lines-engine 0.1.17 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c75b66e2862656500bbf544915c6c8b554b3cb8d
4
- data.tar.gz: 3396baaf3becd71a03e255ea63af3a8bea533aa1
3
+ metadata.gz: efaf76786e0d64f0b0c688a19d7b05cefa2ed5a6
4
+ data.tar.gz: c665412cae4d55a0091bb5d097b792c1514b9afd
5
5
  SHA512:
6
- metadata.gz: f427d273b55339e8639c344b77c23d3b4d8187e92f16474de74073b3bf921ec18feb956274d795d1bdaa874107aa599bc0a96faece4274ce02da117a879aee8d
7
- data.tar.gz: 1d1ec819aeb65064243a2aa79356bcb8052191aa301feddc2c28059ba454abca12d5ad60e229548ef299e17c730e09974194eb8eda6ec32276da95d564674f32
6
+ metadata.gz: 1b6d6e8e98c1d9291cae3c43cc78a5b80c453f04db14b8c1f44c0f9ff7478530e4abb580b4202ba34d3fbbf0ded655cb8c5d19301c8c24b3643d6ae8d399f8aa
7
+ data.tar.gz: 15feb2f96d2d9a6a897e7cca3c243236360902c3f2ee7e9cb88d0d226aecd11f2ed8bbc486e75318cf77608f58afe4bb5bcfe5ce86dc6d66f9e9c37eb915f8ad
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lines-engine (0.1.17)
4
+ lines-engine (0.1.18)
5
5
  acts-as-taggable-on (~> 3.2.6, >= 3.2.6)
6
6
  bcrypt (~> 3.1.0, >= 3.1.0)
7
7
  carrierwave (~> 0.10.0, >= 0.10.0)
@@ -6,14 +6,16 @@
6
6
  require_dependency "lines/application_controller"
7
7
 
8
8
  module Lines
9
+ module Admin
9
10
 
10
- class Admin::ApplicationController < ApplicationController
11
- protect_from_forgery
11
+ class ApplicationController < Lines::ApplicationController
12
+ protect_from_forgery
12
13
 
13
- before_action :authorize
14
+ before_action :authorize
14
15
 
15
- layout 'lines/admin'
16
+ layout 'lines/admin'
16
17
 
18
+ end
19
+
17
20
  end
18
-
19
21
  end
@@ -7,166 +7,168 @@
7
7
  require_dependency "lines/admin/application_controller"
8
8
 
9
9
  module Lines
10
-
11
- class Admin::ArticlesController < Admin::ApplicationController
12
-
13
- autocomplete :tag, :name, class_name: 'ActsAsTaggableOn::Tag'
14
- before_action :process_base64_upload, only: [:create, :update]
15
-
16
- # Lists all articles. Provides <tt>@articles_unpublished</tt> and
17
- # <tt>@articles_published</tt> to distinguish between published and
18
- # unpublished articles
19
- def index
20
- @articles = Article.order('published ASC, featured DESC, published_at DESC').page(params[:page]).per(25)
21
- @articles_unpublished = @articles.select{|a| a.published == false}
22
- @articles_published = @articles.select{|a| a.published == true}
23
- respond_to do |format|
24
- format.html # index.html.erb
10
+ module Admin
11
+
12
+ class ArticlesController < ApplicationController
13
+
14
+ autocomplete :tag, :name, class_name: 'ActsAsTaggableOn::Tag'
15
+ before_action :process_base64_upload, only: [:create, :update]
16
+
17
+ # Lists all articles. Provides <tt>@articles_unpublished</tt> and
18
+ # <tt>@articles_published</tt> to distinguish between published and
19
+ # unpublished articles
20
+ def index
21
+ @articles = Article.order('published ASC, featured DESC, published_at DESC').page(params[:page]).per(25)
22
+ @articles_unpublished = @articles.select{|a| a.published == false}
23
+ @articles_published = @articles.select{|a| a.published == true}
24
+ respond_to do |format|
25
+ format.html # index.html.erb
26
+ end
25
27
  end
26
- end
27
28
 
28
- # GET /admin/articles/1
29
- def show
30
- @article = Article.find(params[:id])
31
- @first_page = true
29
+ # GET /admin/articles/1
30
+ def show
31
+ @article = Article.find(params[:id])
32
+ @first_page = true
32
33
 
33
- respond_to do |format|
34
- format.html {render :show, layout: 'lines/preview'}
34
+ respond_to do |format|
35
+ format.html {render :show, layout: 'lines/preview'}
36
+ end
35
37
  end
36
- end
37
38
 
38
- # GET /admin/articles/new
39
- def new
40
- @article = Lines::Article.new
39
+ # GET /admin/articles/new
40
+ def new
41
+ @article = Lines::Article.new
41
42
 
