spree_static_content 0.60.1 → 0.70.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/README.md +45 -0
  2. data/app/controllers/static_content_controller.rb +2 -2
  3. data/app/models/page.rb +8 -5
  4. data/app/overrides/static_content_admin_tab.rb +4 -0
  5. data/app/views/admin/pages/_form.html.erb +1 -2
  6. data/app/views/admin/pages/edit.html.erb +1 -1
  7. data/lib/generators/spree_static_content/install_generator.rb +13 -8
  8. data/lib/spree_static_content.rb +8 -2
  9. metadata +64 -77
  10. data/.gitignore +0 -2
  11. data/CONTRIBUTORS.textile +0 -7
  12. data/README.rdoc +0 -34
  13. data/Rakefile +0 -113
  14. data/VERSION +0 -1
  15. data/Versionfile +0 -3
  16. data/config/locales/de-CH.yml +0 -23
  17. data/config/locales/en-AU.yml +0 -23
  18. data/config/locales/en-GB.yml +0 -23
  19. data/config/locales/en.yml +0 -32
  20. data/config/locales/es-ES.yml +0 -18
  21. data/config/locales/fr-FR.yml +0 -23
  22. data/config/locales/nl-BE.yml +0 -23
  23. data/config/locales/nl-NL.yml +0 -23
  24. data/config/locales/pl.yml +0 -21
  25. data/config/locales/pt-BR.yml +0 -15
  26. data/config/locales/ru.yml +0 -33
  27. data/config/routes.rb +0 -9
  28. data/lib/generators/templates/db/migrate/20081216193152_create_pages.rb +0 -15
  29. data/lib/generators/templates/db/migrate/20090625125735_extend_pages.rb +0 -21
  30. data/lib/generators/templates/db/migrate/20090814113100_add_visible_to_pages.rb +0 -10
  31. data/lib/generators/templates/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb +0 -8
  32. data/lib/generators/templates/db/migrate/20090829000527_add_index_for_page.rb +0 -10
  33. data/lib/generators/templates/db/migrate/20091219021134_add_meta_fields_to_pages.rb +0 -9
  34. data/lib/generators/templates/db/migrate/20100204105222_add_layout_to_pages.rb +0 -9
  35. data/lib/generators/templates/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb +0 -9
  36. data/lib/generators/templates/public/stylesheets/formtastic.css +0 -145
  37. data/lib/generators/templates/public/stylesheets/formtastic_changes.css +0 -14
  38. data/lib/spree_static_content_hooks.rb +0 -5
  39. data/spec/controllers/admin/pages_controller_spec.rb +0 -5
  40. data/spec/controllers/content_controller_spec.rb +0 -18
  41. data/spec/models/page_spec.rb +0 -20
  42. data/spec/spec.opts +0 -3
  43. data/spec/spec_helper.rb +0 -28
  44. data/spree_static_content.gemspec +0 -96
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Spree Static Content
2
+
3
+ Good, clean content management of pages for Spree. You can use this to:
4
+
5
+ - Add and manage static pages such as an 'About' page.
6
+ - Show a static page instead of existing dynamic pages such as the home page,
7
+ products pages, and taxon pages.
8
+
9
+ ## HowTo
10
+
11
+ See the wiki for some more documentation on how you can use this extension.
12
+
13
+ - use spree_editor.
14
+ - override dynamic pages.
15
+ - ...
16
+
17
+ ## Basic Installation
18
+
19
+ 1. Add the following to your Gemfile
20
+ <pre>
21
+ gem 'spree_static_content', :git => 'github.com/spree/spree_static_content'
22
+ </pre>
23
+ 2. Run `bundle install`
24
+ 3. To copy and apply migrations run: `rails g spree_static_content:install`
25
+
26
+ ## Development
27
+
28
+ 1. fork the repo here: https://github.com/spree/spree_static_content
29
+ 2. inside your fork run `bundle install`
30
+ 3. make sure the tests can run on your system run : `bundle exec rake test_app && bundle exec rspec spec`
31
+
32
+ You can also run `bundle exec rake test_app` and then to run the specs run `bundle exec rake`
33
+
34
+ ### Fix bugs or add functionality
35
+
36
+ 1. create a feature branch
37
+ <pre>
38
+ git checkout -b my-feature-branch
39
+ </pre>
40
+ 2. Apply your changes and add specs.
41
+ 3. Push the feature branch to your fork:
42
+ <pre>
43
+ git push -u origin my-feature-branch
44
+ </pre>
45
+ 4. Send a pull request from your feature branch in the forked repository on github.
@@ -12,14 +12,14 @@ class StaticContentController < Spree::BaseController
12
12
  end
