Skip to content

Commit

Permalink
2.2-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ximik committed Jul 7, 2014
1 parent 23eee74 commit 0012b1e
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
SpreeNews
=========

This is an extension for Spree 1.0 that allows an Admin to create and manage posts in the admin panel. Posts that are marked as published will show up on the home page in a news ticker window that uses jquery to slide between posts. If there are no published posts, the news ticker window will not show up on the home page.
This is an extension for Spree 2.2 that allows an Admin to create and manage posts in the admin panel. Posts that are marked as published will show up on the home page in a news ticker window that uses jquery to slide between posts. If there are no published posts, the news ticker window will not show up on the home page.


Installation
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/admin/spree_news.js

This file was deleted.

1 change: 1 addition & 0 deletions app/assets/javascripts/backend/spree_news.js
@@ -0,0 +1 @@
//= require spree/backend
@@ -1,2 +1,2 @@
//= require store/spree_frontend
//= require spree/frontend
//= require jquery.vticker-min.js
@@ -1,5 +1,5 @@
/*
*= require admin/spree_backend
*= require spree/backend
*/

.new-post {
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/frontend/spree_news.css
@@ -0,0 +1,4 @@
/*
*= require spree/frontend
*= require posts
*/
4 changes: 0 additions & 4 deletions app/assets/stylesheets/store/spree_news.css

This file was deleted.

10 changes: 8 additions & 2 deletions app/controllers/spree/admin/posts_controller.rb
Expand Up @@ -13,7 +13,7 @@ def new
end

def create
@post = Spree::Post.new(params[:post])
@post = Spree::Post.new(post_params)
if @post.save
flash[:notice] = "Post saved successfully"
redirect_to admin_posts_path
Expand All @@ -29,7 +29,7 @@ def edit

def update
@post = Spree::Post.find(params[:id])
if @post.update_attributes(params[:post])
if @post.update_attributes(post_params)
flash[:notice] = "Post saved successfully"
redirect_to admin_posts_path
else
Expand All @@ -47,4 +47,10 @@ def destroy
end
end

private

def post_params
params.require(:post).permit(:title, :description, :published)
end

end
3 changes: 0 additions & 3 deletions app/models/spree/post.rb
@@ -1,8 +1,5 @@
class Spree::Post < ActiveRecord::Base
validates_presence_of :title, :description
# validates_length_of :description, :maximum => 150

attr_accessible :title, :description, :published

scope :published, lambda { where(:published => true) }
scope :latest, order("created_at DESC").limit(3)
Expand Down
4 changes: 2 additions & 2 deletions app/overrides/spree_news_overrides.rb
@@ -1,7 +1,7 @@
Deface::Override.new(:virtual_path => "spree/layouts/admin",
Deface::Override.new(:virtual_path => "spree/admin/shared/_menu",
:name => "news_admin_tab",
:insert_bottom => "[data-hook='admin_tabs']",
:text => "<%= tab(:posts) %>",
:text => "<%= tab(:posts, :icon => 'icon-file-text') %>",
:disabled => false)

Deface::Override.new(:virtual_path => "spree/home/index",
Expand Down
8 changes: 4 additions & 4 deletions lib/generators/spree_news/install/install_generator.rb
Expand Up @@ -3,13 +3,13 @@ module Generators
class InstallGenerator < Rails::Generators::Base

def add_javascripts
append_file "app/assets/javascripts/store/all.js", "#= require store/spree_news\n"
append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_news\n"
append_file "vendor/assets/javascripts/spree/frontend/all.js", "//= require frontend/spree_news\n"
append_file "vendor/assets/javascripts/spree/backend/all.js", "//= require backend/spree_news\n"
end

def add_stylesheets
inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_news\n", :before => /\*\//, :verbose => true
inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_news\n", :before => /\*\//, :verbose => true
inject_into_file "vendor/assets/stylesheets/spree/frontend/all.css", " *= require frontend/spree_news\n", :before => /\*\//, :verbose => true
inject_into_file "vendor/assets/stylesheets/spree/backend/all.css", " *= require backend/spree_news\n", :before => /\*\//, :verbose => true
end

def add_migrations
Expand Down
4 changes: 2 additions & 2 deletions spree_news.gemspec
Expand Up @@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_news'
s.version = '0.0.5'
s.version = '0.0.6'
s.summary = 'Adds a Javascript enabled scrolling news feed ticker wherever you call it'
s.description = 'Provides an Admin view to create/edit posts which will be shown on the home page in a scrolling news ticker window below the products listing.'
s.required_ruby_version = '>= 1.9.2'
Expand All @@ -16,7 +16,7 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

s.add_dependency 'spree_backend', '~> 2.0.0'
s.add_dependency 'spree_backend', '~> 2.2.0'
s.add_dependency 'haml'

end

0 comments on commit 0012b1e

Please sign in to comment.