omeka-recipes 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
@@ -0,0 +1,23 @@
1
+ ## 0.3.0
2
+
3
+ Additional tasks for deploy for cleaning up, performing git-style upgrades,
4
+ and mapping setup directories for the `#{shared_path}`.
5
+
6
+ * Travis integration
7
+ * Maintenance pages for system upgrades
8
+ * Seppuku for destroying everything
9
+
10
+
11
+ ## 0.2.1
12
+
13
+ This release contained mainly bug fixes and fixed consistency issues with the
14
+ descriptions of individual tasks.
15
+
16
+ * Ensure '|OmekaRecipes|' surrounds all tasks. Jeremy Boggs (clioweb)
17
+ * Fixes VERSION constant redefinition
18
+ * Added IniFile dependency to gem
19
+
20
+ ## 0.2.0
21
+
22
+ Initial release of the gem.
23
+
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Omeka::Recipes
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/waynegraham/omeka-recipes.png)](http://travis-ci.org/waynegraham/omeka-recipes)
4
+
3
5
  Useful Capistrano recipes including:
4
6
 
5
7
  * Create MySQL database and user on server (via prompts)
@@ -9,21 +11,31 @@ Useful Capistrano recipes including:
9
11
 
10
12
  ## Included Tasks
11
13
 
12
- * `cap apache:reload`
13
- * `cap apache:restart`
14
- * `cap apache:start`
15
- * `cap apache:stop`
16
- * `cap db:create_ini`
17
- * `cap db:myql:dump`
18
- * `cap db:myql:fetch_dump`
19
- * `cap db:myql:restore`
20
- * `cap db:mysql:setup`
21
- * `cap log:rotate`
22
- * `cap log:tail`
23
- * `cap omeka:db_ini`
24
- * `cap omeka:plugins`
25
- * `cap omeka:themes`
26
- * `cap symlinks:make`
14
+ * cap apache:reload # |OmekaRecipes| Reload Apache
15
+ * cap apache:restart # |OmekaRecipes| Restart Apache
16
+ * cap apache:start # |OmekaRecipes| Start Apache
17
+ * cap apache:stop # |OmekaRecipes| Stop Apache
18
+ * cap db:create_ini # |OmekaRecipes| Create db.ini in shared pa...
19
+ * cap db:mysql:dump # |OmekaRecipes| Performs a compressed data...
20
+ * cap db:mysql:fetch_dump # |OmekaRecipes| Downloads the compressed d...
21
+ * cap db:mysql:restore # |OmekaRecipes| Restores the database from...
22
+ * cap db:mysql:setup # |OmekaRecipes| Create MySQL database and ...
23
+ * cap deploy # |OmekaRecipes| Deploy omeka, github-style
24
+ * cap deploy:seppuku # |OmekaRecipes| Destroys everything
25
+ * cap deploy:setup_dirs # |OmekaRecipes| Create shared dirs
26
+ * cap deploy:symlink # |OmekaRecipes| Alias for symlinks:make
27
+ * cap log:rotate # |OmekaRecipes| Install log rotation scrip...
28
+ * cap log:tail # |OmekaRecipes| Tail all log files
29
+ * cap omeka:db_ini # |OmekaRecipes| Add the db.ini to the shar...
30
+ * cap omeka:fix_archive_permissions # |OmekaRecipes| Ensure the archive directo...
31
+ * cap omeka:get_plugins # |OmekaRecipes| Deploy the plugins defined...
32
+ * cap omeka:get_themes # |OmekaRecipes| Deploy the themes defined ...
33
+ * cap omeka:link_archive_dir # |OmekaRecipes| Link the archive directoy ...
34
+ * cap omeka:maintenance:start # |OmekaRecipes| Add a maitenance page for ...
35
+ * cap omeka:move_archive_dir # |OmekaRecipes| Move the archive directory...
36
+ * cap omeka:move_files_to_shared # |OmekaRecipes| Move a pristine copy of th...
37
+ * cap omeka:rename_files # |OmekaRecipes| Rename files
38
+ * cap symlinks:make # |OmekaRecipes| Make all the symlinks in a...`
27
39
 
28
40
  ## Installation
29
41
 
@@ -164,3 +176,4 @@ See the [LICENSE](https://github.com/waynegraham/omeka-recipes/blob/master/LICEN
164
176
 
165
177
  * Jeremy Boggs ([clioweb](clioweb))
166
178
  * Wayne Graham ([waynegraham](https://github.com/waynegraham))
179
+
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rake/testtask'
5
+
6
+ Rake::TestTask.new(:test) do |test|
7
+ test.libs << 'lib' << 'test'
8
+ test.pattern = 'test/**/*_test.rb'
9
+ test.verbose = true
10
+ end
11
+
12
+ task :default => :test
@@ -32,7 +32,7 @@ Capistrano::Configuration.instance.load do
32
32
  set :rvm_ruby_string, '1.9.3' unless exists?(:rvm_ruby_string)
33
33
  end
34
34
 
35
- set :shared_dirs, %w(archives) unless exists?(:shared_dirs)
35
+ set :shared_dirs, %w(archive) unless exists?(:shared_dirs)
36
36
 
37
37
  namespace :app do
38
38
  task :setup, :roles => :app do
@@ -0,0 +1,30 @@
1
+ Capistrano::Configuration.instance.load do
2
+ set :shared_children, %w(system logs pids config archive)
3
+
4
+ namespace :deploy do
5
+ desc '|OmekaRecipes| Deploy omeka, github-style'
6
+ task :default, :roles => :app, :except => { :no_release => true } do
7
+ update
8
+ end
9
+
10
+
11
+ desc '|OmekaRecipes| Destroys everything'
12
+ task :seppuku, :roles => :app, :except => { :no_release => true } do
13
+ run "rm -rf #{current_path}; rm -rf #{shared_path}"
14
+ end
15
+
16
+ desc '|OmekaRecipes| Create shared dirs'
17
+ task :setup_dirs, :roles => :app, :except => { :no_release => true } do
18
+ commands = shared_dirs.map do |path|
19
+ "mkdir -p #{shared_path}/#{path}"
20
+ end
21
+ run commands.join(" && ")
22
+ end
23
+
24
+ desc '|OmekaRecipes| Alias for symlinks:make'
25
+ task :symlink, :roles => :app, :except => { :no_release => true } do
26
+ symlinks.make
27
+ end
28
+
29
+ end
30
+ end
@@ -39,6 +39,13 @@ Capistrano::Configuration.instance.load do
39
39
  run "touch #{shared_path}/db.ini"
40
40
  end
41
41
 
42
+ desc '|OmekaRecipes| Move a pristine copy of the archives/files directory to the shared_path'
43
+ task :move_files_to_shared, :except => { :no_release => true } do
44
+ #run "touch #{shared_path}/db.ini"
45
+ run "mkdir -p #{shared_path}/application/logs/"
46
+ run "touch #{shared_path}/application/logs/erros.log"
47
+ end
48
+
42
49
  desc '|OmekaRecipes| Deploy the plugins defined in the plugins hash'
43
50
  task :get_plugins do
44
51
  git_clone(plugins, 'plugins')
@@ -49,11 +56,63 @@ Capistrano::Configuration.instance.load do
49
56
  git_clone(themes, 'themes')
50
57
  end
51
58
 
59
+ namespace :maintenance do
60
+ desc <<-DESC
61
+ |OmekaRecipes| Add a maitenance page for visitors. Disables your Omeka
62
+ isntance by writing a "#{maintenance_basename}.html" file to each web
63
+ server. The servers must be configured to detect the presence of the file,
64
+ and if it is present, display the maintenance page instead of performaning
65
+ the request.
66
+
67
+ $ cap omeka:maintenance:start \\
68
+ REASON="hardware upgrade" \\
69
+ UNTIL="12pm EST"
70
+
71
+ You can use a different template for the maintenace page by setting the
72
+ :maintenace_template_path variable in your deploy.rb. The template file
73
+ should either be a plaintext or an erb file.
74
+ DESC
75
+ task :start, :roles => :web, :except => { :no_release => true } do
76
+ require 'erb'
77
+ on_rollback { run "rm -f #{shared_path}/system/maintenance.html" }
78
+
79
+ warn <<-HTACCESS
80
+ # Please add something like this to your site's Apache htaccess to redirect users to the maintenance page.
81
+ # More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503
82
+
83
+ ErrorDocument 503 /system/maintenance.html
84
+ RewriteEngine On
85
+ RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$
86
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
87
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
88
+ RewriteRule ^.*$ - [redirect=503,last]
89
+ HTACCESS
90
+
91
+ reason = ENV['REASON']
92
+ deadline = ENV['UNTIL']
93
+
94
+ template = File.read(maintenance_template_path)
95
+ result = ERB.new(template).result(binding)
96
+
97
+ put result, "#{shared_path}/system/maintenance.html", :mode => 0644
98
+ end
99
+
100
+ desc <<-DESC
101
+ Enables the application web-accessible again. Removes the \n
102
+ "maintenance.html" page generated by deploy:maitenance:start,
103
+ which, (if your server is configured properly) will make Omeka web-
104
+ accessible again.
105
+ DESC
106
+ task :end, :roles => :web, :except => { :no_release => true } do
107
+ run "rm -f #{shared_path}/system/#{maintenance_basename}.html"
108
+ end
109
+ end
52
110
  end
53
111
 
54
112
  after 'deploy:cold', 'omeka:fix_archive_permissions', 'omeka:move_archive_dir'
113
+ after 'deploy:setup', 'omeka:move_files_to_shared'
55
114
  #before 'deploy:create_symlink', 'omeka:move_archive_dir'
56
- after 'deploy:create_symlink', 'omeka:link_archive_dir'
115
+ #after 'deploy:create_symlink', 'omeka:link_archive_dir'
57
116
  after 'deploy', 'omeka:get_themes', 'omeka:get_plugins', 'omeka:rename_files'
58
117
 
59
118
  end
@@ -1,6 +1,6 @@
1
1
  Capistrano::Configuration.instance.load do
2
2
  # these are set to the same structure in shared <=> current
3
- set :normal_symlinks, %w(application/logs/ archive) unless exists?(:normal_symlinks)
3
+ set :normal_symlinks, %w(archive db.ini) unless exists?(:normal_symlinks)
4
4
 
5
5
  # weird symlinks go somewhere else
6
6
  set :weird_symlinks, {'db.ini' => 'db.ini.changeme'} unless exists?( :weird_symlinks )
@@ -1,5 +1,5 @@
1
1
  module Omeka
2
2
  module Recipes
3
- RECIPES_VERSION = "0.2.1"
3
+ RECIPES_VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -0,0 +1,59 @@
1
+ <!DOCTYPE HTML>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Maintenance</title>
6
+ <style>
7
+ ::-moz-selection {
8
+ background: #b3d4fc;
9
+ text-shadow: none;
10
+ }
11
+ ::selection {
12
+ background: #b3d4fc;
13
+ text-shadow: none;
14
+ }
15
+ html {
16
+ padding: 30px 10px;
17
+ font-size: 20px;
18
+ line-height: 1.4;
19
+ color: #737373;
20
+ background: #f0f0f0;
21
+ -webkit-text-size-adjust: 100%;
22
+ -ms-text-size-adjust: 100%;
23
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
24
+ max-width: 500px;
25
+ _width: 500px;
26
+ padding: 30ps 20px 50px;
27
+ border: 1px solid #b3b3b3;
28
+ border-radius: 4px;
29
+ margin: 0 auto;
30
+ box-shadow: 0 1px 10px #a7a7a7, inset 0 1px 0 #fff;
31
+ background: #fcfcfc;
32
+ }
33
+ #container {
34
+ max-width: 380px;
35
+ _width: 380px;
36
+ margin: 0 auto;
37
+ }
38
+ h1 {
39
+ margin: 0 10px;
40
+ font-size: 50px;
41
+ text-align: center;
42
+ }
43
+ p { margin: 1em 0 }
44
+ </style>
45
+ </head>
46
+ <body>
47
+ <div id="container">
48
+ <h1>The system is down</h1>
49
+ <p>
50
+ The system is down for <%= reason ? reason : 'maintenance' %> as of
51
+ <%= Time.now.strftime("%H:%M %Z") %>.
52
+ </p>
53
+
54
+ <p>
55
+ It'll be back <%= deadline ? deadline : "shortly" %>.
56
+ </p>
57
+ </div>
58
+ </body>
59
+ </html>
@@ -0,0 +1,5 @@
1
+ set :application, "foo"
2
+ set :repository, "1/2/#{application}"
3
+ set :gateway, "#{__FILE__}.example.com"
4
+
5
+ role :web, "www.example.com", :primary => true
@@ -0,0 +1,7 @@
1
+ [database]
2
+ host = "sds2.itc.virginia.edu"
3
+ username = "ships_user"
4
+ password = "(fB1hg14w43t7811"
5
+ name = "ships_staging"
6
+ prefix = "omeka_"
7
+ ;port = ""
@@ -0,0 +1,24 @@
1
+
2
+
3
+ def fetch_db_ini
4
+ require 'fileutils'
5
+ require 'IniFile'
6
+
7
+ file_path = "./db.ini"
8
+ @db_config = IniFile.new(:filename => file_path).to_h
9
+ end
10
+
11
+ def prepare_from_ini
12
+ puts @db_config['database']['username']
13
+ puts @db_config['database']['password']
14
+ puts @db_config['database']['host']
15
+ puts @db_config['database']['name']
16
+ puts @db_config['database']['prefix']
17
+ puts @db_config['database']['charset']
18
+
19
+ end
20
+
21
+ fetch_db_ini
22
+ test = prepare_from_ini
23
+
24
+
@@ -0,0 +1,8 @@
1
+ require 'omeka-recipes/omeka.rb'
2
+
3
+ class OmekaTest < Test::Unit::TestCase
4
+ def setup
5
+ @config = {}
6
+
7
+ end
8
+ end
@@ -0,0 +1,27 @@
1
+ require 'utils'
2
+ require 'capistrano/configuration'
3
+
4
+ class RecipesTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ @config = Capistrano::Configuration.new
8
+ @config.stubs(:logger).returns(stub_everything)
9
+ end
10
+
11
+
12
+ def test_current_release_does_not_cause_error_on_dry_run
13
+ @config.dry_run = true
14
+ @config.load 'deploy'
15
+ @config.load do
16
+ set :application, 'foo'
17
+ task :dry_run_test do
18
+ fetch :current_release
19
+ end
20
+ end
21
+
22
+ assert_nothing_raised do
23
+ @config.dry_run_test
24
+ end
25
+
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omeka-recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-22 00:00:00.000000000 Z
12
+ date: 2012-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -102,6 +102,8 @@ extra_rdoc_files:
102
102
  files:
103
103
  - .gitignore
104
104
  - .rvmrc
105
+ - .travis.yml
106
+ - CHANGELOG
105
107
  - Gemfile
106
108
  - LICENSE
107
109
  - README.md
@@ -111,11 +113,18 @@ files:
111
113
  - lib/omeka-recipes/apache.rb
112
114
  - lib/omeka-recipes/application.rb
113
115
  - lib/omeka-recipes/db.rb
116
+ - lib/omeka-recipes/deploy.rb
114
117
  - lib/omeka-recipes/log.rb
115
118
  - lib/omeka-recipes/omeka.rb
116
119
  - lib/omeka-recipes/symlinks.rb
117
120
  - lib/omeka-recipes/version.rb
121
+ - lib/templates/maintenance.html.erb
118
122
  - omeka-recipes.gemspec
123
+ - tests/fixtures/config.rb
124
+ - tests/fixtures/db.ini
125
+ - tests/fixtures/test.rb
126
+ - tests/omeka_test.rb
127
+ - tests/recipes_test.rb
119
128
  homepage: https://github.com/waynegraham/omeka-recipes
120
129
  licenses: []
121
130
  post_install_message:
@@ -130,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
139
  version: '0'
131
140
  segments:
132
141
  - 0
133
- hash: 2626221885588276034
142
+ hash: 4283888623917739916
134
143
  required_rubygems_version: !ruby/object:Gem::Requirement
135
144
  none: false
136
145
  requirements:
@@ -139,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
148
  version: '0'
140
149
  segments:
141
150
  - 0
142
- hash: 2626221885588276034
151
+ hash: 4283888623917739916
143
152
  requirements: []
144
153
  rubyforge_project:
145
154
  rubygems_version: 1.8.24