Skip to content

Commit

Permalink
Migration script and wiki nav tweak.
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnfaraday committed Apr 8, 2018
1 parent 79b01dc commit 6718103
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 16 deletions.
88 changes: 88 additions & 0 deletions beta10_gamedir_shuffle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[engine]))

require 'fileutils'
require 'aresmush'


module AresMUSH

puts "======================================================================="
puts "Put the game dir back where it belongs."
puts "======================================================================="

src = File.join(AresMUSH.root_path, "game.backup")
if (Dir.exist?(src) && !Dir.exist?(AresMUSH.game_path))
FileUtils.mv src, AresMUSH.game_path
end

puts "======================================================================="
puts "Formatting config files."
puts "======================================================================="

files = Dir["#{File.join(AresMUSH.game_path, "config")}/*"]
files.each do |path|
hash = YAML::load( File.read(path) )
File.open(path, 'w') do |file|
file.puts hash.to_yaml
end
end

puts "======================================================================="
puts "Adding new default config options."
puts "======================================================================="

website_tagline = ""
website_welcome = ""

src = File.join(AresMUSH.game_path, "config", "website.yml")
hash = YAML::load( File.read(src) )
hash['website']['left_sidebar'] = false
hash['website']['wiki_nav'] = [ 'Home' ]
website_welcome = hash['website']['website_welcome']
website_tagline = hash['website']['website_tagline']

File.open(src, 'w') do |file|
file.puts hash.to_yaml
end

src = File.join(AresMUSH.game_path, "config", "skin.yml")
hash = YAML::load( File.read(src) )
hash['skin']['line_with_text_color'] = '%x!'
hash['skin']['line_with_text_padding'] = '-'
File.open(src, 'w') do |file|
file.puts hash.to_yaml
end

src = File.join(AresMUSH.game_path, "styles", "colors.scss")
config = File.readlines(src)
if (!config.any? { |c| c =~ /input/ })
config << "$text-color: #333;"
config << "$input-color: $text-color;"
config << "$input-background-color: $background-color;"
end
File.open(src, 'w') do |file|
file.puts config
end

src = File.join(AresMUSH.game_path, "text", "website.txt")
File.open(src, 'w') do |file|
file.puts "<div class=\"jumbotron-tagline\">#{website_tagline}</div>"
file.puts website_welcome
end

puts "======================================================================="
puts "Fixing gitignore."
puts "======================================================================="

src = File.join(AresMUSH.root_path, ".gitignore")
lines = File.readlines(src)
new_lines = []
lines.each do |l|
if (l.chomp != "game/")
new_lines << l
end
end
File.open(src, 'w') do |file|
file.puts new_lines
end
end
3 changes: 2 additions & 1 deletion engine/aresmush/db_migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def migrate
end

def find_migrator_class(migration_name)
search = migration_name.after("_")
search = migration_name.after("_").camelize
search = "Migration#{search}"
class_name = AresMUSH::Migrations.constants.select { |c| c.upcase == search.to_sym.upcase }.first
if (!class_name)
raise "Migration #{migration_name} appears to be misnamed. The migrator class can't be found."
Expand Down
14 changes: 0 additions & 14 deletions install/scripts/format_config.rb

This file was deleted.

6 changes: 5 additions & 1 deletion plugins/website/web/get_sidebar_info_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def handle(request)
nav_list = Global.read_config('website', 'wiki_nav') || [ "Home" ]
nav_list.each do |page_name|
page = WikiPage.find_one_by_name(WikiPage.sanitize_page_name(page_name))
wiki_nav << { url: page.name, heading: page.heading }
if (page)
wiki_nav << { url: page.name, heading: page.heading }
else
Global.logger.warn "Can't find wiki page #{page_name}."
end
end
{
timestamp: Time.now.getutc,
Expand Down

0 comments on commit 6718103

Please sign in to comment.