13
13
 
14
14
  unless @page = Page.visible.find_by_slug(path)
15
- render :file => "#{RAILS_ROOT}/public/404.html", :layout => false, :status => 404
15
+ render_404
16
16
  end
17
17
  end
18
18
 
19
19
  private
20
20
 
21
21
  def accurate_title
22
- @page ? @page.title : nil
22
+ @page ? (@page.meta_title ? @page.meta_title : @page.title) : nil
23
23
  end
24
24
  end
25
25
 
data/app/models/page.rb CHANGED
@@ -4,10 +4,11 @@ class Page < ActiveRecord::Base
4
4
  validates_presence_of :title
5
5
  validates_presence_of [:slug, :body], :if => :not_using_foreign_link?
6
6
 
7
- scope :header_links, where(["show_in_header = ?", true])
8
- scope :footer_links, where(["show_in_footer = ?", true])
9
- scope :sidebar_links, where(["show_in_sidebar = ?", true])
10
7
  scope :visible, where(:visible => true)
8
+ scope :header_links, where(:show_in_header => true).visible
9
+ scope :footer_links, where(:show_in_footer => true).visible
10
+ scope :sidebar_links, where(:show_in_sidebar => true).visible
11
+
11
12
 
12
13
  before_save :update_positions_and_slug
13
14
 
@@ -33,8 +34,10 @@ private
33
34
  end
34
35
  end
35
36
 
36
- self.slug = slug_link
37
- Rails.cache.delete('page_not_exist/' + self.slug)
37
+ if not_using_foreign_link?
38
+ self.slug = slug_link
39
+ Rails.cache.delete('page_not_exist/' + self.slug)
40
+ end
38
41
  return true
39
42
  end
40
43
 
@@ -0,0 +1,4 @@
1
+ Deface::Override.new(:virtual_path => "layouts/admin",
2
+ :name => "static_content_admin_tab",
3
+ :insert_bottom => "[data-hook='admin_tabs']",
4
+ :text => "<%= tab(:pages) %>")
@@ -1,10 +1,9 @@
1
- <%= stylesheet_link_tag 'formtastic', 'formtastic_changes' %>
2
-
3
1
  <%= f.inputs do %>
4
2
  <%= f.input :title %>
5
3
  <%= f.input :slug %>
6
4
  <%= f.input :body %>
7
5
  <%= f.input :foreign_link %>
6
+ <%= f.input :meta_title %>
8
7
  <%= f.input :meta_keywords %>
9
8
  <%= f.input :meta_description %>
10
9
  <%= f.input :show_in_sidebar %>
@@ -1,7 +1,7 @@
1
1
  <h1><%= t("static_content.editing_page") %></h1>
2
2
  <%= render "shared/error_messages", :target => @page %>
3
3
 
4
- <% semantic_form_for([:admin, @page]) do |f| -%>
4
+ <%= semantic_form_for([:admin, @page]) do |f| -%>
5
5
  <%= render :partial => "form", :locals => { :f => f } %>
6
6
  <p class="form-buttons">
7
7
  <%= button t("actions.update"), nil, 'submit' %>
@@ -1,18 +1,23 @@
1
1
  module SpreeStaticContent
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path("../../templates", __FILE__)
5
4
 
6
- desc "Configures your Rails application for use with spree_static_content"
7
-
8
- def copy_migrations
9
- directory "db"
5
+ def add_stylesheets
6
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require formtastic\n", :before => /\*\//, :verbose => true
10
7
  end
11
-
12
- def copy_public
13
- directory "public"
8
+
9
+ def add_migrations
10
+ run 'rake railties:install:migrations FROM=spree_static_content'
14
11
  end
15
12
 
13
+ def run_migrations
14
+ res = ask "Would you like to run the migrations now? [Y/n]"
15
+ if res == "" || res.downcase == "y"
16
+ run 'rake db:migrate'
17
+ else
18
+ puts "Skiping rake db:migrate, don't forget to run it!"
19
+ end
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -1,11 +1,17 @@
1
1
  require 'spree_core'
2
- require 'spree_static_content_hooks'
2
+ require 'formtastic'
3
3
 
4
4
  module SpreeStaticContent
5
5
  class Engine < Rails::Engine
6
+ engine_name 'spree_static_content'
7
+
6
8
  def self.activate
