Permalink
Browse files

Refactor.

- Code cleanup and formatting.
- Updated gem engine.
- Simplecov and database_cleaner.
- Refactor all locales so they have same pattern based on english intl.
- Fixed spanish and portuguese translations and added i18n-spec tests.
  • Loading branch information...
1 parent fccb460 commit 15a6eed986ef87e82965ac51922e1a62d6a8e946 @futhr futhr committed with JDutil Apr 5, 2013
Showing with 809 additions and 485 deletions.
  1. +14 −3 .gitignore
  2. +1 −1 .rspec
  3. +0 −1 .travis.yml
  4. +2 −1 CONTRIBUTORS.textile
  5. +3 −3 Gemfile
  6. +5 −5 README.md
  7. +8 −10 Rakefile
  8. +1 −1 VERSION
  9. +9 −9 Versionfile
  10. +1 −3 app/controllers/spree/admin/pages_controller.rb
  11. +3 −4 app/controllers/spree/static_content_controller.rb
  12. +7 −7 app/models/spree/page.rb
  13. +5 −5 app/overrides/pages_in_footer.rb
  14. +5 −5 app/overrides/pages_in_header.rb
  15. +5 −5 app/overrides/pages_in_sidebar.rb
  16. +5 −5 app/overrides/static_content_admin_tab.rb
  17. +11 −12 app/views/spree/admin/pages/_form.html.erb
  18. +5 −5 app/views/spree/admin/pages/edit.html.erb
  19. +14 −14 app/views/spree/admin/pages/index.html.erb
  20. +5 −5 app/views/spree/admin/pages/new.html.erb
  21. +1 −1 app/views/spree/static_content/_static_content_footer.html.erb
  22. +1 −1 app/views/spree/static_content/_static_content_header.html.erb
  23. +2 −2 app/views/spree/static_content/_static_content_list.html.erb
  24. +2 −2 app/views/spree/static_content/_static_content_sidebar.html.erb
  25. +9 −10 app/views/spree/static_content/show.html.erb
  26. +31 −14 config/locales/de-CH.yml
  27. +14 −11 config/locales/de.yml
  28. +30 −13 config/locales/en-AU.yml
  29. +30 −13 config/locales/en-GB.yml
  30. +15 −14 config/locales/en.yml
  31. +27 −26 config/locales/es-ES.yml
  32. +26 −25 config/locales/es.yml
  33. +20 −12 config/locales/et.yml
  34. +32 −15 config/locales/fr-FR.yml
  35. +24 −16 config/locales/it.yml
  36. +31 −14 config/locales/nl-BE.yml
  37. +31 −15 config/locales/nl-NL.yml
  38. +31 −12 config/locales/pl.yml
  39. +33 −8 config/locales/pt-BR.yml
  40. +18 −17 config/locales/pt-PT.yml
  41. +20 −13 config/locales/ru.yml
  42. +40 −0 config/locales/sv-SE.yml
  43. +40 −0 config/locales/sv.yml
  44. +2 −3 config/routes.rb
  45. +3 −3 db/migrate/20081216193152_create_pages.rb
  46. +8 −10 db/migrate/20090625125735_extend_pages.rb
  47. +5 −6 db/migrate/20090814113100_add_visible_to_pages.rb
  48. +4 −4 db/migrate/20090814142845_add_default_true_to_visible_for_page.rb
  49. +4 −5 db/migrate/20090829000527_add_index_for_page.rb
  50. +2 −2 db/migrate/20091219021134_add_meta_fields_to_pages.rb
  51. +2 −2 db/migrate/20100204105222_add_layout_to_pages.rb
  52. +3 −3 db/migrate/20100323085528_add_show_in_sidebar_option_to_pages.rb
  53. +2 −2 db/migrate/20110717103112_add_meta_title_to_page.rb
  54. +1 −1 db/migrate/20120723144115_add_render_as_partial_for_layout_for_spree_pages.rb
  55. +28 −0 lib/generators/spree_static_content/install/install_generator.rb
  56. +0 −18 lib/generators/spree_static_content/install_generator.rb
  57. +11 −4 lib/spree_static_content/engine.rb
  58. +5 −0 script/rails
  59. +16 −0 spec/integration/locale_spec.rb
  60. +16 −0 spec/models/locale_spec.rb
  61. +4 −5 spec/models/page_spec.rb
  62. +20 −21 spec/requests/static_content_spec.rb
  63. +35 −26 spec/spec_helper.rb
  64. +4 −0 spec/support/database.yml
  65. +17 −12 spree_static_content.gemspec
