cartoonist-comics 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/comic_admin_controller.rb +4 -19
- data/app/models/comic.rb +30 -0
- metadata +5 -5
@@ -53,9 +53,7 @@ class ComicAdminController < CartoonistController
|
|
53
53
|
return redirect_to "/comic_admin/new"
|
54
54
|
end
|
55
55
|
|
56
|
-
|
57
|
-
comic_number = Comic.next_number last
|
58
|
-
comic = Comic.create :number => comic_number, :title => params[:title], :posted_at => Comic.next_post_date(last), :description => params[:description], :scene_description => params[:scene_description], :dialogue => params[:dialogue], :title_text => params[:title_text], :tweet => params[:tweet], :database_file => DatabaseFile.create(:content => params[:image].read), :locked => true
|
56
|
+
comic = Comic.create_comic params
|
59
57
|
redirect_to "/comic_admin/#{comic.number}/edit"
|
60
58
|
end
|
61
59
|
|
@@ -69,31 +67,18 @@ class ComicAdminController < CartoonistController
|
|
69
67
|
|
70
68
|
def lock
|
71
69
|
comic = Comic.from_number params[:id].to_i
|
72
|
-
comic.
|
73
|
-
comic.save!
|
70
|
+
comic.lock!
|
74
71
|
redirect_to "/comic_admin/#{comic.number}/edit"
|
75
72
|
end
|
76
73
|
|
77
74
|
def unlock
|
78
75
|
comic = Comic.from_number params[:id].to_i
|
79
|
-
comic.
|
80
|
-
comic.save!
|
76
|
+
comic.unlock!
|
81
77
|
redirect_to "/comic_admin/#{comic.number}/edit"
|
82
78
|
end
|
83
79
|
|
84
80
|
def update
|
85
|
-
|
86
|
-
comic = Comic.from_number comic_number
|
87
|
-
raise "Cannot update locked comic!" if comic.locked
|
88
|
-
comic.title = params[:title]
|
89
|
-
comic.description = params[:description]
|
90
|
-
comic.scene_description = params[:scene_description]
|
91
|
-
comic.dialogue = params[:dialogue]
|
92
|
-
comic.title_text = params[:title_text]
|
93
|
-
comic.tweet = params[:tweet] unless comic.tweeted?
|
94
|
-
comic.locked = true
|
95
|
-
comic.database_file = DatabaseFile.create(:content => params[:image].read) if params[:image]
|
96
|
-
comic.save!
|
81
|
+
comic = Comic.update_comic params
|
97
82
|
redirect_to "/comic_admin/#{comic.number}/edit"
|
98
83
|
end
|
99
84
|
|
data/app/models/comic.rb
CHANGED
@@ -3,6 +3,16 @@ class Comic < ActiveRecord::Base
|
|
3
3
|
belongs_to :database_file
|
4
4
|
include Tweetable
|
5
5
|
|
6
|
+
def lock!
|
7
|
+
self.locked = true
|
8
|
+
save!
|
9
|
+
end
|
10
|
+
|
11
|
+
def unlock!
|
12
|
+
self.locked = false
|
13
|
+
save!
|
14
|
+
end
|
15
|
+
|
6
16
|
def expected_tweet_time
|
7
17
|
Time.local posted_at.year, posted_at.month, posted_at.day, 8, 0
|
8
18
|
end
|
@@ -64,6 +74,26 @@ class Comic < ActiveRecord::Base
|
|
64
74
|
|
65
75
|
VALID_DAYS = [MONDAY, WEDNESDAY, FRIDAY]
|
66
76
|
|
77
|
+
def create_comic(params)
|
78
|
+
last = current_created
|
79
|
+
create :number => next_number(last), :title => params[:title], :posted_at => next_post_date(last), :description => params[:description], :scene_description => params[:scene_description], :dialogue => params[:dialogue], :title_text => params[:title_text], :tweet => params[:tweet], :database_file => DatabaseFile.create(:content => params[:image].read), :locked => true
|
80
|
+
end
|
81
|
+
|
82
|
+
def update_comic(params)
|
83
|
+
comic = from_number params[:id].to_i
|
84
|
+
raise "Cannot update locked comic!" if comic.locked
|
85
|
+
comic.title = params[:title]
|
86
|
+
comic.description = params[:description]
|
87
|
+
comic.scene_description = params[:scene_description]
|
88
|
+
comic.dialogue = params[:dialogue]
|
89
|
+
comic.title_text = params[:title_text]
|
90
|
+
comic.tweet = params[:tweet] unless comic.tweeted?
|
91
|
+
comic.locked = true
|
92
|
+
comic.database_file = DatabaseFile.create(:content => params[:image].read) if params[:image]
|
93
|
+
comic.save!
|
94
|
+
comic
|
95
|
+
end
|
96
|
+
|
67
97
|
def next_number(comic)
|
68
98
|
if comic
|
69
99
|
comic.number + 1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartoonist-comics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,19 +9,19 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cartoonist
|
16
|
-
requirement: &
|
16
|
+
requirement: &19861160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.0.
|
21
|
+
version: 0.0.8
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19861160
|
25
25
|
description: This core plugin for Cartoonist adds comics.
|
26
26
|
email: reasonnumber@gmail.com
|
27
27
|
executables: []
|