7
9
  Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
8
- Rails.env == "production" ? require(c) : load(c)
10
+ Rails.application.config.cache_classes ? require(c) : load(c)
11
+ end
12
+
13
+ Dir.glob(File.join(File.dirname(__FILE__), "../app/overrides/**/*.rb")) do |c|
14
+ Rails.application.config.cache_classes ? require(c) : load(c)
9
15
  end
10
16
  end
11
17
  config.to_prepare &method(:activate).to_proc
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_static_content
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 257
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
- - 60
8
- - 1
9
- version: 0.60.1
8
+ - 70
9
+ - 3
10
+ version: 0.70.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Peter Berkenbosch
@@ -15,138 +16,124 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-06-25 00:00:00 +04:00
19
- default_executable:
19
+ date: 2012-03-01 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: spree_core
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 261
28
30
  segments:
29
31
  - 0
30
- - 60
31
- - 0
32
- version: 0.60.0
32
+ - 70
33
+ - 1
34
+ version: 0.70.1
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
36
- name: spree_editor
38
+ name: spree_auth
37
39
  prerelease: false
38
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
39
42
  requirements:
40
43
  - - ">="
41
44
  - !ruby/object:Gem::Version
45
+ hash: 261
42
46
  segments:
43
47
  - 0
44
- - 50
45
- - 0
46
- version: 0.50.0
48
+ - 70
49
+ - 1
50
+ version: 0.70.1
47
51
  type: :runtime
48
52
  version_requirements: *id002
49
53
  - !ruby/object:Gem::Dependency
50
54
  name: formtastic
51
55
  prerelease: false
52
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
53
58
  requirements:
54
- - - ~>
59
+ - - ">="
55
60
  - !ruby/object:Gem::Version
61
+ hash: 3
56
62
  segments:
57
- - 1
58
- - 2
59
- - 3
60
- version: 1.2.3
63
+ - 0
64
+ version: "0"
61
65
  type: :runtime
62
66
  version_requirements: *id003
63
- description: Extention to manage the static pages for your Spree shop.
64
- email:
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec-rails
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 3
76
+ segments:
77
+ - 0
78
+ version: "0"
79
+ type: :development
80
+ version_requirements: *id004
81
+ description:
82
+ email: peter@pero-ict.nl
65
83
  executables: []
66
84
 
67
85
  extensions: []
68
86
 
69
- extra_rdoc_files:
70
- - README.rdoc
87
+ extra_rdoc_files: []
88
+
71
89
  files:
72
- - .gitignore
73
- - CONTRIBUTORS.textile
74
- - README.rdoc
75
- - Rakefile
76
- - VERSION
77
- - Versionfile
78
- - app/controllers/admin/pages_controller.rb
79
- - app/controllers/spree/base_controller_decorator.rb
80
- - app/controllers/static_content_controller.rb
90
+ - README.md
91
+ - lib/spree_static_content.rb
92
+ - lib/generators/spree_static_content/install_generator.rb
81
93
  - app/models/page.rb
82
94
  - app/views/admin/pages/_form.html.erb
83
95
  - app/views/admin/pages/edit.html.erb
84
- - app/views/admin/pages/index.html.erb
85
96
  - app/views/admin/pages/new.html.erb
97
+ - app/views/admin/pages/index.html.erb
86
98
  - app/views/static_content/show.html.erb
87
- - config/locales/de-CH.yml
88
- - config/locales/en-AU.yml
89
- - config/locales/en-GB.yml
90
- - config/locales/en.yml
91
- - config/locales/es-ES.yml
92
- - config/locales/fr-FR.yml
93
- - config/locales/nl-BE.yml
94
- - config/locales/nl-NL.yml
95
- - config/locales/pl.yml
96
- - config/locales/pt-BR.yml
97
- - config/locales/ru.yml
98
- - config/routes.rb
99
- - lib/generators/spree_static_content/install_generator.rb
100
- - lib/generators/templates/db/migrate/20081216193152_create_pages.rb
101
- - lib/generators/templates/db/migrate/20090625125735_extend_pages.rb
102
- - lib/generators/templates/db/migrate/20090814113100_add_visible_to_pages.rb
103
- - lib/generators/templates/db/migrate/20090814142845_add_default_true_to_visible_for_page.rb
104
- - lib/generators/templates/db/migrate/20090829000527_add_index_for_page.rb
105
- - lib/generators/templates/db/migrate/20091219021134_add_meta_fields_to_pages.rb
106
- - lib/generators/templates/db/migrate/20100204105222_add_layout_to_pages.rb
107
- - lib/generators/templates/db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb
108
- - lib/generators/templates/public/stylesheets/formtastic.css
109
- - lib/generators/templates/public/stylesheets/formtastic_changes.css
110
- - lib/spree_static_content.rb
111
- - lib/spree_static_content_hooks.rb
112
- - spec/controllers/admin/pages_controller_spec.rb
113
- - spec/controllers/content_controller_spec.rb
114
- - spec/models/page_spec.rb
115
- - spec/spec.opts
116
- - spec/spec_helper.rb
117
- - spree_static_content.gemspec
118
- has_rdoc: true
119
- homepage: http://github.com/spree/spree-static-content
99
+ - app/overrides/static_content_admin_tab.rb
100
+ - app/controllers/spree/base_controller_decorator.rb
101
+ - app/controllers/static_content_controller.rb
102
+ - app/controllers/admin/pages_controller.rb
103
+ homepage: http://spreecommerce.com/extensions/139-static-content
120
104
  licenses: []
