This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def repair_drop_targets(html_id, widgets=[]) | |
| bad = Website.all.select do |web| | |
| !web.website_template.blank? && ( | |
| web.website_template.drop_targets.find_by_html_id(html_id).blank? || | |
| web.website_template.drop_targets.find_by_html_id(html_id).widgets.blank?) | |
| end | |
| bad.each do |web| | |
| wt = web.website_template | |
| dt = wt.drop_targets.find_by_html_id(html_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Array | |
| def to_file(filepath, sep="\n") | |
| File.open(filepath, 'w') { |f| f.write(join(sep)) } unless blank? | |
| end | |
| def squash | |
| blank? ? [] : flatten.compact.uniq | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## G5 Hub | |
| def get_urn(url) | |
| url.gsub("https://","").gsub(".herokuapp.com","") | |
| end | |
| ## Find all internal clients | |
| Client.where(g5_internal: true).map { |c| get_urn(c.cms_url) } | |
| ## Find all real clients |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## G5 Content Management System | |
| def find_setting_value(target) | |
| Setting.where(Setting.arel_table[:value].matches("%#{target}%")) | |
| end | |
| def find_setting_value_widgets(target) | |
| find_setting_value(target).map do |setting| | |
| setting.owner | |
| end.uniq |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## G5 Content Management System | |
| Website.all.select { |web| web.website_template.blank? }.each do |web| | |
| WebsiteSeederJob.perform_async(web.owner.id) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def array_to_file(arr, file) | |
| File.open(file, 'w') { |f| f.write(arr.join("\n")) } unless arr.blank? | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def file_to_array(file) | |
| arr = [] | |
| if File.exists?(file) | |
| f = File.read(file) | |
| f.each_line { |line| arr << line.strip unless line == "\n" } | |
| end | |
| arr | |
| end |
NewerOlder