ems 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/controllers/ems/application_controller.rb +2 -2
- data/app/controllers/ems/articles_controller.rb +14 -14
- data/app/controllers/ems/categories_controller.rb +1 -1
- data/app/controllers/ems/channels_controller.rb +2 -2
- data/app/controllers/ems/ems_controller.rb +3 -3
- data/app/controllers/ems/images_controller.rb +1 -1
- data/app/controllers/ems/news_controller.rb +2 -2
- data/app/controllers/ems/reports_controller.rb +1 -1
- data/app/controllers/ems/tags_controller.rb +2 -2
- data/app/models/ems/ability.rb +1 -1
- data/app/models/ems/article.rb +13 -10
- data/app/models/ems/category.rb +3 -0
- data/app/models/ems/channel.rb +5 -2
- data/app/models/ems/role.rb +1 -0
- data/app/models/ems/tag.rb +5 -2
- data/app/views/layouts/ems/application.html.haml +1 -2
- data/lib/ems/version.rb +1 -1
- metadata +5 -5
@@ -4,12 +4,12 @@ module Ems
|
|
4
4
|
before_filter :authenticate_user!
|
5
5
|
# Also make sure we either have to check cancan or skipit, emtpy is too risky
|
6
6
|
check_authorization
|
7
|
-
|
7
|
+
|
8
8
|
# # Global cancan failure recovery
|
9
9
|
# rescue_from CanCan::AccessDenied do |exception|
|
10
10
|
# redirect_to main_app.new_user_session_path, :alert => exception.message
|
11
11
|
# end
|
12
|
-
|
12
|
+
|
13
13
|
# We need to make sure that we are using the ems abilities in the EMS
|
14
14
|
def current_ability
|
15
15
|
@current_ability ||= Ability.new(current_user)
|
@@ -1,53 +1,53 @@
|
|
1
1
|
module Ems
|
2
2
|
class ArticlesController < ApplicationController
|
3
|
-
load_and_authorize_resource
|
4
|
-
|
3
|
+
load_and_authorize_resource :class => Ems::Article
|
4
|
+
|
5
5
|
# GET /articles
|
6
6
|
# GET /articles.json
|
7
7
|
def index
|
8
8
|
@articles = Article.all
|
9
|
-
|
9
|
+
|
10
10
|
respond_to do |format|
|
11
11
|
format.html # index.html.erb
|
12
12
|
format.json { render json: @articles }
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# GET /articles/1
|
17
17
|
# GET /articles/1.json
|
18
18
|
def show
|
19
19
|
@article = Article.find(params[:id])
|
20
|
-
|
20
|
+
|
21
21
|
respond_to do |format|
|
22
22
|
format.html # show.html.erb
|
23
23
|
format.json { render json: @article }
|
24
24
|
end
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# GET /articles/new
|
28
28
|
# GET /articles/new.json
|
29
29
|
def new
|
30
30
|
@article = Article.new(:category => Category.find(params[:category_id]))
|
31
31
|
@article.assets.build
|
32
32
|
@article.category = Category.find params[:category_id]
|
33
|
-
|
33
|
+
|
34
34
|
respond_to do |format|
|
35
35
|
format.html # new.html.erb
|
36
36
|
format.json { render json: @article }
|
37
37
|
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
# GET /articles/1/edit
|
41
41
|
def edit
|
42
42
|
@article = Article.find(params[:id])
|
43
43
|
@article.assets.build
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
# POST /articles
|
47
47
|
# POST /articles.json
|
48
48
|
def create
|
49
49
|
@article = Article.new(params[:article])
|
50
|
-
|
50
|
+
|
51
51
|
respond_to do |format|
|
52
52
|
if @article.save
|
53
53
|
format.html { redirect_to edit_category_article_path(@article.category, @article), notice: 'Article was successfully created.' }
|
@@ -58,12 +58,12 @@ module Ems
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
# PUT /articles/1
|
63
63
|
# PUT /articles/1.json
|
64
64
|
def update
|
65
65
|
@article = Article.find(params[:id])
|
66
|
-
|
66
|
+
|
67
67
|
respond_to do |format|
|
68
68
|
if @article.update_attributes(params[:article])
|
69
69
|
format.html { redirect_to edit_category_article_path(@article.category, @article), notice: 'Article was successfully updated.' }
|
@@ -74,14 +74,14 @@ module Ems
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
# DELETE /articles/1
|
79
79
|
# DELETE /articles/1.json
|
80
80
|
def destroy
|
81
81
|
@article = Article.find(params[:id])
|
82
82
|
category = @article.category
|
83
83
|
@article.destroy
|
84
|
-
|
84
|
+
|
85
85
|
respond_to do |format|
|
86
86
|
format.html { redirect_to category_articles_path(category), notice: 'Article was successfully deleted.' }
|
87
87
|
format.json { head :no_content }
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Ems
|
2
2
|
class ChannelsController < ApplicationController
|
3
|
-
load_and_authorize_resource
|
3
|
+
load_and_authorize_resource :class => Ems::Channel
|
4
4
|
# GET /channels
|
5
5
|
# GET /channels.json
|
6
6
|
def index
|
7
7
|
@channels = Channel.all
|
8
|
-
|
8
|
+
|
9
9
|
respond_to do |format|
|
10
10
|
format.html # index.html.erb
|
11
11
|
format.json { render json: @channels }
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Ems
|
2
2
|
class EmsController < ApplicationController
|
3
3
|
skip_authorization_check :only => [:index]
|
4
|
-
|
4
|
+
|
5
5
|
def index
|
6
6
|
# Workaround for active admin routing problem.
|
7
7
|
# see:
|
8
8
|
# http://stackoverflow.com/questions/10684566/mountable-engine-routing-with-active-admin-on-rails
|
9
|
-
#
|
9
|
+
# TODO find a nicer solution for this problem.
|
10
10
|
render :layout => 'ems/application'
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
end
|
14
14
|
end
|
data/app/models/ems/ability.rb
CHANGED
data/app/models/ems/article.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module Ems
|
2
2
|
|
3
3
|
class Article < ActiveRecord::Base
|
4
|
+
|
5
|
+
attr_accessible :category_id, :channel_ids, :tag_ids, :title, :publish_from,
|
6
|
+
:status, :image, :standfirst, :content, :assets, :article_ids, :report_ids,
|
7
|
+
:news_ids, :hot, :featured
|
8
|
+
|
4
9
|
# use friendly_id to handle our slugs
|
5
10
|
extend FriendlyId
|
6
11
|
friendly_id :title, use: :slugged
|
@@ -13,17 +18,16 @@ module Ems
|
|
13
18
|
validates :channels, :presence => true, :if => :is_live?
|
14
19
|
validates :publish_from, :presence => true, :if => :is_live?
|
15
20
|
validates :status, :presence => true
|
16
|
-
|
21
|
+
|
17
22
|
validates :image, :attachment_presence => true, :if => :is_live?
|
18
23
|
validates :title, :presence => true, :if => :is_live?
|
19
24
|
validates :standfirst, :presence => true, :if => :is_live?
|
20
25
|
validates :content, :presence => true, :if => :is_live?
|
21
|
-
|
26
|
+
|
22
27
|
validates_uniqueness_of :slug
|
23
28
|
validates_inclusion_of :content_disposition, :in => [ :html, :markdown ], :message => "Value is not a valid content disposition"
|
24
29
|
validates_inclusion_of :status, :in => [ :draft, :pending, :live ], :message => "Value is not a valid status"
|
25
|
-
|
26
|
-
|
30
|
+
|
27
31
|
# searchable do
|
28
32
|
# text :title, :stored => true
|
29
33
|
# text :standfirst, :stored => true
|
@@ -35,7 +39,6 @@ module Ems
|
|
35
39
|
|
36
40
|
# after methods
|
37
41
|
after_initialize :init
|
38
|
-
|
39
42
|
|
40
43
|
# relations
|
41
44
|
belongs_to :category
|
@@ -52,7 +55,7 @@ module Ems
|
|
52
55
|
accepts_nested_attributes_for :reports
|
53
56
|
has_many :assets, :as => :assetable
|
54
57
|
accepts_nested_attributes_for :assets, :allow_destroy => true
|
55
|
-
|
58
|
+
|
56
59
|
# paperclip files
|
57
60
|
has_attached_file :image, :styles => { :image564x252 => "564x252#", :image312x189 => "312x189#", :image312x126 => "312x126", :image228x126 => "228x126"}
|
58
61
|
|
@@ -87,7 +90,7 @@ module Ems
|
|
87
90
|
def content_disposition= (value)
|
88
91
|
write_attribute(:content_disposition, value.to_s)
|
89
92
|
end
|
90
|
-
|
93
|
+
|
91
94
|
def content_as_html
|
92
95
|
Kramdown::Document.new(content, :input => "BeanKramdown").to_html
|
93
96
|
end
|
@@ -97,15 +100,15 @@ module Ems
|
|
97
100
|
def as_json(options={})
|
98
101
|
super( options.merge( :include => [ :category, :channels, :tags, :images ] ) )
|
99
102
|
end
|
100
|
-
|
103
|
+
|
101
104
|
#
|
102
105
|
def is_live?
|
103
106
|
self.status === :live
|
104
107
|
end
|
105
|
-
|
108
|
+
|
106
109
|
# base queries
|
107
110
|
class << self
|
108
|
-
|
111
|
+
|
109
112
|
def base_query(category=nil)
|
110
113
|
q = self.joins(:category).where("publish_from <= :publish_from", {:publish_from => Time.now.strftime("%Y/%m/%d %H:00:00")}).where(:status => 'live')
|
111
114
|
q = q.where('ems_categories.id' => category.id) if category
|
data/app/models/ems/category.rb
CHANGED
data/app/models/ems/channel.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Ems
|
2
2
|
class Channel < ActiveRecord::Base
|
3
|
+
|
4
|
+
attr_accessible :name, :category_ids, :articles, :news, :reports
|
5
|
+
|
3
6
|
extend FriendlyId
|
4
7
|
friendly_id :name, use: :slugged
|
5
8
|
def should_generate_new_friendly_id?
|
6
9
|
new_record?
|
7
10
|
end
|
8
|
-
|
11
|
+
|
9
12
|
# Validators
|
10
13
|
validates_uniqueness_of :slug
|
11
14
|
validates :slug, :presence => true
|
@@ -13,7 +16,7 @@ module Ems
|
|
13
16
|
|
14
17
|
has_and_belongs_to_many :categories, :join_table => 'ems_categories_channels'
|
15
18
|
accepts_nested_attributes_for :categories
|
16
|
-
|
19
|
+
|
17
20
|
has_and_belongs_to_many :articles, :join_table => 'ems_articles_channels'
|
18
21
|
accepts_nested_attributes_for :articles
|
19
22
|
has_and_belongs_to_many :news, :join_table => 'ems_channels_news'
|
data/app/models/ems/role.rb
CHANGED
data/app/models/ems/tag.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
module Ems
|
2
2
|
class Tag < ActiveRecord::Base
|
3
|
+
|
4
|
+
attr_accessible :title, :description
|
5
|
+
|
3
6
|
extend FriendlyId
|
4
7
|
friendly_id :title, use: :slugged
|
5
8
|
def should_generate_new_friendly_id?
|
6
9
|
new_record?
|
7
10
|
end
|
8
|
-
|
11
|
+
|
9
12
|
has_and_belongs_to_many :articles, :join_table => 'ems_articles_tags'
|
10
13
|
accepts_nested_attributes_for :articles
|
11
14
|
|
@@ -13,7 +16,7 @@ module Ems
|
|
13
16
|
validates_uniqueness_of :slug
|
14
17
|
validates :slug, :presence => true
|
15
18
|
validates :title, :presence => true
|
16
|
-
|
19
|
+
|
17
20
|
#
|
18
21
|
# @param options
|
19
22
|
def as_json(options={})
|
data/lib/ems/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ems
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
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-
|
12
|
+
date: 2012-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -552,7 +552,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
552
552
|
version: '0'
|
553
553
|
segments:
|
554
554
|
- 0
|
555
|
-
hash:
|
555
|
+
hash: 1341355416954403944
|
556
556
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
557
557
|
none: false
|
558
558
|
requirements:
|
@@ -561,10 +561,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
561
561
|
version: '0'
|
562
562
|
segments:
|
563
563
|
- 0
|
564
|
-
hash:
|
564
|
+
hash: 1341355416954403944
|
565
565
|
requirements: []
|
566
566
|
rubyforge_project:
|
567
|
-
rubygems_version: 1.8.
|
567
|
+
rubygems_version: 1.8.19
|
568
568
|
signing_key:
|
569
569
|
specification_version: 3
|
570
570
|
summary: Editorial Management System
|