121
105
 
122
106
  post_install_message:
123
- rdoc_options:
124
- - --charset=UTF-8
107
+ rdoc_options: []
108
+
125
109
  require_paths:
126
110
  - lib
127
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
128
113
  requirements:
129
114
  - - ">="
130
115
  - !ruby/object:Gem::Version
116
+ hash: 57
131
117
  segments:
132
- - 0
133
- version: "0"
118
+ - 1
119
+ - 8
120
+ - 7
121
+ version: 1.8.7
134
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
135
124
  requirements:
136
125
  - - ">="
137
126
  - !ruby/object:Gem::Version
127
+ hash: 3
138
128
  segments:
139
129
  - 0
140
130
  version: "0"
141
- requirements: []
142
-
131
+ requirements:
132
+ - none
143
133
  rubyforge_project:
144
- rubygems_version: 1.3.6
134
+ rubygems_version: 1.8.15
145
135
  signing_key:
146
136
  specification_version: 3
147
137
  summary: Extention to manage the static pages for your Spree shop.
148
- test_files:
149
- - spec/models/page_spec.rb
150
- - spec/spec_helper.rb
151
- - spec/controllers/content_controller_spec.rb
152
- - spec/controllers/admin/pages_controller_spec.rb
138
+ test_files: []
139
+
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- .DS_Store
2
- nbproject
data/CONTRIBUTORS.textile DELETED
@@ -1,7 +0,0 @@
1
- h2. Contributors list - Thanks guys!
2
-
3
- |Maxim Filatov|http://github.com/Bregor|
4
- |Marcin Raczkowski|http://github.com/swistak|
5
- |Roman Smirnov|http://github.com/romul|
6
- |Eliot Sykes|http://github.com/eliotsykes|
7
- |Oliver Azevedo Barnes|http://github.com/oliverbarnes|
data/README.rdoc DELETED
@@ -1,34 +0,0 @@
1
- = Static Content
2
-
3
- Good, clean content management of pages for Spree. You can use this to:
4
-
5
- - Add and manage static pages such as an 'About' page.
6
- - Show a static page instead of existing dynamic pages such as the home page,
7
- products pages, and taxon pages.
8
-
9
- To override a dynamic page, use the path of that dynamic page as the slug when
10
- you create your page in the Spree Administration area, including the
11
- leading slash. For example:
12
-
13
- - to override the home page, use a path of '/' (without quotes).
14
- - to override a product page, use its path, e.g. '/products/apache-baseball-jersey' (without quotes).
15
-
16
- The dynamic page can be made available again if you delete the static page or change its slug.
17
-
18
- Create your own copy of the app/views/content/show.html.erb template in your site
19
- extension to change the layout of the static pages.
20
-
21
- === Example to use the static pages inside a menu
22
- <ul>
23
- <% for page in Page.header_links do %>
24
- <li><%= link_to page.title, page.link %></li>
25
- <% end %>
26
- </ul>
27
-
28
- == Installation
29
-
30
- 1. Add `gem "spree_static_content"` and `gem "spree_editor", :git => "git://github.com/romul/spree_editor.git"` to your Gemfile
31
- 1. Run `bundle install`
32
- 1. Run `rails g spree_static_content:install`
33
- 1. Run `rake db:migrate`
34
- 1. Run `rake spree_editor:install`
data/Rakefile DELETED
@@ -1,113 +0,0 @@
1
- # encoding: utf-8
2
- require 'rubygems'
3
- begin
4
- require 'jeweler'
5
- rescue LoadError
6
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
7
- exit 1
8
- end
9
- #gem 'rdoc', '= 2.2'
10
- require 'rdoc'
11
- require 'rake'
12
- require 'rake/testtask'
13
- require 'rake/rdoctask'
14
- require 'rake/packagetask'
15
- require 'rake/gempackagetask'
16
-
17
- Jeweler::Tasks.new do |s|
18
- s.name = "spree_static_content"
19
- s.summary = "Extention to manage the static pages for your Spree shop."
20
- s.description = s.summary
21
- #s.email = ""
22
- s.homepage = "http://github.com/spree/spree-static-content"
23
- s.authors = ["Peter Berkenbosch", "Roman Smirnov"]
24
- s.add_dependency 'spree_core', '>= 0.60.0'
25
- s.add_dependency 'spree_editor', '>= 0.50.0'
26
- s.add_dependency 'formtastic', '~> 1.2.3'
27
- #s.has_rdoc = false
28
- #s.extra_rdoc_files = [ "README.rdoc"]
29
- #s.rdoc_options = ["--main", "README.rdoc", "--inline-source", "--line-numbers"]
30
- #s.test_files = Dir['test/**/*.{yml,rb}']
31
- end
32
- Jeweler::GemcutterTasks.new
33
-
34
-
35
- require 'spec/rake/spectask'
36
- # require 'spec/translator'
37
-
38
- extension_root = File.expand_path(File.dirname(__FILE__))
39
-
40
- task :default => :spec
41
- task :stats => "spec:statsetup"
42
-
43
- desc "Run all specs in spec directory"
44
- Spec::Rake::SpecTask.new(:spec) do |t|
45
- t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
46
- t.spec_files = FileList['spec/**/*_spec.rb']
47
- end
48
-
49
- namespace :spec do
50
- desc "Run all specs in spec directory with RCov"
51
- Spec::Rake::SpecTask.new(:rcov) do |t|
52
- t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
53
- t.spec_files = FileList['spec/**/*_spec.rb']
54
- t.rcov = true
55
- t.rcov_opts = ['--exclude', 'spec', '--rails']
56
- end
57
-
58
- desc "Print Specdoc for all specs"
59
- Spec::Rake::SpecTask.new(:doc) do |t|
60
- t.spec_opts = ["--format", "specdoc", "--dry-run"]
61
- t.spec_files = FileList['spec/**/*_spec.rb']
62
- end
63
-
64
- [:models, :controllers, :views, :helpers].each do |sub|
65
- desc "Run the specs under spec/#{sub}"
66
- Spec::Rake::SpecTask.new(sub) do |t|
67
- t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
68
- t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
69
- end
70
- end
71
-
72
- # Hopefully no one has written their extensions in pre-0.9 style
73
- # desc "Translate specs from pre-0.9 to 0.9 style"
74
- # task :translate do
75
- # translator = ::Spec::Translator.new
76
- # dir = RAILS_ROOT + '/spec'
77
- # translator.translate(dir, dir)
78
- # end
79
-
80
- # Setup specs for stats
81
- task :statsetup do
82
- require 'code_statistics'
83
- ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
84
- ::STATS_DIRECTORIES << %w(View\ specs spec/views)
85
- ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
86
- ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
87
- ::CodeStatistics::TEST_TYPES << "Model specs"
88
- ::CodeStatistics::TEST_TYPES << "View specs"
89
- ::CodeStatistics::TEST_TYPES << "Controller specs"
90
- ::CodeStatistics::TEST_TYPES << "Helper specs"
91
- ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
92
- end
93
- end
94
-
95
- desc 'Generate documentation for the static_content extension.'
96
- Rake::RDocTask.new(:rdoc) do |rdoc|
97
- rdoc.rdoc_dir = 'rdoc'
98
- rdoc.title = 'StaticContentExtension'
99
- rdoc.options << '--line-numbers' << '--inline-source'
100
- rdoc.rdoc_files.include('README')
101
- rdoc.rdoc_files.include('lib/**/*.rb')
102
- end
103
-
104
- # For extensions that are in transition
105
- desc 'Test the static_content extension.'
106
- Rake::TestTask.new(:test) do |t|
107
- t.libs << 'lib'
108
- t.pattern = 'test/**/*_test.rb'
109
- t.verbose = true
110
- end
111
-
112
- # Load any custom rakefiles for extension
113
- Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }