Skip to content

Commit

Permalink
AO3-4736 Broken skins path (otwcode#2919)
Browse files Browse the repository at this point in the history
  • Loading branch information
zz9pzza authored and sarken committed May 18, 2017
1 parent 8e80a4e commit 93a9f8a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app/models/challenge_signup.rb
Expand Up @@ -217,7 +217,7 @@ def self.generate_summary_in_background(collection)
end

def self.summary_dir
"#{Rails.public_path}/static/challenge_signup_summaries"
Rails.public_path.join("static/challenge_signup_summaries").to_s
end

def self.summary_file(collection)
Expand Down
15 changes: 8 additions & 7 deletions app/models/skin.rb
Expand Up @@ -271,10 +271,10 @@ def parse_sheet_role(role_string)
end

def get_css
if self.filename
File.read(Rails.public_path + self.filename)
if filename
File.read(Rails.public_path.join("." + filename))
else
self.css
css
end
end

Expand Down Expand Up @@ -386,7 +386,8 @@ def get_cached_style(roles_to_include)
end

def stylesheet_link(file, media)
'<link rel="stylesheet" type="text/css" media="' + media + '" href="/' + file + '" />'
# we want one and only one / in the url path
'<link rel="stylesheet" type="text/css" media="' + media + '" href="/' + file.gsub(/^\/*/,"") + '" />'
end

def self.naturalized(string)
Expand Down Expand Up @@ -472,15 +473,15 @@ def skin_dirname
end

def self.skins_dir
Rails.public_path + SKIN_PATH
Rails.public_path.join(SKIN_PATH).to_s
end

def self.skin_dir_entries(dir, regex)
Dir.entries(dir).select {|f| f.match(regex)}.sort_by {|f| Skin.naturalized(f.to_s)}
end

def self.site_skins_dir
Rails.public_path + SITE_SKIN_PATH
Rails.public_path.join(SITE_SKIN_PATH).to_s
end

# Get the most recent version and find the topmost skin
Expand All @@ -505,7 +506,7 @@ def self.create_default
skin = Skin.find_or_create_by(title: "Default", css: "", public: true, role: "user")
current_version = Skin.get_current_version
if current_version
File.open(Skin.site_skins_dir + current_version + 'preview.png', 'rb') {|preview_file| skin.icon = preview_file}
File.open(Skin.site_skins_dir + current_version + '/preview.png', 'rb') {|preview_file| skin.icon = preview_file}
else
File.open(Skin.site_skins_dir + 'preview.png', 'rb') {|preview_file| skin.icon = preview_file}
end
Expand Down
53 changes: 26 additions & 27 deletions lib/tasks/after_tasks.rake
Expand Up @@ -153,17 +153,16 @@ namespace :After do
# end
# end


desc "Clear out old epub files"
task(:remove_old_epubs => :environment) do
download_dir = "#{Rails.public_path}/downloads/"
cmd = %Q{find #{download_dir} -depth -name epub -exec rm -rf {} \\;}
puts cmd
`#{cmd}`
cmd = %Q{find #{download_dir} -name "*.epub" -exec rm {} \\;}
puts cmd
`#{cmd}`
end
# desc "Clear out old epub files"
# task(:remove_old_epubs => :environment) do
# download_dir = Rails.public_path.join("downloads").to_s
# cmd = %Q{find #{download_dir} -depth -name epub -exec rm -rf {} \\;}
# puts cmd
# `#{cmd}`
# cmd = %Q{find #{download_dir} -name "*.epub" -exec rm {} \\;}
# puts cmd
# `#{cmd}`
# end

# desc "update filter taggings since nov 21"
# task(:update_filter_taggings => :environment) do
Expand Down Expand Up @@ -234,7 +233,7 @@ namespace :After do
# end



# desc "Set complete status for works"
# task(:set_complete_status => :environment) do
# Work.update_all("complete = 1", "expected_number_of_chapters = 1")
Expand Down Expand Up @@ -280,7 +279,7 @@ namespace :After do
# convert_restriction_tagset(meme.request_restriction, owners, title + "_requests")
# end
# end
#
#
# def convert_restriction_tagset(restriction, owner_pseuds, title)
# if restriction && restriction.tag_set_id
# tag_set_title = "Tag Set For #{title.gsub(/[^\w\s]+/, '_')}"
Expand All @@ -296,7 +295,7 @@ namespace :After do
# end
# end
# end
#
#
# desc "Convert existing skins to be based off version 1.0"
# task(:convert_existing_skins => :environment) do
# oldskin = Skin.find_by_title_and_official("Archive 1.0", true)
Expand All @@ -322,37 +321,37 @@ namespace :After do
#
#
# require 'nokogiri'
#
#
# desc "Esacape ampersands in work titles"
# task(:escape_ampersands => :environment) do
# Work.where("title LIKE '%&%'").each do |work|
# work.title = Nokogiri::HTML.fragment(work.title).to_s
# work.save
# end
# end
#
#
# desc "Set stat counts for works"
# task(:set_work_stats => :environment) do
# Work.find_each do |work|
# puts work.id
# work.update_stat_counter
# end
# end
#
#
# desc "Set anon/unrevealed status for works"
# task(:set_anon_unrevealed => :environment) do
# CollectionItem.where("(anonymous = 1 OR unrevealed = 1) AND item_type = 'Work'").each do |collection_item|
# puts collection_item.id
# work = collection_item.item
# if work.present?
# work.update_attributes(
# in_anon_collection: collection_item.anonymous,
# in_anon_collection: collection_item.anonymous,
# in_unrevealed_collection: collection_item.unrevealed
# )
# end
# end
# end
#
#
# desc "Add filters to external works"
# task(:external_work_filters => :environment) do
# ExternalWork.find_each do |ew|
Expand All @@ -362,19 +361,19 @@ namespace :After do
# end

#### Add your new tasks here


desc "Set initial values for sortable tag names"
task(:sortable_tag_names => :environment) do
Media.all.each{ |m| m.save }

Fandom.find_each do |fandom|
fandom.set_sortable_name
puts fandom.sortable_name
fandom.save
end
end

desc "Increase skins' width threshold for handheld devices to 640px"
task(:increase_handheld_width => :environment) do
hh_width_media = "only screen and (max-width: 480px)"
Expand All @@ -395,9 +394,9 @@ namespace :After do
lang = Language.find_by_short(short)
if lang.present?
Locale.create(
iso: iso,
short: short,
name: lang.name,
iso: iso,
short: short,
name: lang.name,
language_id: lang.id
)
else
Expand Down Expand Up @@ -465,7 +464,7 @@ namespace :After do
end

if skin.background_color.present? || skin.foreground_color.present? || skin.font.present? || skin.base_em.present?
wizard_css += "body, #main {
wizard_css += "body, #main {
#{skin.background_color.present? ? "background: #{skin.background_color}; " : ''}
#{skin.foreground_color.present? ? "color: #{skin.foreground_color}; " : ''} "
if skin.base_em.present?
Expand Down Expand Up @@ -507,7 +506,7 @@ end # this is the end that you have to put new tasks above
# ADD NEW MIGRATE TASKS TO THIS LIST ONCE THEY ARE WORKING

# Remove tasks from the list once they've been run on the deployed site
# NOTE:
# NOTE:
desc "Run all current migrate tasks"
# task :After => ['After:convert_tag_sets', 'autocomplete:reload_tagset_data', 'skins:disable_all', 'skins:unapprove_all',
# 'skins:load_site_skins', 'After:convert_existing_skins', 'skins:load_user_skins', 'After:remove_old_epubs']
Expand Down

0 comments on commit 93a9f8a

Please sign in to comment.