typo 3.99.2 → 3.99.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/app/controllers/articles_controller.rb +21 -14
  2. data/app/controllers/content_controller.rb +3 -5
  3. data/app/controllers/xml_controller.rb +13 -3
  4. data/app/helpers/application_helper.rb +7 -1
  5. data/app/helpers/xml_helper.rb +23 -0
  6. data/app/models/article.rb +5 -0
  7. data/app/models/content.rb +2 -0
  8. data/app/models/ping.rb +32 -22
  9. data/app/views/admin/content/_form.rhtml +1 -0
  10. data/app/views/admin/general/index.rhtml +1 -1
  11. data/app/views/admin/pages/_form.rhtml +1 -0
  12. data/app/views/articles/_comment_box.rhtml +1 -0
  13. data/app/views/xml/_googlesitemap_item_article.rxml +5 -0
  14. data/app/views/xml/_googlesitemap_item_category.rxml +4 -0
  15. data/app/views/xml/_googlesitemap_item_page.rxml +4 -0
  16. data/app/views/xml/_googlesitemap_item_tag.rxml +4 -0
  17. data/app/views/xml/googlesitemap_feed.rxml +7 -0
  18. data/app/views/xml/itunes_feed.rxml +4 -4
  19. data/bin/typo +10 -0
  20. data/components/plugins/sidebars/archives_controller.rb +20 -14
  21. data/components/plugins/sidebars/delicious/content.rhtml +4 -4
  22. data/components/plugins/textfilters/amazon_controller.rb +1 -1
  23. data/config/routes.rb +2 -1
  24. data/doc/Installer.txt +21 -4
  25. data/installer/rails-installer.rb +78 -90
  26. data/installer/rails-installer/commands.rb +117 -0
  27. data/installer/rails-installer/web-server.rb +108 -0
  28. data/installer/rails-installer/web-servers.rb +108 -0
  29. data/installer/rails_installer_defaults.yml +1 -0
  30. data/lib/sidebars/plugin.rb +1 -1
  31. data/lib/tasks/release.rake +2 -1
  32. data/lib/typo_version.rb +1 -1
  33. data/log/development.log-1 +991 -0
  34. data/log/development.log-2 +422 -0
  35. data/log/development.log-3 +429 -0
  36. data/log/development.log-4 +174 -0
  37. data/public/javascripts/typo.js +8 -0
  38. data/test/fixtures/contents.yml +5 -0
  39. data/test/functional/articles_controller_test.rb +2 -2
  40. data/test/functional/xml_controller_test.rb +8 -0
  41. data/test/test_helper.rb +2 -0
  42. data/themes/scribbish/CONTRIBUTORS +2 -0
  43. data/themes/scribbish/about.markdown +9 -0
  44. data/themes/scribbish/images/background.gif +0 -0
  45. data/themes/scribbish/images/gravatar.gif +0 -0
  46. data/themes/scribbish/images/header_shadow.gif +0 -0
  47. data/themes/scribbish/images/spinner.gif +0 -0
  48. data/themes/scribbish/layouts/default.rhtml +42 -0
  49. data/themes/scribbish/preview.png +0 -0
  50. data/themes/scribbish/stylesheets/application.css +27 -0
  51. data/themes/scribbish/stylesheets/content.css +400 -0
  52. data/themes/scribbish/stylesheets/layout.css +70 -0
  53. data/themes/scribbish/views/articles/_article.rhtml +37 -0
  54. data/themes/scribbish/views/articles/_comment.rhtml +14 -0
  55. data/themes/scribbish/views/articles/_comment_form.rhtml +47 -0
  56. data/themes/scribbish/views/articles/_search.rhtml +15 -0
  57. data/themes/scribbish/views/articles/_trackback.rhtml +9 -0
  58. data/themes/scribbish/views/articles/comment_preview.rhtml +10 -0
  59. data/themes/scribbish/views/articles/index.rhtml +5 -0
  60. data/themes/scribbish/views/articles/read.rhtml +42 -0
  61. data/tmp/cache/META/DATA/ACTION_PARAM/10.1.0.181/articles/index/.cache +537 -0
  62. data/tmp/cache/META/DATA/ACTION_PARAM/localhost/articles/index/.cache +537 -0
  63. data/tmp/cache/META/DATA/ACTION_PARAM/localhost/xml/feed/format=atom&type=feed.cache +671 -0
  64. data/tmp/cache/META/DATA/ACTION_PARAM/localhost/xml/feed/format=rss20&type=feed.cache +401 -0
  65. data/tmp/cache/META/META/ACTION_PARAM/10.1.0.181/articles/index/.cache +2 -0
  66. data/tmp/cache/META/META/ACTION_PARAM/localhost/articles/index/.cache +2 -0
  67. data/tmp/cache/META/META/ACTION_PARAM/localhost/xml/feed/format=atom&type=feed.cache +2 -0
  68. data/tmp/cache/META/META/ACTION_PARAM/localhost/xml/feed/format=rss20&type=feed.cache +2 -0
  69. data/vendor/plugins/expiring_action_cache/lib/actionparamcache.rb +2 -1
  70. metadata +91 -2