42
- respond_to do |format|
43
- format.html # new.html.erb
43
+ respond_to do |format|
44
+ format.html # new.html.erb
45
+ end
44
46
  end
45
- end
46
47
 
47
- # GET /admin/articles/1/edit
48
- def edit
49
- @article = Article.find(params[:id])
50
- end
48
+ # GET /admin/articles/1/edit
49
+ def edit
50
+ @article = Article.find(params[:id])
51
+ end
51
52
 
52
- # POST /admin/articles
53
- def create
54
- @article = Article.new(article_params)
53
+ # POST /admin/articles
54
+ def create
55
+ @article = Article.new(article_params)
55
56
 
56
- respond_to do |format|
57
- if @article.save
58
- format.html { redirect_to admin_article_path(@article), notice: 'Article was successfully created.' }
59
- else
60
- format.html { render action: "new" }
57
+ respond_to do |format|
58
+ if @article.save
59
+ format.html { redirect_to admin_article_path(@article), notice: 'Article was successfully created.' }
60
+ else
61
+ format.html { render action: "new" }
62
+ end
61
63
  end
62
64
  end
63
- end
64
65
 
65
- # PUT /admin/articles/1
66
- # TODO: Very much is happening here. Move deletion of hero_image to the article model
67
- def update
68
- @article = Article.find(params[:id])
69
- a_params = article_params
66
+ # PUT /admin/articles/1
67
+ # TODO: Very much is happening here. Move deletion of hero_image to the article model
68
+ def update
69
+ @article = Article.find(params[:id])
70
+ a_params = article_params
70
71
 
71
- # replace picture_path with the new uploaded file
72
- a_params[:hero_image] = @uploaded_file if @uploaded_file
72
+ # replace picture_path with the new uploaded file
73
+ a_params[:hero_image] = @uploaded_file if @uploaded_file
73
74
 
74
- # delete uploaded hero image when predifined image is selected
75
- if !a_params[:hero_image_cache].present? && a_params[:short_hero_image].present?
76
- @article.remove_hero_image!
77
- @article.remove_hero_image = true
78
- @article.save
79
- end
75
+ # delete uploaded hero image when predifined image is selected
76
+ if !a_params[:hero_image_cache].present? && a_params[:short_hero_image].present?
77
+ @article.remove_hero_image!
78
+ @article.remove_hero_image = true
79
+ @article.save
80
+ end
80
81
 
81
- respond_to do |format|
82
- if @article.update_attributes(article_params)
83
- ActionController::Base.new.expire_fragment(@article)
84
- format.html { redirect_to admin_article_path(@article), notice: 'Article was successfully updated.' }
85
- else
86
- format.html { render action: "edit" }
82
+ respond_to do |format|
83
+ if @article.update_attributes(article_params)
84
+ ActionController::Base.new.expire_fragment(@article)
85
+ format.html { redirect_to admin_article_path(@article), notice: 'Article was successfully updated.' }
86
+ else
87
+ format.html { render action: "edit" }
88
+ end
87
89
  end
88
90
  end
89
- end
90
91
 
91
- # DELETE /admin/articles/1
92
- def destroy
93
- @article = Article.find(params[:id])
94
- @article.destroy
92
+ # DELETE /admin/articles/1
93
+ def destroy
94
+ @article = Article.find(params[:id])
95
+ @article.destroy
95
96
 
96
- respond_to do |format|
97
- format.html { redirect_to admin_articles_url }
97
+ respond_to do |format|
98
+ format.html { redirect_to admin_articles_url }
99
+ end
98
100
  end
99
- end
100
101
 
101
- # Toggles published state of an article
102
- def toggle_publish
103
- @article = Article.find(params[:article_id])
104
- @article.update_attributes(published: !@article.published)
105
- redirect_to admin_articles_url, notice: 'Article updated!'
106
- end
102
+ # Toggles published state of an article
103
+ def toggle_publish
104
+ @article = Article.find(params[:article_id])
105
+ @article.update_attributes(published: !@article.published)
106
+ redirect_to admin_articles_url, notice: 'Article updated!'
107
+ end
107
108
 
108
- # Toggles featured state of an article
109
- def toggle_feature
110
- @article = Article.find(params[:article_id])
111
- old_featured = Article.where(featured: true)
112
- if old_featured.size > 0
113
- old_featured.each do |article|
114
- article.update_attributes(featured: false)
109
+ # Toggles featured state of an article
110
+ def toggle_feature
111
+ @article = Article.find(params[:article_id])
112
+ old_featured = Article.where(featured: true)
113
+ if old_featured.size > 0
114
+ old_featured.each do |article|
115
+ article.update_attributes(featured: false)
116
+ end
115
117
  end
118
+ @article.update_attributes(featured: !@article.featured)
119
+ redirect_to admin_articles_url, notice: 'Article updated!'
116
120
  end
117
- @article.update_attributes(featured: !@article.featured)
118
- redirect_to admin_articles_url, notice: 'Article updated!'
119
- end
120
121
 
121
- # Handles base64 encoded file uploads
122
- def process_base64_upload
123
- @uploaded_file = nil
124
- #check if file is given
125
- if params[:article][:hero_image_file] != ""
126
-
127
- picture_filename = "hero_image"
128
- picture_original_filename = "hero_image"
129
- picture_content_type = splitBase64(params[:article][:hero_image_file])[:type]
130
- picture_data = splitBase64(params[:article][:hero_image_file])[:data]
131
-
132
- #create a new tempfile named fileupload
133
- tempfile = Tempfile.new("fileupload")
134
- tempfile.binmode
135
-
136
- #get the file and decode it with base64 then write it to the tempfile
137
- tempfile.write(Base64.decode64(picture_data))
138
-
139
- #create a new uploaded file
140
- @uploaded_file = ActionDispatch::Http::UploadedFile.new(
141
- tempfile: tempfile,
142
- filename: picture_filename,
143
- original_filename: picture_original_filename
144
- )
145
- @uploaded_file.content_type = picture_content_type
122
+ # Handles base64 encoded file uploads
123
+ def process_base64_upload
124
+ @uploaded_file = nil
125
+ #check if file is given
126
+ if params[:article][:hero_image_file] != ""
127
+
128
+ picture_filename = "hero_image"
129
+ picture_original_filename = "hero_image"
130
+ picture_content_type = splitBase64(params[:article][:hero_image_file])[:type]
131
+ picture_data = splitBase64(params[:article][:hero_image_file])[:data]
132
+
133
+ #create a new tempfile named fileupload
134
+ tempfile = Tempfile.new("fileupload")
135
+ tempfile.binmode
136
+
137
+ #get the file and decode it with base64 then write it to the tempfile
138
+ tempfile.write(Base64.decode64(picture_data))
139
+
140
+ #create a new uploaded file
141
+ @uploaded_file = ActionDispatch::Http::UploadedFile.new(
142
+ tempfile: tempfile,
143
+ filename: picture_filename,
144
+ original_filename: picture_original_filename
145
+ )
146
+ @uploaded_file.content_type = picture_content_type
147
+ end
146
148
  end
147
- end
148
149
 
149
- def splitBase64(uri)
150
- if uri.match(%r{^data:(.*?);(.*?),(.*)$})
151
- return {
152
- type: $1, # "image/png"
153
- encoder: $2, # "base64"
154
- data: $3, # data string
155
- extension: $1.split('/')[1] # "png"
156
- }
150
+ def splitBase64(uri)
151
+ if uri.match(%r{^data:(.*?);(.*?),(.*)$})
152
+ return {
153
+ type: $1, # "image/png"
154
+ encoder: $2, # "base64"
155
+ data: $3, # data string
156
+ extension: $1.split('/')[1] # "png"
157
+ }
158
+ end
157
159
  end
158
- end
159
160
 
160
- private
161
+ private
161
162
 
162
- # Allowed attribute with strong_params
163
- def article_params
164
- params.require(:article).permit(:content, :hero_image, :short_hero_image, :published, :published_at,
165
- :sub_title, :title, :pictures, :author_ids, :hero_image_cache, :tag_list, :gplus_url, :featured,
166
- :document, :document_cache, :hero_image_file, :remove_document, :pictures, :authors,
167
- pictures_attributes: [:id, :image, :name, :article_id], author_ids: [] )
168
- end
163
+ # Allowed attribute with strong_params
164
+ def article_params
165
+ params.require(:article).permit(:content, :hero_image, :short_hero_image, :published, :published_at,
166
+ :sub_title, :title, :pictures, :author_ids, :hero_image_cache, :tag_list, :gplus_url, :featured,
167
+ :document, :document_cache, :hero_image_file, :remove_document, :pictures, :authors,
168
+ pictures_attributes: [:id, :image, :name, :article_id], author_ids: [] )
169
+ end
169
170
 
170
- end
171
+ end
171
172
 
173
+ end
172
174
  end
@@ -3,68 +3,69 @@
3
3
  require_dependency "lines/admin/application_controller"
4
4
 
5
5
  module Lines
6
+ module Admin
7
+ class AuthorsController < ApplicationController
6
8
 
7
- class Admin::AuthorsController < Admin::ApplicationController
8
-
9
- # Listes all authroes
10
- def index
11
- @authors = Author.all
12
- end
9
+ # Listes all authroes
10
+ def index
11
+ @authors = Author.all
12
+ end
13
13
 
14
- # Shows an author
15
- def show
16
- @author = Author.find(params[:id])
17
- end
14
+ # Shows an author
15
+ def show
16
+ @author = Author.find(params[:id])
17
+ end
18
18
 
19
- # New author
20
- def new
21
- @author = Lines::Author.new
22
- end
19
+ # New author
20
+ def new
21
+ @author = Lines::Author.new
22
+ end
23
23
 
24
- # Edit an existing author
25
- def edit
26
- @author = Author.find(params[:id])
27
- end
24
+ # Edit an existing author
25
+ def edit
26
+ @author = Author.find(params[:id])
27
+ end
28
28
 
29
- # Create a new author from params
30
- def create
31
- @author = Author.new(author_params)
29
+ # Create a new author from params
30
+ def create
31
+ @author = Author.new(author_params)
32
32
 
33
- if @author.save
34
- redirect_to admin_author_path @author, notice: 'Author was successfully created.'
35
- else
36
- render action: "new"
33
+ if @author.save
34
+ redirect_to admin_author_path @author, notice: 'Author was successfully created.'
35
+ else
36
+ render action: "new"
37
+ end
37
38
  end
38
- end
39
39
 
40
- # Update an existing author from params
41
- def update
42
- @author = Author.find(params[:id])
40
+ # Update an existing author from params
41
+ def update
42
+ @author = Author.find(params[:id])
43
43
 
44
- if @author.update_attributes(params[:author])
45
- redirect_to admin_author_path @author, notice: 'Author was successfully updated.'
46
- else
47
- render action: "edit"
44
+ if @author.update_attributes(params[:author])
45
+ redirect_to admin_author_path @author, notice: 'Author was successfully updated.'
46
+ else
47
+ render action: "edit"
48
+ end
48
49
  end
49
- end
50
50
 
51
- # Delete an author
52
- def destroy
53
- @author = Author.find(params[:id])
54
- if @author.destroy
55
- redirect_to admin_authors_url
56
- else
57
- @authors = Author.all
58
- render "index"
51
+ # Delete an author
52
+ def destroy
53
+ @author = Author.find(params[:id])
54
+ if @author.destroy
55
+ redirect_to admin_authors_url
56
+ else
57
+ @authors = Author.all
58
+ render "index"
59
+ end
59
60
  end
60
- end
61
61
 
62
- private
62
+ private
63
63
 
64
- # Use strong_params
65
- def author_params
66
- params.require(:author).permit(:email, :name, :description, :gplus_profile)
67
- end
68
- end
64
+ # Use strong_params
65
+ def author_params
66
+ params.require(:author).permit(:email, :name, :description, :gplus_profile)
67
+ end
68
+ end
69
69
 
70
+ end
70
71
  end
@@ -2,42 +2,43 @@
2
2
  require_dependency "lines/admin/application_controller"
3
3
 
4
4
  module Lines
5
+ module Admin
5
6
 
7
+ class PicturesController < ApplicationController
8
+ def create
9
+ @picture = Picture.create(picture_params)
10
+ end
6
11
 
7
- class Admin::PicturesController < Admin::ApplicationController
8
- def create
9
- @picture = Picture.create(picture_params)
10
- end
11
-
12
- # PUT /admin/pictures/1
13
- def update
14
- @picture = Picture.find(params[:id])
12
+ # PUT /admin/pictures/1
13
+ def update
14
+ @picture = Picture.find(params[:id])
15
15
 
16
- respond_to do |format|
17
- if @picture.update_attributes(picture_params[:picture])
18
- format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }
19
- else
20
- format.html { render action: "edit" }
16
+ respond_to do |format|
17
+ if @picture.update_attributes(picture_params[:picture])
18
+ format.html { redirect_to @picture, notice: 'Picture was successfully updated.' }
19
+ else
20
+ format.html { render action: "edit" }
21
+ end
21
22
  end
22
23
  end
23
- end
24
24
 
25
- # Deletes a picture. Only responds to JS requests.
26
- def destroy
27
- @picture = Picture.find(params[:id])
28
- @picture.destroy
25
+ # Deletes a picture. Only responds to JS requests.
26
+ def destroy
27
+ @picture = Picture.find(params[:id])
28
+ @picture.destroy
29
29
 
30
- respond_to do |format|
31
- format.js
30
+ respond_to do |format|
31
+ format.js
32
+ end
32
33
  end
33
- end
34
34
 
35
- private
35
+ private
36
36
 
37
- # strong_params
38
- def picture_params
39
- params.fetch(:picture, {}).permit(:image)
40
- end
37
+ # strong_params
38
+ def picture_params
39
+ params.fetch(:picture, {}).permit(:image)
40
+ end
41
+ end
42
+
41
43
  end
42
-
43
44
  end
data/lib/lines/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lines
2
- VERSION = "0.1.17"
2
+ VERSION = "0.1.18"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lines-engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.17
4
+ version: 0.1.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Opoloo GbR