diff --git a/app/assets/javascripts/admin/spree_simple_cms.js b/app/assets/javascripts/admin/spree_simple_cms.js index 7cace55..e69de29 100644 --- a/app/assets/javascripts/admin/spree_simple_cms.js +++ b/app/assets/javascripts/admin/spree_simple_cms.js @@ -1,2 +0,0 @@ -//= require admin/spree_core -//= require ckeditor/init diff --git a/app/assets/javascripts/store/spree_simple_cms.js b/app/assets/javascripts/store/spree_simple_cms.js index e7624f2..83a4ef3 100644 --- a/app/assets/javascripts/store/spree_simple_cms.js +++ b/app/assets/javascripts/store/spree_simple_cms.js @@ -1,6 +1,3 @@ -//= require store/spree_core -//= require ckeditor/init - (function($){ $(document).ready(function(){ diff --git a/app/assets/stylesheets/admin/spree_simple_cms.css b/app/assets/stylesheets/admin/spree_simple_cms.css index ef47b5b..e69de29 100644 --- a/app/assets/stylesheets/admin/spree_simple_cms.css +++ b/app/assets/stylesheets/admin/spree_simple_cms.css @@ -1,21 +0,0 @@ -/* - *= require admin/spree_core - *= require formtastic -*/ - -.formtastic input, .formtastic textarea, .formtastic select { - font-size: 100%; - padding: 5px; -} - -.formtastic button { - margin: 0; - padding: 0 20px 0 0; -} -.formtastic button:hover { - text-shadow: #FFFFFF -1px -1px 0px; -} - -.tags { - margin-right: 5px; -} diff --git a/app/assets/stylesheets/store/spree_simple_cms.css b/app/assets/stylesheets/store/spree_simple_cms.css index 94dbe33..e69de29 100644 --- a/app/assets/stylesheets/store/spree_simple_cms.css +++ b/app/assets/stylesheets/store/spree_simple_cms.css @@ -1,3 +0,0 @@ -/* - *= require store/spree_core -*/ diff --git a/app/controllers/spree/admin/blogs_controller.rb b/app/controllers/spree/admin/blogs_controller.rb deleted file mode 100644 index 63f662d..0000000 --- a/app/controllers/spree/admin/blogs_controller.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Spree - module Admin - class BlogsController < ResourceController - def index - params[:search] ||= {} - params[:search][:meta_sort] ||= "name.asc" - @blogs = @search.result.page(params[:name]).per(Spree::Config[:admin_products_per_page]) - end - - def collection - @search = super.ransack(params[:search]) - end - - def new - @blog = @object - end - - def edit - @blog = @object - end - - def location_after_save - admin_blogs_url - end - - end - end -end \ No newline at end of file diff --git a/app/controllers/spree/admin/posts_controller.rb b/app/controllers/spree/admin/posts_controller.rb index 78f9bab..305720d 100644 --- a/app/controllers/spree/admin/posts_controller.rb +++ b/app/controllers/spree/admin/posts_controller.rb @@ -2,26 +2,41 @@ module Spree module Admin class PostsController < ResourceController def index - params[:search] ||= {} - params[:search][:meta_sort] ||= "name.asc" - @posts = @search.result.published.page(params[:name]).per(Spree::Config[:admin_products_per_page]) + respond_with(@collection) end - - def collection - @search = super.ransack(params[:search]) + + def show + redirect_to( :action => :edit ) end + + def destroy + @static_page = StaticPage.where(:permalink => params[:id]).first! + @static_page.delete - def new - @post = @object - end + flash.notice = I18n.t('notice_messages.page_deleted') - def edit - @post = @object + respond_with(@static_page) do |format| + format.html { redirect_to collection_url } + format.js { render_js_for_destroy } + end end protected + def find_resource + Post.find_by_permalink!(params[:id]) + end + def location_after_save - admin_static_pages_url + edit_admin_post_url(@post) + end + + def collection + return @collection if @collection.present? + params[:q] ||= {} + params[:q][:s] ||= "title asc" + + @search = super.ransack(params[:q]) + @collection = @search.result.page(params[:page]).per(Spree::Config[:admin_post_per_page]) end end end diff --git a/app/controllers/spree/admin/static_pages_controller.rb b/app/controllers/spree/admin/static_pages_controller.rb index 03dd455..e3ca787 100644 --- a/app/controllers/spree/admin/static_pages_controller.rb +++ b/app/controllers/spree/admin/static_pages_controller.rb @@ -1,14 +1,29 @@ module Spree module Admin class StaticPagesController < ResourceController + def index - params[:search] ||= {} - params[:search][:meta_sort] ||= "name.asc" - @static_pages = @search.result.page(params[:name]).per(Spree::Config[:admin_products_per_page]) + respond_with(@collection) end + + def show + redirect_to( :action => :edit ) + end + + def destroy + @static_page = StaticPage.where(:permalink => params[:id]).first! + @static_page.delete + + flash.notice = I18n.t('notice_messages.page_deleted') + respond_with(@static_page) do |format| + format.html { redirect_to collection_url } + format.js { render_js_for_destroy } + end + end + def published - sp = Spree::StaticPage.find(params[:id]) + sp = StaticPage.find(params[:id]) if sp.update_attribute(:published_at, Time.now) flash[:notice] = t("info_published_static_page") @@ -19,7 +34,7 @@ def published end def in_nav_menu - sp = Spree::StaticPage.find(params[:id]) + sp = StaticPage.find(params[:id]) if sp.update_attribute(:in_nav_menu, true) flash[:notice] = t("info_in_nav_menu_static_page") @@ -29,31 +44,25 @@ def in_nav_menu redirect_to spree.admin_static_pages_path end - def update_positions - params[:positions].each do |id, index| - Spree::StaticPage.where(:id => id).update_all(:position => index) - end - respond_to do |format| - format.js { render :text => 'Ok' } - end - end - - def collection - @search = super.ransack(params[:search]) - end - - def new - @static_page = @object - end - - def edit - @static_page = @object - end protected + def find_resource + StaticPage.find_by_permalink!(params[:id]) + end + def location_after_save - admin_static_pages_url + edit_admin_static_page_url(@static_page) + end + + def collection + return @collection if @collection.present? + params[:q] ||= {} + params[:q][:s] ||= "title asc" + + @search = super.ransack(params[:q]) + @collection = @search.result.page(params[:page]).per(Spree::Config[:admin_post_per_page]) end + end end end \ No newline at end of file diff --git a/app/controllers/spree/admin/store_settings_controller.rb b/app/controllers/spree/admin/store_settings_controller.rb index 915c53b..3f353b9 100644 --- a/app/controllers/spree/admin/store_settings_controller.rb +++ b/app/controllers/spree/admin/store_settings_controller.rb @@ -1,25 +1,21 @@ module Spree module Admin class StoreSettingsController < BaseController - def show - @preferences = ['store_name', 'store_default_email', 'store_address', - 'store_phone_number', 'store_fax_number', 'store_twitter_id', - 'store_facebook_id', 'store_skype', 'store_location', 'store_description', 'store_welcome_title', 'store_welcome_description'] - end - + def edit - @preferences = [:store_name, :store_default_email, :store_address, + @preferences = [:store_default_email, :store_address, :store_phone_number, :store_fax_number, :store_twitter_id, :store_facebook_id, :store_skype, :store_location, :store_description, :store_welcome_title, :store_welcome_description] end - + def update params.each do |name, value| next unless Spree::Config.has_preference? name Spree::Config[name] = value end + flash[:success] = t(:successfully_updated, :resource => t(:general_settings)) - redirect_to admin_store_settings_path + redirect_to edit_admin_store_settings_path end end diff --git a/app/controllers/spree/static_pages_controller.rb b/app/controllers/spree/static_pages_controller.rb index 777ef8b..bde44da 100644 --- a/app/controllers/spree/static_pages_controller.rb +++ b/app/controllers/spree/static_pages_controller.rb @@ -1,17 +1,21 @@ module Spree class StaticPagesController < BaseController - before_filter :load_obj + before_filter :load_page, :only => :show + rescue_from ActiveRecord::RecordNotFound, :with => :render_404 + helper 'spree/taxons' + + respond_to :html def contacts end def show - @page = Spree::StaticPage.find(params[:id]) + return unless @static_page end def create_mail unless (params[:name].blank? && params[:email].blank? && params[:messaggio].blank?) - Spree::ContactMailer.contacts_form(params[:name], params[:email], params[:messaggio]).deliver + Spree::ContactMailer.contact_form(params[:name], params[:email], params[:messaggio]).deliver flash[:notice] = t('create_mail_static_page') else flash[:notice] = t('not_create_mail_static_page')#'Si e` verificato un problema durante l\'invio della mail. Verifica di aver compilato tutti i campi' @@ -19,9 +23,13 @@ def create_mail redirect_to contacts_url end - def load_obj - @static_pages = Spree::StaticPage.published + private + def accurate_title + @static_page ? @static_page.title : super end + def load_page + @static_page = Spree::StaticPage.find_by_permalink!(params[:id]) + end end end diff --git a/app/mailers/spree/contact_mailer.rb b/app/mailers/spree/contact_mailer.rb index e80043a..665ed53 100644 --- a/app/mailers/spree/contact_mailer.rb +++ b/app/mailers/spree/contact_mailer.rb @@ -1,15 +1,12 @@ module Spree class ContactMailer < ActionMailer::Base helper 'spree/base' - - default :from => Spree::Config[:store_default_email] - def contacts_form(name, email, text) + def contact_form(name, email, text) @name = name @email = email @messaggio = text - mail(:to => "#{email} - #{name}", - :subject => Spree::Config[:store_default_contact_subject]) + mail(:to => Spree::Config[:store_default_email], :subject => "#{Spree::Config[:site_name]} - #{Spree::Config[:store_default_contact_subject]}") end end end diff --git a/app/models/comment.rb b/app/models/comment.rb deleted file mode 100644 index 1d8c0c0..0000000 --- a/app/models/comment.rb +++ /dev/null @@ -1,52 +0,0 @@ -module Spree - class Comment < ActiveRecord::Base - acts_as_nested_set :scope => [:commentable_id, :commentable_type] - - validates_presence_of :body - validates_presence_of :user - - # NOTE: install the acts_as_votable plugin if you - # want user to vote on the quality of comments. - #acts_as_voteable - - belongs_to :commentable, :polymorphic => true - - # NOTE: Comments belong to a user - belongs_to :user - - # Helper class method that allows you to build a comment - # by passing a commentable object, a user_id, and comment text - # example in readme - def self.build_from(obj, user_id, comment) - c = self.new - c.commentable_id = obj.id - c.commentable_type = obj.class.base_class.name - c.body = comment - c.user_id = user_id - c - end - - #helper method to check if a comment has children - def has_children? - self.children.size > 0 - end - - # Helper class method to lookup all comments assigned - # to all commentable types for a given user. - scope :find_comments_by_user, lambda { |user| - where(:user_id => user.id).order('created_at DESC') - } - - # Helper class method to look up all comments for - # commentable class name and commentable id. - scope :find_comments_for_commentable, lambda { |commentable_str, commentable_id| - where(:commentable_type => commentable_str.to_s, :commentable_id => commentable_id).order('created_at DESC') - } - - # Helper class method to look up a commentable object - # given the commentable class name and id - def self.find_commentable(commentable_str, commentable_id) - commentable_str.constantize.find(commentable_id) - end - end -end diff --git a/app/models/spree/app_configuration_decorator.rb b/app/models/spree/app_configuration_decorator.rb index f381869..aa8bc7e 100644 --- a/app/models/spree/app_configuration_decorator.rb +++ b/app/models/spree/app_configuration_decorator.rb @@ -1,8 +1,24 @@ +# This is the primary location for defining spree preferences +# +# The expectation is that this is created once and stored in +# the spree environment +# +# setters: +# a.color = :blue +# a[:color] = :blue +# a.set :color = :blue +# a.preferred_color = :blue +# +# getters: +# a.color +# a[:color] +# a.get :color +# a.preferred_color +# Spree::AppConfiguration.class_eval do - preference :store_name, :string, :default => 'Spree Demo' preference :store_default_email, :string, :default => 'spree@example.com' - preference :store_default_contact_subject, :string, :default => "[Spree Demo] Contact form subject" + preference :store_default_contact_subject, :string, :default => "Contact form subject" preference :store_address, :string, :default => 'Address, 123 - 123456 City (IT)' preference :store_phone_number, :string, :default => '012 - 3456789' preference :store_fax_number, :string, :default => '012 - 3456789' @@ -13,5 +29,7 @@ preference :store_description, :text, :default => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt, sem id vulputate auctor, dui lectus lacinia ipsum, placerat euismod felis tellus a nulla. Nunc fermentum tincidunt dui, ac iaculis quam elementum et. Mauris sit amet vehicula tortor. Maecenas euismod fringilla venenatis. In accumsan ultricies odio at venenatis. Duis aliquam euismod libero, nec eleifend massa fermentum iaculis. Donec imperdiet egestas ligula pretium aliquam.' preference :store_welcome_title, :string, :default => 'Welcome' preference :store_welcome_description, :text, :default => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt, sem id vulputate auctor, dui lectus lacinia ipsum, placerat euismod felis tellus a nulla. Nunc fermentum tincidunt dui, ac iaculis quam elementum et. Mauris sit amet vehicula tortor. Maecenas euismod fringilla venenatis. In accumsan ultricies odio at venenatis. Duis aliquam euismod libero, nec eleifend massa fermentum iaculis. Donec imperdiet egestas ligula pretium aliquam.' + preference :admin_post_per_page, :integer, :default => 10 preference :post_per_page, :integer, :default => 5 + end \ No newline at end of file diff --git a/app/models/spree/blog.rb b/app/models/spree/blog.rb index 0e0c974..515c89c 100644 --- a/app/models/spree/blog.rb +++ b/app/models/spree/blog.rb @@ -1,38 +1,31 @@ module Spree class Blog < ActiveRecord::Base + has_many :blog_images, :source => :images, :as => :viewable, :order => :position, :dependent => :destroy + has_many :uploads, :as => :uploadable + + attr_accessible :title, :permalink, :tag_title, :meta_description, :meta_keywords, :description, :content, :link, + :position, :in_nav_menu, :published_at # TAGGING AND COMMENT SYSTEM acts_as_taggable acts_as_taggable_on :tags - validates_presence_of :name, :content - validate :no_image_errors + make_permalink :order => :title - extend ::FriendlyId - friendly_id :name, :use => :slugged - - has_attached_file :image, :styles => { - :thumbnail => "100x100>", - :small => "200x200>", - :medium => "300x300>", - :big => "400x400#", - :custom => Proc.new { |instance| "#{instance.image_width}x#{instance.image_height}#" }} - + validates_presence_of :title, :content + + has_many :products, :through => :post_products + has_many :blog_images, :source => :images, :as => :viewable, :order => :position, :dependent => :destroy has_many :uploads, :as => :uploadable accepts_nested_attributes_for :uploads, :allow_destroy => true before_save :set_published_at, :if => Proc.new {|model| model.published_at.nil? } - - def set_published_at - self.published_at = Time.now - end - - #TODO: spostare in libreria - def no_image_errors - unless image.errors.empty? - errors.add :image, "Paperclip returned errors for file '#{image_file_name}' - check ImageMagick installation or image source file." - false - end + + def to_param + permalink.present? ? permalink : (permalink_was || title.to_s.to_url) end + def set_published_at + self.published_at = Time.now + end end end diff --git a/app/models/spree/page.rb b/app/models/spree/page.rb index 18cd28a..92a3e83 100644 --- a/app/models/spree/page.rb +++ b/app/models/spree/page.rb @@ -1,20 +1,23 @@ module Spree - class Page < ActiveRecord::Base - extend ::FriendlyId - friendly_id :name, :use => :slugged - + class Page < ActiveRecord::Base + has_and_belongs_to_many :products, :join_table => 'spree_pages_products' + has_and_belongs_to_many :taxons, :join_table => 'spree_pages_taxons' has_many :images, :as => :viewable, :order => :position, :dependent => :destroy + has_many :uploads, :as => :uploadable + + attr_accessible :title, :permalink, :tag_title, :meta_description, :meta_keywords, :body, :link, + :position, :in_nav_menu, :published_at + + accepts_nested_attributes_for :uploads, :allow_destroy => true - def should_generate_new_friendly_id? - new_record? + make_permalink :order => :title + + def to_param + permalink.present? ? permalink : (permalink_was || title.to_s.to_url) end - - def link_is_blank + + def link_is_blank? self.link.blank? end - - def content_is_blank - self.content.blank? - end end end diff --git a/app/models/spree/post.rb b/app/models/spree/post.rb index 30bacd2..736c1f5 100644 --- a/app/models/spree/post.rb +++ b/app/models/spree/post.rb @@ -1,7 +1,12 @@ module Spree class Post < Blog - #acts_as_commentable - belongs_to :post_category + has_and_belongs_to_many :products, :join_table => 'spree_posts_products' + has_and_belongs_to_many :taxons, :join_table => 'spree_posts_taxons' + acts_as_commentable + + has_and_belongs_to_many :post_categories, :join_table => "spree_post_categories_posts", :class_name => "Spree::PostCategory" + alias_attribute :categories, :post_categories + attr_accessible :name, :content, :published_at, :active, :tag_list scope :published, lambda { where("published_at <= '#{Time.now}' AND active = 1") } scope :valid, lambda { where("from <= #{Time.now} AND to >= #{Time.now}") } diff --git a/app/models/spree/post_category.rb b/app/models/spree/post_category.rb index 788c7c9..294931e 100644 --- a/app/models/spree/post_category.rb +++ b/app/models/spree/post_category.rb @@ -1,10 +1,15 @@ module Spree class PostCategory < ActiveRecord::Base - extend ::FriendlyId - friendly_id :name, :use => :slugged - has_many :posts + attr_accessible :title, :permalink, :tag_title, :meta_description, :meta_keywords, :presentation, + :position, :published_at + + make_permalink :order => :title + has_and_belongs_to_many :posts, :join_table => 'spree_post_categories_posts', :uniq => true scope :published, lambda { where(:published_at => "published_at <= #{Time.now}", :active => true) } + def to_param + permalink.present? ? permalink : (permalink_was || title.to_s.to_url) + end end end \ No newline at end of file diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index 8799af2..9733bad 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -1,4 +1,4 @@ Spree::Product.class_eval do - has_many :static_pages - + has_and_belongs_to_many :static_pages, :join_table => 'spree_pages_products' + has_and_belongs_to_many :posts, :join_table => 'spree_posts_products' end \ No newline at end of file diff --git a/app/models/spree/static_page.rb b/app/models/spree/static_page.rb index ee66d6c..6a192b7 100644 --- a/app/models/spree/static_page.rb +++ b/app/models/spree/static_page.rb @@ -1,16 +1,7 @@ module Spree - class StaticPage < Page - belongs_to :product - - attr_accessible :name, :slug, :tag_title, :meta_description, :meta_keywords, :content, :published_at + class StaticPage < Page scope :published, lambda { where("published_at <= ? AND published_at IS NOT NULL", Time.now) } - def initialize(*args) - super(*args) - last_static_page = StaticPage.last - self.position = last_static_page ? last_static_page.position + 1 : 0 - end - def published? !self.published_at.blank? end diff --git a/app/models/spree/taxon_decorator.rb b/app/models/spree/taxon_decorator.rb index 14ce000..335c9be 100644 --- a/app/models/spree/taxon_decorator.rb +++ b/app/models/spree/taxon_decorator.rb @@ -1,8 +1,14 @@ Spree::Taxon.class_eval do has_and_belongs_to_many :pages, :join_table => 'spree_pages_taxons' + has_and_belongs_to_many :posts, :join_table => 'spree_posts_taxons' - def active_products + def active_pages scope = pages.published scope end + + def active_posts + scope = posts.published + scope + end end \ No newline at end of file diff --git a/app/overrides/simple_cms_admin_tabs.rb b/app/overrides/simple_cms_admin_tabs.rb index 7588094..64cd89d 100644 --- a/app/overrides/simple_cms_admin_tabs.rb +++ b/app/overrides/simple_cms_admin_tabs.rb @@ -1,12 +1,10 @@ Deface::Override.new(:virtual_path => "spree/layouts/admin", :name => "pages_tab", :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]", - :text => "<%= tab(t('simple_cms.pages'), :url => spree.admin_static_pages_path) %>", - :disabled => false) + :text => "<%= tab(t('simple_cms.pages'), :url => spree.admin_static_pages_path) %>") Deface::Override.new(:virtual_path => "spree/layouts/admin", :name => "posts_tab", :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]", - :text => "<%= tab(:posts, :url => spree.admin_posts_path) %>", - :disabled => false) + :text => "<%= tab(:posts, :url => spree.admin_posts_path) %>") diff --git a/app/overrides/store_setting_admin_configuration_menu.rb b/app/overrides/store_setting_admin_configuration_menu.rb index 557e2c7..a08bbb8 100644 --- a/app/overrides/store_setting_admin_configuration_menu.rb +++ b/app/overrides/store_setting_admin_configuration_menu.rb @@ -1,11 +1,9 @@ Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu", :name => "add_store_setting_link_configuration_menu", :insert_bottom => "[data-hook='admin_configurations_sidebar_menu']", - :text => %q{<%= configurations_sidebar_menu_item t("simple_cms.store_settings"), admin_store_settings_url %>}, - :disabled => false) + :text => %q{<%= configurations_sidebar_menu_item t("simple_cms.store_settings"), admin_store_settings_url %>}) Deface::Override.new(:virtual_path => "spree/admin/configurations/index", :name => "add_store_setting_to_configuration_menu", :insert_after => "[data-hook='admin_configurations_menu']", - :partial => "spree/admin/shared/store_setting_configurations_menu", - :disabled => false) \ No newline at end of file + :partial => "spree/admin/shared/store_setting_configurations_menu") \ No newline at end of file diff --git a/app/views/spree/admin/posts/_form.html.erb b/app/views/spree/admin/posts/_form.html.erb index 8ad7823..d532422 100644 --- a/app/views/spree/admin/posts/_form.html.erb +++ b/app/views/spree/admin/posts/_form.html.erb @@ -11,4 +11,10 @@

<%= t(:insert_tag_instruction) %>

<%= f.input :tag_list, :label => t(:tag_list) %> <% end %> - \ No newline at end of file + + +<%= form.field_container :tag_list do %> + <%= form.label :tag_list, t("activerecord.attributes.post.tags") %>
+ <%= form.text_field :tag_list, :class => 'text' %>
+ <%= error_message_on :post, :tag_list %> +<% end %> diff --git a/app/views/spree/admin/shared/_store_setting_configurations_menu.html.erb b/app/views/spree/admin/shared/_store_setting_configurations_menu.html.erb index f9c76a4..c52a11c 100644 --- a/app/views/spree/admin/shared/_store_setting_configurations_menu.html.erb +++ b/app/views/spree/admin/shared/_store_setting_configurations_menu.html.erb @@ -1,4 +1,4 @@ - <%= link_to t("simple_cms.store_settings"), admin_store_settings_url %> - <%= t("simple_cms.manage_store_settings") %> + <%= link_to t(:store_settings), admin_store_settings_url %> + <%= t(:store_settings_description) %> \ No newline at end of file diff --git a/app/views/spree/admin/static_pages/_form.html.erb b/app/views/spree/admin/static_pages/_form.html.erb index 224562d..cb45fbd 100644 --- a/app/views/spree/admin/static_pages/_form.html.erb +++ b/app/views/spree/admin/static_pages/_form.html.erb @@ -1,4 +1,5 @@
+<<<<<<< HEAD
<%= f.field_container :name do %> <%= f.label :name, t("simple_cms.page.name") %> * @@ -38,4 +39,48 @@
-
\ No newline at end of file +
+======= +
+
+ <%= f.field_container :name do %> + <%= f.label :name, t(:name) %> *
+ <%= f.text_field :name, :class => 'fullwidth title' %> + %= f.error_message_on :name %> + <% end %> + + <%= f.field_container :body do %> + <%= f.label :body, t(:body) %>
+ <%= f.text_area :body, {:cols => 60, :rows => 4, :class => 'fullwidth'} %> + <%= f.error_message_on :body %> + <% end %> +
+
+ <%= f.field_container :permalink do %> + <%= f.label :permalink, t(:permalink) %> *
+ <%= f.text_field :permalink, :class => 'fullwidth title' %> + <%= f.error_message_on :permalink %> + <% end %> + + <%= f.field_container :published_at do %> + <%= f.label :published_at, t(:published_at) %>
+ <%= f.error_message_on :published_at %> + <%= f.text_field :published_at, :class => 'datepicker' %> + <% end %> +
+
+ +

<%= t(:metadata) %>

+
+ <%= f.field_container :meta_keywords do %> + <%= f.label :meta_keywords, t(:meta_keywords) %>
+ <%= f.text_field :meta_keywords, :class => 'fullwidth' %> + <% end %> + + <%= f.field_container :meta_description do %> + <%= f.label :meta_description, t(:meta_description) %>
+ <%= f.text_field :meta_description, :class => 'fullwidth' %> + <% end %> +
+ +>>>>>>> 1-1-stable diff --git a/app/views/spree/admin/static_pages/edit.html.erb b/app/views/spree/admin/static_pages/edit.html.erb index ff2aafa..d71f2a3 100644 --- a/app/views/spree/admin/static_pages/edit.html.erb +++ b/app/views/spree/admin/static_pages/edit.html.erb @@ -11,4 +11,4 @@ <%= render :partial => 'spree/admin/shared/edit_resource_links' %> <% end %> - \ No newline at end of file + diff --git a/app/views/spree/admin/static_pages/index.html.erb b/app/views/spree/admin/static_pages/index.html.erb index 7ab7593..bb56cc6 100644 --- a/app/views/spree/admin/static_pages/index.html.erb +++ b/app/views/spree/admin/static_pages/index.html.erb @@ -1,12 +1,12 @@ <% content_for :page_title do %> - <%= t("simple_cms.page.listing_pages") %> + <%= t(:listing_pages) %> <% end %> <% content_for :page_actions do %>

@@ -15,27 +15,27 @@
- +
- + - + - <% @static_pages.each do |sp|%> - + <% @collection.each do |sp|%> + - - - - + + +
<%= sort_link @search,:name, t(:page), {}, {:title => t("simple_cms.page.name")} %><%= sort_link @search,:title, t(:page), {}, {:title => t(:title)} %> <%= t(:position) %> <%= t(:in_nav_menu) %> <%= t(:published_at) %><%= t(:action) %>
<%= sp.name %> <%= sp.position %><%= sp.in_nav_menu %><%= l(sp.published_at, :format => :short) rescue "" %> + <%= sp.position %><%= sp.in_nav_menu %><%= l(sp.published_at, :format => :short) rescue "" %> <%= link_to_edit sp, :class => 'edit' %>   <%= link_to_delete sp %> <% unless sp.published? %> diff --git a/app/views/spree/admin/static_pages/new.html.erb b/app/views/spree/admin/static_pages/new.html.erb index 445f4c8..01fde8e 100644 --- a/app/views/spree/admin/static_pages/new.html.erb +++ b/app/views/spree/admin/static_pages/new.html.erb @@ -1,7 +1,5 @@ -
- <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @static_page } %> -

<%= t("simple_cms.page.new_page") %>

-
+

<%= t(:new_page) %>

+<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @static_page } %>
<%= form_for([:admin, @static_page], :html => { :multipart => true }) do |f| %> @@ -11,4 +9,4 @@ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
<% end %> - \ No newline at end of file + diff --git a/app/views/spree/contact_mailer/contact_form.html.erb b/app/views/spree/contact_mailer/contact_form.html.erb index e69de29..fec2f71 100644 --- a/app/views/spree/contact_mailer/contact_form.html.erb +++ b/app/views/spree/contact_mailer/contact_form.html.erb @@ -0,0 +1,6 @@ +

Richiesta contatto

+
+

Nome: <%= @name %>

+

Email: <%= @email %>

+
+

Messaggio:
<%= @messaggio %>

\ No newline at end of file diff --git a/app/views/spree/contact_mailer/contact_form.text.erb b/app/views/spree/contact_mailer/contact_form.text.erb index e69de29..0ff2a00 100644 --- a/app/views/spree/contact_mailer/contact_form.text.erb +++ b/app/views/spree/contact_mailer/contact_form.text.erb @@ -0,0 +1,8 @@ +Richiesta contatto + +Nome: <%= @name %> +Email: <%= @email %> + +Messaggio: +<%= @messaggio %> + diff --git a/config/routes.rb b/config/routes.rb index e032bce..ab7e8e1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,8 +2,27 @@ namespace :admin do resource :store_settings - resources :posts + resources :posts do + resources :images do + collection do + post :update_positions + end + end + collection do + post :update_positions + end + member do + get :published + get :in_nav_menu + end + end + resources :static_pages do + resources :images do + collection do + post :update_positions + end + end collection do post :update_positions end @@ -14,16 +33,11 @@ end end - resources :articles - match '/contacts', :to => 'static_pages#contacts', :as => :contacts match '/contacts/send', :to => "static_pages#create_mail", :via => :post match '/pages/*id', :to => 'static_pages#show', :as => :page match '/pages', :to => 'static_pages#index', :as => :pages - - #match '/post/*id', :to => 'posts#show', :as => :post - #match '/blog', :to => 'posts#index', :as => :posts - match '/news', :to => 'posts#index', :as => :posts + match '/blog', :to => 'posts#index', :as => :blog match '/news/*id', :to => 'posts#show', :as => :post - + end diff --git a/db/migrate/20120316075003_create_uploads.rb b/db/migrate/20120316075003_create_uploads.rb new file mode 100644 index 0000000..f99dccc --- /dev/null +++ b/db/migrate/20120316075003_create_uploads.rb @@ -0,0 +1,19 @@ +class CreateUploads < ActiveRecord::Migration + def change + create_table :spree_uploads do |t| + + t.string :attachment_name + t.string :attachment_alt + + t.string :attachment_content_type, :attachment_file_name + t.integer :attachment_size + t.integer :attachment_width, :attachment_height + + t.integer :position + + t.references :uploadable, :polymorphic => true + + t.timestamps + end + end +end diff --git a/db/migrate/20120316081104_create_blogs.rb b/db/migrate/20120316081104_create_blogs.rb index fe34565..02479c8 100644 --- a/db/migrate/20120316081104_create_blogs.rb +++ b/db/migrate/20120316081104_create_blogs.rb @@ -26,4 +26,4 @@ def change end add_index :spree_blogs, :slug, :unique => true end -end +end \ No newline at end of file diff --git a/db/migrate/20130301082910_refactor_tables.rb b/db/migrate/20130301082910_refactor_tables.rb new file mode 100644 index 0000000..a4664d6 --- /dev/null +++ b/db/migrate/20130301082910_refactor_tables.rb @@ -0,0 +1,39 @@ +class RefactorTables < ActiveRecord::Migration + def change + # Remove slug, added permalink and rename name => title + remove_index :spree_pages, :slug + rename_column :spree_pages, :slug, :permalink + rename_column :spree_pages, :name, :title + add_index :spree_pages, :permalink, :unique => true + remove_index :spree_blogs, :slug + rename_column :spree_blogs, :slug, :permalink + rename_column :spree_blogs, :name, :title + add_index :spree_blogs, :permalink, :unique => true + + # Remove all image attachment for model + remove_column :spree_pages, :image_file_name + remove_column :spree_pages, :image_content_type + remove_column :spree_pages, :image_file_size + remove_column :spree_pages, :image_update_at + remove_column :spree_pages, :image_width + remove_column :spree_pages, :image_height + remove_column :spree_blogs, :image_file_name + remove_column :spree_blogs, :image_content_type + remove_column :spree_blogs, :image_file_size + remove_column :spree_blogs, :image_update_at + remove_column :spree_blogs, :image_width + remove_column :spree_blogs, :image_height + + remove_column :spree_pages, :description + rename_column :spree_pages, :content, :body + remove_column :spree_blogs, :description + rename_column :spree_blogs, :content, :body + + # Remove slug, added permalink and rename name => title for category + remove_index :spree_post_category, :slug + rename_column :spree_post_category, :slug, :permalink + rename_column :spree_post_category, :name, :title + add_index :spree_post_category, :permalink, :unique => true + rename_column :spree_post_category, :description, :presentation + end +end diff --git a/db/migrate/20130303171443_add_join_tables.rb b/db/migrate/20130303171443_add_join_tables.rb new file mode 100644 index 0000000..5ae5869 --- /dev/null +++ b/db/migrate/20130303171443_add_join_tables.rb @@ -0,0 +1,35 @@ +class AddJoinTables < ActiveRecord::Migration + def change + create_table :spree_pages_products, :id => false do |t| + t.references :page + t.references :product + end + + add_index :spree_pages_products, [:product_id], :name => 'index_spree_pages_products_on_page_id' + add_index :spree_pages_products, [:taxon_id], :name => 'index_spree_pages_products_on_product_id' + + create_table :spree_posts_products, :id => false do |t| + t.references :post + t.references :product + end + + add_index :spree_posts_products, [:product_id], :name => 'index_spree_posts_products_on_post_id' + add_index :spree_posts_products, [:taxon_id], :name => 'index_spree_posts_products_on_product_id' + + create_table :spree_pages_taxons, :id => false do |t| + t.references :page + t.references :taxon + end + + add_index :spree_pages_taxons, [:product_id], :name => 'index_spree_pages_taxons_on_page_id' + add_index :spree_pages_taxons, [:taxon_id], :name => 'index_spree_pages_taxons_on_taxon_id' + + create_table :spree_posts_taxons, :id => false do |t| + t.references :post + t.references :taxon + end + + add_index :spree_posts_taxons, [:product_id], :name => 'index_spree_posts_taxons_on_post_id' + add_index :spree_posts_taxons, [:taxon_id], :name => 'index_spree_posts_taxons_on_taxon_id' + end +end diff --git a/lib/generators/spree_simple_cms/install/install_generator.rb b/lib/generators/spree_simple_cms/install/install_generator.rb index 22454f8..7154e73 100644 --- a/lib/generators/spree_simple_cms/install/install_generator.rb +++ b/lib/generators/spree_simple_cms/install/install_generator.rb @@ -4,11 +4,7 @@ class InstallGenerator < Rails::Generators::Base def add_javascripts append_file "app/assets/javascripts/store/all.js", "//= require store/spree_simple_cms\n" - append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_simple_cms\n" - end - - def add_stylesheets - inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_simple_cms\n", :before => /\*\//, :verbose => true + #append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_simple_cms\n" end def add_migrations diff --git a/lib/spree_simple_cms.rb b/lib/spree_simple_cms.rb index 0c11a85..90fbda0 100644 --- a/lib/spree_simple_cms.rb +++ b/lib/spree_simple_cms.rb @@ -1,2 +1,4 @@ require 'spree_core' +require 'acts-as-taggable-on' +require 'acts_as_commentable_with_threading' require 'spree_simple_cms/engine' diff --git a/spree_simple_cms.gemspec b/spree_simple_cms.gemspec index 2cac1c6..8bc370e 100644 --- a/spree_simple_cms.gemspec +++ b/spree_simple_cms.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = 'spree_simple_cms' - s.version = '1.2.0' + s.version = '1.3.0' s.summary = 'Extension to create a simple CMS and Blog for you Spree Shop' s.required_ruby_version = '>= 1.8.7' @@ -15,13 +15,9 @@ Gem::Specification.new do |s| s.files = Dir['CHANGELOG', 'README.md', 'LICENSE', 'lib/**/*', 'app/**/*', 'db/**/*', 'config/**/*'] s.require_path = 'lib' s.requirements << 'none' - - s.add_dependency 'spree_core' - s.add_dependency 'friendly_id' + s.add_dependency 'spree_core', '>= 1.3.0' s.add_dependency 'paperclip' s.add_dependency 'acts-as-taggable-on' s.add_dependency 'acts_as_commentable_with_threading' - - s.add_development_dependency 'rspec-rails' end