data/doc/Installer.txt CHANGED
@@ -47,6 +47,15 @@ Installing Typo
47
47
  installer/apache.conf.example to run your Typo installation under Apache.
48
48
 
49
49
 
50
+ Upgrading Typo
51
+ --------------
52
+
53
+ The Typo installer can upgrade an existing installer-created Typo install by
54
+ simple running 'typo install DIRECTORY'. The installer will automatically
55
+ detect that it's upgrading an existing install and will attempt to preserve
56
+ the existing configuration as much as possible.
57
+
58
+
50
59
  Starting and Stopping Typo
51
60
  --------------------------
52
61
 
@@ -55,10 +64,18 @@ To stop Typo from running, run `typo stop /path/to/typo`. To restart it, run
55
64
  you can't depend on your web server restarting it automatically on reboot. You'll need to either create an init script or cron reboot entry to restart it, depending on your host and/or privilege level.
56
65
 
57
66
 
67
+ Configuration Variables
68
+ -----------------------
69
+
70
+ Each Typo installation maintains a list of configuration variables. To see
71
+ the list for an existing install, run 'typo config DIRECTORY'. You can change
72
+ them via 'typo config DIRECTORY name1=value1 name2=value2...' For example:
73
+
74
+ typo config /var/www/typo web-server=mongrel_cluster
75
+
76
+
58
77
  TODO
59
78
  ----
60
79
 
61
- 1. Actually write the Apache HTTP proxy instructions (for 1.3 and 2.x)
62
- 2. Add lighttpd proxy directions.
63
- 3. Figure out how to best have Typo restart on reboot.
64
- 4. Handle the "missing swig" problem better.
80
+ 1. Figure out how to best have Typo restart on reboot.
81
+ 2. Handle the "missing swig" problem better.
@@ -4,6 +4,9 @@ require 'rubygems'
4
4
  require 'yaml'
5
5
  require 'digest/sha1'
6
6
 
7
+ require 'installer/rails-installer/web-servers'
8
+ require 'installer/rails-installer/commands'
9
+
7
10
  class RailsInstaller
8
11
  include FileUtils
9
12
  attr_accessor :install_directory, :source_directory, :config
@@ -24,10 +27,16 @@ class RailsInstaller
24
27
  def self.rails_version(svn_tag)
25
28
  @@rails_version = svn_tag
26
29
  end
30
+
31
+ def app_name
32
+ @@app_name
33
+ end
27
34
 
28
35
  def initialize(install_directory)
29
36
  # use an absolute path, not a relative path.
30
- @install_directory = File.expand_path(install_directory)
37
+ if install_directory
38
+ @install_directory = File.expand_path(install_directory)
39
+ end
31
40
 
32
41
  @config = read_yml(config_file) rescue nil
33
42
  @config ||= Hash.new
@@ -45,10 +54,9 @@ class RailsInstaller
45
54
  # Install Application
46
55
  def install(version=nil)
47
56
  @source_directory = find_source_directory(@@app_name,version)
48
-
49
- if config.size == 0
50
- @config = read_yml(backup_config_file)
51
- end
57
+
58
+ # Merge default configuration settings
59
+ @config = read_yml(backup_config_file).merge(config)
52
60
 