View
@@ -1,5 +1,16 @@
+\#*
+*~
+.#*
.DS_Store
-nbproject
-**.gem
+.idea
+.project
+.sass-cache
+coverage
Gemfile.lock
-spec/dummy/
+tmp
+nbproject
+pkg
+*.swp
+spec/dummy
+spec/test
+.rvmrc
View
2 .rspec
@@ -1,3 +1,3 @@
--colour
--format
-progress
+documentation
View
@@ -1,6 +1,5 @@
language: ruby
rvm:
- - 1.8.7
- 1.9.2
- 1.9.3
- 2.0.0
View
@@ -4,4 +4,5 @@ h2. Contributors list - Thanks guys!
|Marcin Raczkowski|http://github.com/swistak|
|Roman Smirnov|http://github.com/romul|
|Eliot Sykes|http://github.com/eliotsykes|
-|Oliver Azevedo Barnes|http://github.com/oliverbarnes|
+|Oliver Azevedo Barnes|http://github.com/oliverbarnes|
+|Tobias Bohwalli|http://github.com/futhr|
View
@@ -1,4 +1,4 @@
-source 'http://rubygems.org/'
-# Remove once there is a gem release for spree 2.0.x
-gem 'spree', github: 'spree/spree'
+source 'https://rubygems.org/'
+
+gem 'spree', github: 'spree/spree' # remove once there is a gem release for spree 2.0.x
gemspec
View
@@ -7,34 +7,34 @@ Good, clean content management of pages for Spree. You can use this to:
- Add and manage static pages such as an 'About' page.
- Show a static page instead of existing dynamic pages such as the home page,
products pages, and taxon pages.
-
+
## HowTo
Using the 'Pages' option in the admin tab, you can add static pages to your Spree install. The page content can
be pulled directly from the database, be a separate layout file or rendered as a partial.
In the admin tab, use the 'New page' option to create a new static page.
-The title, slug, body, and meta fields will replace their respective page elements on load. The title, slug and
+The title, slug, body, and meta fields will replace their respective page elements on load. The title, slug and
body element are all required fields.
Body text provided without a layout / partial being specified will be loaded in the spree_application layout after
it is pulled from the database.
**Layout and Partial Rendering**
-To render an entire page without the spree_application layout, specify a relative path to the layout file (eg.
+To render an entire page without the spree_application layout, specify a relative path to the layout file (eg.
spree/layouts/layout_file_name). This file will not be prefixed with an underscore as it is a layout, not a partial.
To render a partial, specify the path in the layout file name and check the 'Render layout as partial' option. The
path specified in the layout area will not have an underscore, but it will be required in the filename.
-Also note the availability of the render_snippet helper which finds a page by its slug and renders the raw page
+Also note the availability of the render_snippet helper which finds a page by its slug and renders the raw page
body anywhere in your view.
**Options**
-Use the 'Show in' checkboxes to specify whether to display the page links in the header, footer or sidebar. The
+Use the 'Show in' checkboxes to specify whether to display the page links in the header, footer or sidebar. The
position setting alters the order in which they appear.
Finally, toggle the visibility using the 'Visible' checkbox. If it is unchecked, the page will not be available.
View
@@ -1,24 +1,22 @@
-# encoding: utf-8
require 'bundler'
+
Bundler::GemHelper.install_tasks
-Bundler.setup
require 'rspec/core/rake_task'
-RSpec::Core::RakeTask.new
-
require 'spree/testing_support/common_rake'
-desc "Default Task"
-task :default => [ :spec ]
+RSpec::Core::RakeTask.new
+
+task default: [:spec]
namespace :test_app do
- desc 'Rebuild test and cucumber databases'
- task :rebuild_dbs do
- system("cd spec/test_app && rake db:drop db:migrate RAILS_ENV=test && rake db:drop db:migrate RAILS_ENV=cucumber")
+ desc 'Rebuild test database'
+ task :rebuild_db do
+ system('cd spec/test_app && rake db:drop db:migrate RAILS_ENV=test')
end
end
-desc "Generates a dummy app for testing"
+desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'spree_static_content'
Rake::Task['common:test_app'].invoke
View
@@ -1 +1 @@
-1.1.0.beta
+1.1.1.beta
View
@@ -1,9 +1,9 @@
-"2.0.x" => { :branch => 'master' }
-"1.3.x" => { :branch => '1-3-stable' }
-"1.2.x" => { :branch => '1-2-stable' }
-"1.1.x" => { :branch => '1-1-stable', :version => '1.1' }
-"1.0.x" => { :branch => '1-0-stable', :version => '1.0.1' }
-"0.70.x" => { :version => '0.70.3', :ref => '1861f4cd08c0ffa9940f0c81e69ea29b4541dbbd' }
-"0.60.x" => { :tag => "v0.60.2", :version => '0.60.2'}
-"0.50.x" => { :version => '0.40.2', :ref => '45b0050b96809c8fb0f21940f9407e9012a6d420' }
-"0.40.x" => { :version => '0.40.2', :ref => '45b0050b96809c8fb0f21940f9407e9012a6d420' }
+"2.0.x" => { :branch => "master" }
+"1.3.x" => { :branch => "1-3-stable" }
+"1.2.x" => { :branch => "1-2-stable" }
+"1.1.x" => { :branch => "1-1-stable", :version => "1.1" }
+"1.0.x" => { :branch => "1-0-stable", :version => "1.0.1" }
+"0.70.x" => { :version => "0.70.3", :ref => "1861f4cd08c0ffa9940f0c81e69ea29b4541dbbd" }
+"0.60.x" => { :tag => "v0.60.2", :version => "0.60.2" }
+"0.50.x" => { :version => "0.40.2", :ref => "45b0050b96809c8fb0f21940f9407e9012a6d420" }
+"0.40.x" => { :version => "0.40.2", :ref => "45b0050b96809c8fb0f21940f9407e9012a6d420" }
@@ -1,3 +1 @@
-class Spree::Admin::PagesController < Spree::Admin::ResourceController
-
-end
+class Spree::Admin::PagesController < Spree::Admin::ResourceController; end
@@ -1,12 +1,12 @@
class Spree::StaticContentController < Spree::StoreController
- helper "spree/products"
+ helper 'spree/products'
layout :determine_layout
def show
path = case params[:path]
when Array
- '/' + params[:path].join("/")
+ '/' + params[:path].join('/')
when String
'/' + params[:path]
when nil
@@ -18,7 +18,7 @@ def show
end
end
- private
+private
def determine_layout
return @page.layout if @page and @page.layout.present? and not @page.render_layout_as_partial?
@@ -28,5 +28,4 @@ def determine_layout
def accurate_title
@page ? (@page.meta_title.present? ? @page.meta_title : @page.title) : nil
end
-
end
View
@@ -1,14 +1,14 @@
class Spree::Page < ActiveRecord::Base
- default_scope :order => "position ASC"
+ default_scope order: 'position ASC'
validates_presence_of :title
validates_presence_of [:slug, :body], :if => :not_using_foreign_link?
validates_presence_of :layout, :if => :render_layout_as_partial?
- scope :visible, where(:visible => true)
- scope :header_links, where(:show_in_header => true).visible
- scope :footer_links, where(:show_in_footer => true).visible
- scope :sidebar_links, where(:show_in_sidebar => true).visible
+ scope :visible, where(visible: true)
+ scope :header_links, where(show_in_header: true).visible
+ scope :footer_links, where(show_in_footer: true).visible
+ scope :sidebar_links, where(show_in_sidebar: true).visible
before_save :update_positions_and_slug
@@ -38,9 +38,9 @@ def update_positions_and_slug
unless new_record?
return unless prev_position = Spree::Page.find(self.id).position
if prev_position > self.position
- Spree::Page.update_all("position = position + 1", ["? <= position AND position < ?", self.position, prev_position])
+ Spree::Page.update_all('position = position + 1', ['? <= position AND position < ?', self.position, prev_position])
elsif prev_position < self.position
- Spree::Page.update_all("position = position - 1", ["? < position AND position <= ?", prev_position, self.position])
+ Spree::Page.update_all('position = position - 1', ['? < position AND position <= ?', prev_position, self.position])
end
end
@@ -1,5 +1,5 @@
-Deface::Override.new(:virtual_path => "spree/shared/_footer",
- :name => "pages_in_footer",
- :insert_bottom => "#footer-right",
- :partial => "spree/static_content/static_content_footer",
- :disabled => false)
+Deface::Override.new(virtual_path: "spree/shared/_footer",
+ name: "pages_in_footer",
+ insert_bottom: "#footer-right",
+ partial: "spree/static_content/static_content_footer",
+ disabled: false)
@@ -1,5 +1,5 @@
-Deface::Override.new(:virtual_path => "spree/shared/_main_nav_bar",
- :name => "pages_in_header",
- :insert_bottom => "#main-nav-bar",
- :partial => "spree/static_content/static_content_header",
- :disabled => false)
+Deface::Override.new(virtual_path: "spree/shared/_main_nav_bar",
+ name: "pages_in_header",
+ insert_bottom: "#main-nav-bar",
+ partial: "spree/static_content/static_content_header",
+ disabled: false)
@@ -1,5 +1,5 @@
-Deface::Override.new(:virtual_path => "spree/shared/_sidebar",
- :name => "pages_in_sidebar",
- :insert_bottom => "#sidebar",
- :partial => "spree/static_content/static_content_sidebar",
- :disabled => false)
+Deface::Override.new(virtual_path: "spree/shared/_sidebar",
+ name: "pages_in_sidebar",
+ insert_bottom: "#sidebar",
+ partial: "spree/static_content/static_content_sidebar",
+ disabled: false)
@@ -1,5 +1,5 @@
-Deface::Override.new(:virtual_path => "spree/layouts/admin",
- :name => "static_content_admin_tab",
- :insert_bottom => "[data-hook='admin_tabs']",
- :text => "<%= tab(:pages, :icon => 'icon-file') %>",
- :disabled => false)
+Deface::Override.new(virtual_path: "spree/layouts/admin",
+ name: "static_content_admin_tab",
+ insert_bottom: "[data-hook='admin_tabs']",
+ text: "<%= tab(:pages, icon: 'icon-file') %>",
+ disabled: false)
@@ -2,55 +2,55 @@
<div class="alpha ten columns">
<%= f.field_container :title do %>
<%= f.label :title %> <span class="required">*</span><br />
- <%= f.text_field :title, :class => 'fullwidth title' %>
+ <%= f.text_field :title, class: 'fullwidth title' %>
<%= f.error_message_on :title %>
<% end %>
<%= f.field_container :slug do %>
<%= f.label :slug %> <span class="required">*</span><br />
- <%= f.text_field :slug, :class => 'fullwidth title' %>
+ <%= f.text_field :slug, class: 'fullwidth title' %>
<%= f.error_message_on :slug %>
<% end %>
<%= f.field_container :body do %>
<%= f.label :body %><span class="required">*</span><br />
- <%= f.text_area :body, {:class => 'fullwidth'} %>
+ <%= f.text_area :body, {class: 'fullwidth'} %>
<%= f.error_message_on :body %>
<% end %>
</div>
-
+
<div class="omega six columns">
<%= f.field_container :meta_title do %>
<%= f.label :meta_title %><br />
- <%= f.text_field :meta_title, :class => 'fullwidth title' %>
+ <%= f.text_field :meta_title, class: 'fullwidth title' %>
<%= f.error_message_on :meta_title %>
<% end %>
<%= f.field_container :meta_keywords do %>
<%= f.label :meta_keywords %><br />
- <%= f.text_field :meta_keywords, :class => 'fullwidth title' %>
+ <%= f.text_field :meta_keywords, class: 'fullwidth title' %>
<%= f.error_message_on :meta_keywords %>
<% end %>
<%= f.field_container :meta_description do %>
<%= f.label :meta_description %><br />
- <%= f.text_field :meta_description, :class => 'fullwidth title' %>
+ <%= f.text_field :meta_description, class: 'fullwidth title' %>
<%= f.error_message_on :meta_description %>
<% end %>
-
+
<%= f.field_container :layout do %>
<%= f.label :layout %><br />
- <%= f.text_field :layout, :class => 'fullwidth title' %>
+ <%= f.text_field :layout, class: 'fullwidth title' %>
<% end %>
<%= f.field_container :foreign_link do %>
<%= f.label :foreign_link %><br />
- <%= f.text_field :foreign_link, :class => 'fullwidth title' %>
+ <%= f.text_field :foreign_link, class: 'fullwidth title' %>
<% end %>
<%= f.field_container :position do %>
<%= f.label :position %><br />
- <%= f.number_field :position, :min => 0 %>
+ <%= f.number_field :position, min: 0 %>
<% end %>
<ul id="static_page_options">
@@ -75,6 +75,5 @@
<%= f.label :render_layout_as_partial %>
</li>
</ul>
-
</div>
</div>
@@ -1,16 +1,16 @@
<% content_for :page_title do %>
- <%= t("static_content.static_pages") %> <i class="icon-arrow-right"></i> <%= t("static_content.editing_page") %> "<%= @page.title%>"
+ <%= t('static_content.static_pages') %> <i class="icon-arrow-right"></i> <%= t('static_content.editing_page') %> "<%= @page.title %>"
<% end %>
<% content_for :page_actions do %>
- <li><%= button_link_to t(:back_to_static_pages_list), spree.admin_pages_url, :icon => 'icon-arrow-left' %></li>
+ <li><%= button_link_to t(:back_to_static_pages_list), spree.admin_pages_url, icon: 'icon-arrow-left' %></li>
<% end %>
-<%= render "spree/shared/error_messages", :target => @page %>
+<%= render partial: 'spree/shared/error_messages', target: @page %>
<%= form_for [:admin, @page] do |f| %>
<fieldset class="no-border-top">
- <%= render :partial => 'form', :locals => { :f => f } %>
- <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
+ <%= render partial: 'form', f: f %>
+ <%= render partial: 'spree/admin/shared/edit_resource_links' %>
</fieldset>
<% end %>
Oops, something went wrong.

0 comments on commit 15a6eed

Please sign in to comment.