53
61
  install_sequence
54
62
 
@@ -84,36 +92,24 @@ class RailsInstaller
84
92
 
85
93
  # Start application in the background
86
94
  def start(foreground = false)
87
- return unless config['web-server'] == 'mongrel'
88
-
89
- args = {}
90
- args['-p'] = config['port-number']
91
- args['-a'] = config['bind-address']
92
- args['-e'] = config['rails-environment']
93
- args['-d'] = foreground
94
- args['-P'] = pid_file
95
-
96
- # Remove keys with nil values
97
- args.delete_if {|k,v| v==nil}
95
+ server_class = RailsInstaller::WebServer.servers[config['web-server']]
96
+ if not server_class
97
+ message "** warning: web-server #{config['web-server']} unknown. Use 'web-server=external' to disable."
98
+ end
98
99
 
99
- args_array = args.to_a.flatten.map {|e| e.to_s}
100
- args_array = ['mongrel_rails', 'start', install_directory] + args_array
101
- message "Starting #{@@app_name.capitalize} on port #{config['port-number']}"
102
- system(args_array.join(' '))
100
+ server_class.start(self,foreground)
103
101
  end
104
102
 
105
103
  # Stop application
106
104
  def stop
107
- return unless File.exists? pid_file
108
- return unless config['web-server'] == 'mongrel'
105
+ return unless File.directory?(install_directory)
109
106
 
110
- args = {}
111
- args['-P'] = pid_file
107
+ server_class = RailsInstaller::WebServer.servers[config['web-server']]
108
+ if not server_class
109
+ message "** warning: web-server #{config['web-server']} unknown. Use 'web-server=external' to disable."
110
+ end
112
111
 
113
- args_array = args.to_a.flatten.map {|e| e.to_s}
114
- args_array = ['mongrel_rails', 'stop', install_directory] + args_array
115
- message "Stopping #{@@app_name.capitalize}"
116
- system(args_array.join(' '))
112
+ server_class.stop(self)
117
113
  end
118
114
 
119
115
  # private
@@ -126,7 +122,6 @@ class RailsInstaller
126
122
  # Backup the database
127
123
  def backup_database
128
124
  return unless File.exists? db_file
129
- Dir.chdir(install_directory)
130
125
 
131
126
  return unless config['database'] == 'sqlite'
132
127
  new_db_file = db_file+"-#{Time.now.strftime('%Y%m%d-%H%M')}.sql"
@@ -184,7 +179,6 @@ class RailsInstaller
184
179
  end
185
180
 
186
181
  write_yml(files_yml,new_files)
187
- Dir.chdir(install_directory)
188
182
  end
189
183
 
190
184
  # Copy one file from source_directory to install_directory, creating directories as needed.
@@ -295,11 +289,14 @@ class RailsInstaller
295
289
  # Create the default database.yml
296
290
  def create_default_database_yml
297
291
  database_yml = File.join(install_directory,'config','database.yml')
298
- return if File.exist?(database_yml)
299
- return unless config['database'] == 'sqlite'
300
292
 
293
+ if File.exist?(database_yml)
294
+ message "Preserving database.yml"
295
+ return
296
+ end
297
+
301
298
  message "Creating default database configuration file"
302
- cp("#{database_yml}.sqlite",database_yml)
299
+ cp("#{database_yml}.#{config['database']}",database_yml)
303
300
  end
304
301
 
305
302
  # Create required directories, like tmp
@@ -353,10 +350,11 @@ class RailsInstaller
353
350
  # Are we downgrading?
354
351
  if old_schema_version > new_schema_version
355
352
  message "Downgrading schema from #{old_schema_version} to #{new_schema_version}"
356
- status = system("rake -s migrate VERSION=#{new_schema_version}")
357
353
 
358
- unless status
359
- raise InstallFailed, "Downgrade migrating from #{old_schema_version} to #{new_schema_version} failed."
354
+ in_directory install_directory do
355
+ unless system("rake -s migrate VERSION=#{new_schema_version}")
356
+ raise InstallFailed, "Downgrade migrating from #{old_schema_version} to #{new_schema_version} failed."
357
+ end
360
358
  end
361
359
  end
362
360
  end
@@ -364,25 +362,27 @@ class RailsInstaller
364
362
  # Migrate the database
365
363
  def migrate
366
364
  message "Migrating #{@@app_name.capitalize}'s database to newest release"
367
- status = system("rake -s migrate")
368
365
 
369
- unless status
370
- raise InstallFailed, "Migration failed"
366
+ in_directory install_directory do
367
+ unless system("rake -s migrate")
368
+ raise InstallFailed, "Migration failed"
369
+ end
371
370
  end
372
371
  end
373
372
 
374
373
  # Sweep the cache
375
374
  def run_rails_tests
376
375
  message "Running tests. This may take a minute or two"
377
- status = system_silently("rake -s test")
378
376
 
379
- if status
380
- message "All tests pass. Congratulations."
381
- else
382
- message "***** Tests failed *****"
383
- message "** Please run 'rake test' by hand in your install directory."
384
- message "** Report problems to #{@@support_location}."
385
- message "***** Tests failed *****"
377
+ in_directory install_directory do
378
+ if system_silently("rake -s test")
379
+ message "All tests pass. Congratulations."
380
+ else
381
+ message "***** Tests failed *****"
382
+ message "** Please run 'rake test' by hand in your install directory."
383
+ message "** Report problems to #{@@support_location}."
384
+ message "***** Tests failed *****"
385
+ end
386
386
  end
387
387
  end
388
388
 
@@ -414,10 +414,6 @@ class RailsInstaller
414
414
  end
415
415
  end
416
416
 
417
- def pid_file
418
- File.join(install_directory,'tmp','pid.txt')
419
- end
420
-
421
417
  # Locate the source directory for a specific Version
422
418
  def find_source_directory(gem_name, version)
423
419
  if version == 'cwd'
@@ -471,50 +467,42 @@ class RailsInstaller
471
467
  exit(1)
472
468
  end
473
469
 
474
- case args[0]
475
- when 'install'
476
- install(args[2])
477
- when 'upgrade'
478
- install(args[2])
479
- when 'start'
480
- start
481
- when 'stop'
482
- stop
483
- when 'run'
484
- start(true)
485
- when 'config'
486
- if args.size < 3
487
- config.keys.sort.each do |k|
488
- puts "#{k}=#{config[k]}"
489
- end
490
- else
491
- args[2..-1].each do |arg|
492
- if(arg=~/^([^=]+)=(.*)$/)
493
- config[$1.to_s]=$2.to_s
494
- else
495
- STDERR.puts "Unknown config command: #{arg}"
496
- end
497
- end
498
- save
499
- end
470
+ command_class = Command.commands[args.first]
471
+
472
+ if command_class
473
+ command_class.command(self,*(args[2..-1]))
500
474
  else
501
- display_help('Unknown command')
475
+ display_help
476
+ exit(1)
502
477
  end
503
478
  end
504
479
 
505
480
  def display_help(error=nil)
506
481
  STDERR.puts error if error
507
- STDERR.puts "Commands:"
508
- STDERR.puts " typo install DIRECTORY [VERSION]"
509
- STDERR.puts " Installs Typo into DIRECTORY. If there's an existing Typo install in"
510
- STDERR.puts " DIRECTORY, then the installer will upgrade the installation instead."
511
- STDERR.puts " typo start DIRECTORY"
512
- STDERR.puts " Starts a Typo server in DIRECTORY."
513
- STDERR.puts " typo stop DIRECTORY"
514
- STDERR.puts " Shuts down a Typo server in DIRECTORY."
515
- STDERR.puts " typo config DIRECTORY"
516
- STDERR.puts " Shows configuration variables for Typo."
517
- STDERR.puts " typo config DIRECTORY NAME=VALUE..."
518
- STDERR.puts " Sets configuration variables for Typo."
482
+
483
+ commands = Command.commands.keys.sort
484
+ commands.each do |cmd|
485
+ cmd_class = Command.commands[cmd]
486
+ cmd_help = cmd_class.help(self)
487
+
488
+ STDERR.puts " #{app_name} #{cmd} DIRECTORY #{cmd_help.first}"
489
+ STDERR.puts " #{cmd_help.last}"
490
+ end
519
491
  end
520
492
  end
493
+
494
+ # Run a block inside of a specific directory. Chdir into the directory
495
+ # before executing the block, then chdir back to the original directory
496
+ # when the block exits.
497
+ def in_directory(directory)
498
+ begin
499
+ old_dir = Dir.pwd
500
+ Dir.chdir(directory)
501
+ value = yield
502
+ ensure
503
+ Dir.chdir(old_dir)
504
+ end
505
+
506
+ return value
507
+ end
508
+
@@ -0,0 +1,117 @@
1
+ class RailsInstaller
2
+
3
+ # Parent class for webserver plugins for the installer. To create a new
4
+ # webserver handler, subclass this class and define a 'start' and 'stop'
5
+ # class method.
6
+ class Command
7
+ @@command_map = {}
8
+
9
+ def self.command(installer, *args)
10
+ raise "Not Implemented"
11
+ end
12
+
13
+ def self.help(installer)
14
+ end
15
+
16
+ def self.inherited(sub)
17
+ name = sub.to_s.gsub(/^.*::/,'').gsub(/([A-Z])/) do |match|
18
+ "_#{match.downcase}"
19
+ end.gsub(/^_/,'')
20
+
21
+ @@command_map[name] = sub
22
+ end
23
+
24
+ def self.commands
25
+ @@command_map
26
+ end
27
+
28
+ class Install < RailsInstaller::Command
29
+ def self.command(installer, *args)
30
+ version = nil
31
+ args.each do |arg|
32
+ if(arg =~ /^([^=]+)=(.*)$/)
33
+ installer.config[$1.to_s] = $2.to_s
34
+ else
35
+ version = arg
36
+ end
37
+ end
38
+
39
+ installer.install(version)
40
+ end
41
+
42
+ def self.help(installer)
43
+ ['',"Install or upgrade #{installer.app_name} in PATH."]
44
+ end
45
+ end
46
+
47
+ class Config < RailsInstaller::Command
48
+ def self.command(installer, *args)
49
+ if args.size == 0
50
+ installer.config.keys.sort.each do |k|
51
+ puts "#{k}=#{installer.config[k]}"
52
+ end
53
+ else
54
+ args.each do |arg|
55
+ if(arg=~/^([^=]+)=(.*)$/)
56
+ if $2.to_s.empty?
57
+ installer.config.delete($1.to_s)
58
+ else
59
+ installer.config[$1.to_s]=$2.to_s
60
+ end
61
+ else
62
+ puts installer.config[arg]
63
+ end
64
+ end
65
+ installer.save
66
+ end
67
+
68
+ end
69
+
70
+ def self.help(installer)
71
+ ['[KEY=VALUE]...',"Read or set a #{installer.app_name} configuration variable"]
72
+ end
73
+ end
74
+
75
+ class Start < RailsInstaller::Command
76
+ def self.command(installer, *args)
77
+ installer.start
78
+ end
79
+
80
+ def self.help(installer)
81
+ ['',"Start the web server for #{installer.app_name} in the background"]
82
+ end
83
+ end
84
+
85
+ class Run < RailsInstaller::Command
86
+ def self.command(installer, *args)
87
+ installer.start(true)
88
+ end
89
+
90
+ def self.help(installer)
91
+ ['',"Start the web server for #{installer.app_name} in the foreground"]
92
+ end
93
+ end
94
+
95
+ class Restart < RailsInstaller::Command
96
+ def self.command(installer, *args)
97
+ installer.stop
98
+ installer.start
99
+ end
100
+
101
+ def self.help(installer)
102
+ ['',"Stop and restart the web server for #{installer.app_name}."]
103
+ end
104
+ end
105
+
106
+ class Stop < RailsInstaller::Command
107
+ def self.command(installer, *args)
108
+ installer.stop
109
+ end
110
+
111
+ def self.help(installer)
112
+ ['',"Stop the web server for #{installer.app_name}"]
113
+ end
114
+ end
115
+ end
116
+ end
117
+
@@ -0,0 +1,108 @@
1
+ class RailsInstaller
2
+
3
+ # Parent class for webserver plugins for the installer. To create a new
4
+ # webserver handler, subclass this class and define a 'start' and 'stop'
5
+ # class method.
6
+ class WebServer
7
+ @@server_map = {}
8
+
9
+ def self.start(installer, foreground)
10
+ raise "Not Implemented"
11
+ end
12
+
13
+ def self.stop(installer, foreground)
14
+ raise "Not Implemented"
15
+ end
16
+
17
+ def self.inherited(sub)
18
+ name = sub.to_s.gsub(/^.*::/,'').gsub(/([A-Z])/) do |match|
19
+ "_#{match.downcase}"
20
+ end.gsub(/^_/,'')
21
+
22
+ @@server_map[name] = sub
23
+ end
24
+
25
+ def self.servers
26
+ @@server_map
27
+ end
28
+
29
+ class Mongrel < RailsInstaller::WebServer
30
+ def self.start(installer, foreground)
31
+ args = {}
32
+ args['-p'] = installer.config['port-number']
33
+ args['-a'] = installer.config['bind-address']
34
+ args['-e'] = installer.config['rails-environment']
35
+ args['-d'] = foreground
36
+ args['-P'] = pid_file(installer)
37
+
38
+ # Remove keys with nil values
39
+ args.delete_if {|k,v| v==nil}
40
+
41
+ args_array = args.to_a.flatten.map {|e| e.to_s}
42
+ args_array = ['mongrel_rails', 'start', installer.install_directory] + args_array
43
+ installer.message "Starting #{installer.app_name.capitalize} on port #{installer.config['port-number']}"
44
+ in_directory installer.install_directory do
45
+ system(args_array.join(' '))
46
+ end
47
+ end
48
+
49
+ def self.stop(installer)
50
+ args = {}
51
+ args['-P'] = pid_file(installer)
52
+
53
+ args_array = args.to_a.flatten.map {|e| e.to_s}
54
+ args_array = ['mongrel_rails', 'stop', installer.install_directory] + args_array
55
+ installer.message "Stopping #{installer.app_name.capitalize}"
56
+ in_directory installer.install_directory do
57
+ system(args_array.join(' '))
58
+ end
59
+
60
+ end
61
+
62
+ def self.pid_file(installer)
63
+ File.join(installer.install_directory,'tmp','pid.txt')
64
+ end
65
+ end
66
+
67
+ class MongrelCluster < RailsInstaller::WebServer
68
+ def self.start(installer, foreground)
69
+ args = {}
70
+ args['-p'] = installer.config['port-number']
71
+ args['-a'] = installer.config['bind-address']
72
+ args['-e'] = installer.config['rails-environment']
73
+ args['-N'] = installer.config['threads']
74
+
75
+ # Remove keys with nil values
76
+ args.delete_if {|k,v| v==nil}
77
+
78
+ args_array = args.to_a.flatten.map {|e| e.to_s}
79
+ args_array = ['mongrel_rails', 'cluster::configure'] + args_array
80
+ installer.message "Configuring mongrel_cluster for #{installer.app_name.capitalize}"
81
+ in_directory installer.install_directory do
82
+ system(args_array.join(' '))
83
+ end
84
+ installer.message "Starting #{installer.app_name.capitalize} on port #{installer.config['port-number']}"
85
+ in_directory installer.install_directory do
86
+ system('mongrel_rails cluster::start')
87
+ end
88
+
89
+ end
90
+
91
+ def self.stop(installer)
92
+ installer.message "Stopping #{installer.app_name.capitalize}"
93
+ in_directory installer.install_directory do
94
+ system('mongrel_rails cluster::stop')
95
+ end
96
+ end
97
+ end
98
+
99
+ # Do-nothing webserver class. Used when the installer doesn't control the web server.
100
+ class External < RailsInstaller::WebServer
101
+ def self.start(installer, foreground)
102
+ end
103
+
104
+ def self.stop(installer)
105
+ end
106
+ end
107
+ end
108
+ end