cartoonist-comics 0.0.3.5 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/comic_admin_controller.rb +112 -0
- data/app/controllers/comic_controller.rb +81 -0
- data/app/helpers/comic_admin_helper.rb +15 -0
- data/app/helpers/comic_helper.rb +33 -0
- data/app/models/comic.rb +154 -0
- data/app/models/comic_feed.rb +23 -0
- data/app/views/comic/index.rss.erb +29 -0
- data/app/views/comic/show.html.erb +28 -0
- data/app/views/comic_admin/edit.html.erb +70 -0
- data/app/views/comic_admin/index.html.erb +24 -0
- data/app/views/comic_admin/new.html.erb +55 -0
- data/app/views/layouts/comic.html.erb +78 -0
- data/app/views/layouts/comic_admin.html.erb +16 -0
- data/cartoonist-comics.gemspec +3 -2
- data/config/locales/en.yml +35 -0
- data/db/migrate/20120107035512_create_comics.rb +21 -0
- data/lib/cartoonist-comics/engine.rb +44 -0
- metadata +17 -2
@@ -0,0 +1,112 @@
|
|
1
|
+
class ComicAdminController < ApplicationController
|
2
|
+
helper :comic
|
3
|
+
before_filter :preview!, :only => [:preview, :preview_random]
|
4
|
+
before_filter :ensure_ssl!
|
5
|
+
before_filter :check_admin!
|
6
|
+
|
7
|
+
def index
|
8
|
+
@unposted = Comic.unposted.numerical
|
9
|
+
@posted = Comic.posted.reverse_numerical
|
10
|
+
end
|
11
|
+
|
12
|
+
def preview
|
13
|
+
respond_to do |format|
|
14
|
+
format.html do
|
15
|
+
if params[:id].present?
|
16
|
+
begin
|
17
|
+
return redirect_to "/comic_admin/1/preview" if params[:id].to_i < 1
|
18
|
+
@comic = Comic.from_number params[:id]
|
19
|
+
@disabled_next = @comic.maybe_newest?
|
20
|
+
rescue
|
21
|
+
return redirect_to "/comic_admin/preview"
|
22
|
+
end
|
23
|
+
else
|
24
|
+
@comic = Comic.preview_current
|
25
|
+
@disabled_next = true
|
26
|
+
end
|
27
|
+
|
28
|
+
@disabled_prev = true if @comic.oldest?
|
29
|
+
render "comic/show", :layout => "comic"
|
30
|
+
end
|
31
|
+
|
32
|
+
format.png do
|
33
|
+
comic = Comic.from_number params[:id]
|
34
|
+
send_data comic.database_file.content, :filename => "comic_#{comic.number}.png", :type => "image/png", :disposition => "inline"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def preview_random
|
40
|
+
redirect_to "/comic_admin/#{rand(max_preview_comic) + 1}/preview"
|
41
|
+
end
|
42
|
+
|
43
|
+
def new
|
44
|
+
last = Comic.current_created
|
45
|
+
@next_number = Comic.next_number last
|
46
|
+
@next_post_date = Comic.next_post_date last
|
47
|
+
@edit_last_number = last.number if last
|
48
|
+
end
|
49
|
+
|
50
|
+
def create
|
51
|
+
unless params[:image]
|
52
|
+
flash[:message] = "Error: You must include an image when creating a new comic."
|
53
|
+
return redirect_to "/comic_admin/new"
|
54
|
+
end
|
55
|
+
|
56
|
+
last = Comic.current_created
|
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
|
59
|
+
redirect_to "/comic_admin/#{comic.number}/edit"
|
60
|
+
end
|
61
|
+
|
62
|
+
def edit
|
63
|
+
@comic = Comic.from_number params[:id]
|
64
|
+
@edit_last_number = @comic.number - 1
|
65
|
+
@edit_next_number = @comic.number + 1
|
66
|
+
rescue ActiveRecord::RecordNotFound
|
67
|
+
redirect_to "/comic_admin/new"
|
68
|
+
end
|
69
|
+
|
70
|
+
def lock
|
71
|
+
comic = Comic.from_number params[:id].to_i
|
72
|
+
comic.locked = true
|
73
|
+
comic.save!
|
74
|
+
redirect_to "/comic_admin/#{comic.number}/edit"
|
75
|
+
end
|
76
|
+
|
77
|
+
def unlock
|
78
|
+
comic = Comic.from_number params[:id].to_i
|
79
|
+
comic.locked = false
|
80
|
+
comic.save!
|
81
|
+
redirect_to "/comic_admin/#{comic.number}/edit"
|
82
|
+
end
|
83
|
+
|
84
|
+
def update
|
85
|
+
comic_number = params[:id].to_i
|
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!
|
97
|
+
redirect_to "/comic_admin/#{comic.number}/edit"
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
def admin_comic_cache
|
102
|
+
@@admin_comic_cache ||= ActiveSupport::Cache::MemoryStore.new(:expires_in => 2.hours)
|
103
|
+
end
|
104
|
+
|
105
|
+
def max_preview_comic
|
106
|
+
result = admin_comic_cache.read "preview-max-comic"
|
107
|
+
return result if result
|
108
|
+
result = Comic.largest_number
|
109
|
+
admin_comic_cache.write "preview-max-comic", result
|
110
|
+
result
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
class ComicController < ApplicationController
|
2
|
+
def current
|
3
|
+
@comic = Comic.current
|
4
|
+
@disabled_prev = true if @comic.oldest?
|
5
|
+
@disabled_next = true
|
6
|
+
@title = Setting[:site_name]
|
7
|
+
render :show
|
8
|
+
cache_current_page
|
9
|
+
end
|
10
|
+
|
11
|
+
def random
|
12
|
+
redirect_to "/#{rand(max_comic) + 1}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def show
|
16
|
+
respond_to do |format|
|
17
|
+
format.html do
|
18
|
+
begin
|
19
|
+
return redirect_to "/1" if params[:id].to_i < 1
|
20
|
+
@comic = Comic.from_number params[:id], true
|
21
|
+
@disabled_prev = true if @comic.oldest?
|
22
|
+
@disabled_next = @comic.maybe_newest?
|
23
|
+
render
|
24
|
+
cache_show_page
|
25
|
+
rescue
|
26
|
+
redirect_to "/"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
format.png do
|
31
|
+
comic = Comic.from_number params[:id], true
|
32
|
+
send_data comic.database_file.content, :filename => "comic_#{comic.number}.png", :type => "image/png", :disposition => "inline"
|
33
|
+
cache_page_as "static/comic/#{comic.number}.png"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def index
|
39
|
+
respond_to do |format|
|
40
|
+
format.html { redirect_to "/" }
|
41
|
+
|
42
|
+
format.rss do
|
43
|
+
@feed = feed
|
44
|
+
render :content_type => "application/xml"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def feed
|
51
|
+
result = comic_cache.read "feed"
|
52
|
+
return result if result
|
53
|
+
result = ComicFeed.new Comic.feed
|
54
|
+
comic_cache.write "feed", result
|
55
|
+
result
|
56
|
+
end
|
57
|
+
|
58
|
+
def max_comic
|
59
|
+
result = comic_cache.read "max-comic"
|
60
|
+
return result if result
|
61
|
+
result = Comic.largest_posted_number
|
62
|
+
comic_cache.write "max-comic", result
|
63
|
+
result
|
64
|
+
end
|
65
|
+
|
66
|
+
def comic_cache
|
67
|
+
@@comic_cache ||= ActiveSupport::Cache::MemoryStore.new(:expires_in => 2.hours)
|
68
|
+
end
|
69
|
+
|
70
|
+
def cache_current_page
|
71
|
+
cache_page_as ".#{cache_type}.tmp.html"
|
72
|
+
end
|
73
|
+
|
74
|
+
def cache_show_page
|
75
|
+
if @disabled_next
|
76
|
+
cache_page_as "#{@comic.number}.#{cache_type}.tmp.html"
|
77
|
+
else
|
78
|
+
cache_page_as "#{@comic.number}.#{cache_type}.html"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ComicHelper
|
2
|
+
def comic_current_url
|
3
|
+
if preview?
|
4
|
+
"/comic_admin/preview"
|
5
|
+
else
|
6
|
+
"/"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def comic_url(number)
|
11
|
+
if preview?
|
12
|
+
"/comic_admin/#{number}/preview"
|
13
|
+
else
|
14
|
+
"/#{number}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def comic_img_url
|
19
|
+
if preview?
|
20
|
+
@comic.preview_img_url
|
21
|
+
else
|
22
|
+
@comic.img_url
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def random_url
|
27
|
+
if preview?
|
28
|
+
"/comic_admin/preview_random"
|
29
|
+
else
|
30
|
+
"/random"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/app/models/comic.rb
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
class Comic < ActiveRecord::Base
|
2
|
+
belongs_to :database_file
|
3
|
+
include Tweetable
|
4
|
+
|
5
|
+
def expected_tweet_time
|
6
|
+
Time.local posted_at.year, posted_at.month, posted_at.day, 8, 0
|
7
|
+
end
|
8
|
+
|
9
|
+
def formatted_posted_at(default_msg = "not yet posted")
|
10
|
+
if posted_at
|
11
|
+
posted_at.strftime "%-m/%-d/%Y"
|
12
|
+
else
|
13
|
+
default_msg
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def real?
|
18
|
+
number
|
19
|
+
end
|
20
|
+
|
21
|
+
def previous_number
|
22
|
+
if number
|
23
|
+
number - 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def next_number
|
28
|
+
if number
|
29
|
+
number + 1
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def oldest?
|
34
|
+
number == 1 || !number
|
35
|
+
end
|
36
|
+
|
37
|
+
def maybe_newest?
|
38
|
+
if respond_to? :max_number
|
39
|
+
max_number.to_i == number
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def absolute_url
|
44
|
+
"http://#{Setting[:domain]}/#{number}"
|
45
|
+
end
|
46
|
+
|
47
|
+
def img_url
|
48
|
+
"/comic/#{number}.png"
|
49
|
+
end
|
50
|
+
|
51
|
+
def preview_img_url
|
52
|
+
"/comic_admin/#{number}/preview.png"
|
53
|
+
end
|
54
|
+
|
55
|
+
def absolute_img_url
|
56
|
+
"http://#{Setting[:domain]}#{img_url}"
|
57
|
+
end
|
58
|
+
|
59
|
+
class << self
|
60
|
+
MONDAY = 1
|
61
|
+
WEDNESDAY = 3
|
62
|
+
FRIDAY = 5
|
63
|
+
|
64
|
+
VALID_DAYS = [MONDAY, WEDNESDAY, FRIDAY]
|
65
|
+
|
66
|
+
def next_number(comic)
|
67
|
+
if comic
|
68
|
+
comic.number + 1
|
69
|
+
else
|
70
|
+
1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def next_post_date(comic)
|
75
|
+
if comic
|
76
|
+
from = comic.posted_at
|
77
|
+
else
|
78
|
+
from = Date.today
|
79
|
+
end
|
80
|
+
|
81
|
+
result = from
|
82
|
+
result += 1.day until result > from && VALID_DAYS.include?(result.wday)
|
83
|
+
result
|
84
|
+
end
|
85
|
+
|
86
|
+
def largest_posted_number
|
87
|
+
current.number
|
88
|
+
end
|
89
|
+
|
90
|
+
def largest_number
|
91
|
+
preview_current.number
|
92
|
+
end
|
93
|
+
|
94
|
+
def untweeted
|
95
|
+
posted.where(:tweeted_at => nil).all
|
96
|
+
end
|
97
|
+
|
98
|
+
def posted
|
99
|
+
where "comics.posted_at <= ?", Date.today
|
100
|
+
end
|
101
|
+
|
102
|
+
def unposted
|
103
|
+
where "comics.posted_at > ?", Date.today
|
104
|
+
end
|
105
|
+
|
106
|
+
def reverse_numerical
|
107
|
+
order "comics.number DESC"
|
108
|
+
end
|
109
|
+
|
110
|
+
def numerical
|
111
|
+
order "comics.number ASC"
|
112
|
+
end
|
113
|
+
|
114
|
+
def feed
|
115
|
+
posted.reverse_numerical.take 10
|
116
|
+
end
|
117
|
+
|
118
|
+
def sitemap
|
119
|
+
posted.reverse_numerical.all
|
120
|
+
end
|
121
|
+
|
122
|
+
def current_created
|
123
|
+
reverse_numerical.first
|
124
|
+
end
|
125
|
+
|
126
|
+
def current
|
127
|
+
comic = posted.reverse_numerical.first
|
128
|
+
comic = new :title => "No Comics Yet", :description => "Check back later for the first comic!" unless comic
|
129
|
+
comic
|
130
|
+
end
|
131
|
+
|
132
|
+
def preview_current
|
133
|
+
comic = reverse_numerical.first
|
134
|
+
comic = new :title => "No Comics Yet", :description => "Check back later for the first comic!" unless comic
|
135
|
+
comic
|
136
|
+
end
|
137
|
+
|
138
|
+
def from_number(num, only_posted = false)
|
139
|
+
comic = where :number => num.to_i
|
140
|
+
|
141
|
+
if only_posted
|
142
|
+
max_number = Comic.posted.select("MAX(comics.number)").to_sql
|
143
|
+
comic = comic.posted.select("comics.*, (#{max_number}) AS max_number")
|
144
|
+
else
|
145
|
+
max_number = Comic.select("MAX(comics.number)").to_sql
|
146
|
+
comic = comic.select("comics.*, (#{max_number}) AS max_number")
|
147
|
+
end
|
148
|
+
|
149
|
+
comic = comic.first
|
150
|
+
raise ActiveRecord::RecordNotFound.new("No records found!") unless comic
|
151
|
+
comic
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ComicFeed
|
2
|
+
attr_reader :pub_date, :items
|
3
|
+
|
4
|
+
def initialize(feed)
|
5
|
+
@pub_date = feed.first.posted_at.to_time.strftime "%a, %d %b %Y 00:00:01 %z"
|
6
|
+
@items = feed.map do |item|
|
7
|
+
ComicFeed::Item.new item
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class Item
|
12
|
+
attr_reader :number, :title, :img_url, :title_text, :description, :pub_date
|
13
|
+
|
14
|
+
def initialize(comic)
|
15
|
+
@number = comic.number
|
16
|
+
@title = comic.title
|
17
|
+
@img_url = comic.absolute_img_url
|
18
|
+
@title_text = comic.title_text
|
19
|
+
@description = comic.description
|
20
|
+
@pub_date = comic.posted_at.to_time.strftime "%a, %d %b %Y 00:00:01 %z"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<% content_for :rss_title, "#{Setting[:site_name]} Comic#{" (Mobile Edition)" if mobile?}" %>
|
2
|
+
<% content_for :pub_date, @feed.pub_date %>
|
3
|
+
|
4
|
+
<% @feed.items.each do |item| %>
|
5
|
+
<item>
|
6
|
+
<title><%= item.title %></title>
|
7
|
+
<description>
|
8
|
+
<%= %{
|
9
|
+
<h1>#{h item.title}</h1>
|
10
|
+
<p>
|
11
|
+
<img src="#{h item.img_url}" title="#{h item.title_text}" />
|
12
|
+
</p>
|
13
|
+
<p>
|
14
|
+
#{h item.description}
|
15
|
+
</p>
|
16
|
+
} %>
|
17
|
+
<% if mobile? %>
|
18
|
+
<%= %{
|
19
|
+
<p style="background: #eff8bd; width: 85%; margin: 20px auto 0 auto; border: 1px solid #d5eab7; padding: 4px 10px; display: block;">
|
20
|
+
#{h item.title_text}
|
21
|
+
</p>
|
22
|
+
} %>
|
23
|
+
<% end %>
|
24
|
+
</description>
|
25
|
+
<link>http://<%= Setting[:domain] %>/<%= item.number %></link>
|
26
|
+
<guid>http://<%= Setting[:domain] %>/<%= item.number %></guid>
|
27
|
+
<pubDate><%= item.pub_date %></pubDate>
|
28
|
+
</item>
|
29
|
+
<% end %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% content_for(:title, @title || @comic.title) %>
|
2
|
+
<% content_for :post_date, @comic.formatted_posted_at %>
|
3
|
+
<% content_for(:prev, @comic.previous_number.to_s) %>
|
4
|
+
<% content_for(:next, @comic.next_number.to_s) %>
|
5
|
+
<% enable_disqus! :path => "#{@comic.number}", :title => @comic.title, :category => Setting[:disqus_comic_category], :count_link => true %>
|
6
|
+
|
7
|
+
<h1 class="number"><%= @comic.title %></h1>
|
8
|
+
|
9
|
+
<p class="comic">
|
10
|
+
<% if @comic.database_file_id %>
|
11
|
+
<img title="<%= @comic.title_text %>" src="<%= comic_img_url %>" alt="<%= @comic.title %>" />
|
12
|
+
<% end %>
|
13
|
+
<div id="transcript" style="display: none;">
|
14
|
+
<div class="scene-description"><%= @comic.scene_description %></div>
|
15
|
+
<div class="dialogue"><%= @comic.dialogue %></div>
|
16
|
+
<div class="title"><%= @comic.title_text %></div>
|
17
|
+
</div>
|
18
|
+
</p>
|
19
|
+
|
20
|
+
<p class="description">
|
21
|
+
<%= @comic.description %>
|
22
|
+
</p>
|
23
|
+
|
24
|
+
<% if mobile? %>
|
25
|
+
<p class="title-text">
|
26
|
+
<%= @comic.title_text %>
|
27
|
+
</p>
|
28
|
+
<% end %>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<p>
|
2
|
+
<%= form_tag "/comic_admin/#{@comic.number}/#{lock_toggle_target}", :method => :post do %>
|
3
|
+
<input type="submit" value="<%= lock_toggle_target %>" />
|
4
|
+
<% end %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<%= form_tag "/comic_admin/#{@comic.number}", :method => :put, :multipart => true do %>
|
8
|
+
<table>
|
9
|
+
<tr><td colspan="2">Comic: <%= @comic.number %></td></tr>
|
10
|
+
<tr><td colspan="2">Post Date: <%= @comic.posted_at.strftime "%a, %-m/%-d/%Y" %></td></tr>
|
11
|
+
|
12
|
+
<tr>
|
13
|
+
<td colspan="2">
|
14
|
+
Title:<br />
|
15
|
+
<input type="text" name="title" value="<%= @comic.title %>" tabindex="1" <%= lock_disabled %> />
|
16
|
+
</td>
|
17
|
+
</tr>
|
18
|
+
|
19
|
+
<tr>
|
20
|
+
<td>
|
21
|
+
Description:<br />
|
22
|
+
<textarea name="description" rows="5" cols="50" autofocus="autofocus" tabindex="2" <%= lock_disabled %>><%= @comic.description %></textarea>
|
23
|
+
</td>
|
24
|
+
<td>
|
25
|
+
Scene Description:<br />
|
26
|
+
<textarea name="scene_description" rows="5" cols="50" tabindex="4" <%= lock_disabled %>><%= @comic.scene_description %></textarea>
|
27
|
+
</td>
|
28
|
+
</tr>
|
29
|
+
|
30
|
+
<tr>
|
31
|
+
<td>
|
32
|
+
Title Text:<br />
|
33
|
+
<textarea name="title_text" rows="5" cols="50" tabindex="3" <%= lock_disabled %>><%= @comic.title_text %></textarea>
|
34
|
+
</td>
|
35
|
+
<td>
|
36
|
+
Dialogue:<br />
|
37
|
+
<textarea name="dialogue" rows="5" cols="50" tabindex="5" <%= lock_disabled %>><%= @comic.dialogue %></textarea>
|
38
|
+
</td>
|
39
|
+
</tr>
|
40
|
+
|
41
|
+
<tr>
|
42
|
+
<td colspan="2">
|
43
|
+
Tweet:
|
44
|
+
<% if @comic.tweeted_at %>
|
45
|
+
<em>(sent <%= @comic.tweeted_at.strftime "%-m/%-d/%Y %-l:%M %P" %>)</em>
|
46
|
+
<% end %>
|
47
|
+
<br />
|
48
|
+
<textarea name="tweet" rows="2" cols="100" tabindex="6" <%= lock_disabled %>><%= @comic.tweet %></textarea>
|
49
|
+
</td>
|
50
|
+
</tr>
|
51
|
+
|
52
|
+
<tr>
|
53
|
+
<td colspan="2">
|
54
|
+
Image:<br />
|
55
|
+
<input name="image" type="file" tabindex="7" <%= lock_disabled %> />
|
56
|
+
</td>
|
57
|
+
</tr>
|
58
|
+
|
59
|
+
<tr>
|
60
|
+
<td colspan="2">
|
61
|
+
<input type="submit" value="Save" tabindex="8" <%= lock_disabled %> />
|
62
|
+
</td>
|
63
|
+
</tr>
|
64
|
+
</table>
|
65
|
+
<% end %>
|
66
|
+
|
67
|
+
<p>
|
68
|
+
Current Image:<br />
|
69
|
+
<img src="<%= @comic.preview_img_url %>" />
|
70
|
+
</p>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<h2><%= t "admin.comic.index.not_posted" %></h2>
|
2
|
+
|
3
|
+
<ul>
|
4
|
+
<% @unposted.each do |comic| %>
|
5
|
+
<li>
|
6
|
+
<%= comic.formatted_posted_at "" %>
|
7
|
+
<a href="/comic_admin/<%= comic.number %>/edit"><%= comic.title %></a>
|
8
|
+
(<a href="/comic_admin/<%= comic.number %>/preview"><%= t "admin.comic.index.preview" %></a>)
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
|
13
|
+
<h2><%= t "admin.comic.index.posted" %></h2>
|
14
|
+
|
15
|
+
<ul>
|
16
|
+
<% @posted.each do |comic| %>
|
17
|
+
<li>
|
18
|
+
<%= comic.formatted_posted_at "" %>
|
19
|
+
<a href="/comic_admin/<%= comic.number %>/edit"><%= comic.title %></a>
|
20
|
+
(<a href="/comic_admin/<%= comic.number %>/preview"><%= t "admin.comic.index.preview" %></a>)
|
21
|
+
(<a href="/<%= comic.number %>"><%= t "admin.comic.index.show" %></a>)
|
22
|
+
</li>
|
23
|
+
<% end %>
|
24
|
+
</ul>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<%= form_tag "/comic_admin", :method => :post, :multipart => true do %>
|
2
|
+
<table>
|
3
|
+
<tr><td colspan="2">Comic: <%= @next_number %></td></tr>
|
4
|
+
<tr><td colspan="2">Post Date: <%= @next_post_date.strftime "%a, %-m/%-d/%Y" %></td></tr>
|
5
|
+
|
6
|
+
<tr>
|
7
|
+
<td colspan="2">
|
8
|
+
Title:<br />
|
9
|
+
<input type="text" name="title" value="<%= SimpleTemplate[Setting[:default_title], :next_number => @next_number] %>" tabindex="1" />
|
10
|
+
</td>
|
11
|
+
</tr>
|
12
|
+
|
13
|
+
<tr>
|
14
|
+
<td>
|
15
|
+
Description:<br />
|
16
|
+
<textarea name="description" rows="5" cols="50" autofocus="autofocus" tabindex="2"></textarea>
|
17
|
+
</td>
|
18
|
+
<td>
|
19
|
+
Scene Description:<br />
|
20
|
+
<textarea name="scene_description" rows="5" cols="50" tabindex="4"></textarea>
|
21
|
+
</td>
|
22
|
+
</tr>
|
23
|
+
|
24
|
+
<tr>
|
25
|
+
<td>
|
26
|
+
Title Text:<br />
|
27
|
+
<textarea name="title_text" rows="5" cols="50" tabindex="3"></textarea>
|
28
|
+
</td>
|
29
|
+
<td>
|
30
|
+
Dialogue:<br />
|
31
|
+
<textarea name="dialogue" rows="5" cols="50" tabindex="5"></textarea>
|
32
|
+
</td>
|
33
|
+
</tr>
|
34
|
+
|
35
|
+
<tr>
|
36
|
+
<td colspan="2">
|
37
|
+
Tweet:<br />
|
38
|
+
<textarea name="tweet" rows="2" cols="100" tabindex="6"><%= SimpleTemplate[Setting[:default_tweet], :next_number => @next_number] %></textarea>
|
39
|
+
</td>
|
40
|
+
</tr>
|
41
|
+
|
42
|
+
<tr>
|
43
|
+
<td colspan="2">
|
44
|
+
Image:<br />
|
45
|
+
<input name="image" type="file" tabindex="7" />
|
46
|
+
</td>
|
47
|
+
</tr>
|
48
|
+
|
49
|
+
<tr>
|
50
|
+
<td colspan="2">
|
51
|
+
<input type="submit" value="Save" tabindex="8" />
|
52
|
+
</td>
|
53
|
+
</tr>
|
54
|
+
</table>
|
55
|
+
<% end %>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
<% content_for :content_class, "comic-content" %>
|
2
|
+
<% licensed! %>
|
3
|
+
<% rss! "/feed", t("comic.layout.rss_title", :site_name => Setting[:site_name]) %>
|
4
|
+
|
5
|
+
<% content_for :small_buttons do %>
|
6
|
+
<% if @comic.real? %>
|
7
|
+
<a class="facebook" href="https://www.facebook.com/sharer.php?u=<%= u @comic.absolute_url %>&t=<%= u t("comic.layout.facebook_text_message", :title => @comic.title) %>" title="<%= t "comic.layout.facebook_title" %>"><%= t "comic.layout.facebook" %></a>
|
8
|
+
<a class="twitter" href="https://twitter.com/intent/tweet?source=<%= u Setting[:domain] %>&text=<%= u t("comic.layout.twitter_text_message", :title => @comic.title, :url => @comic.absolute_url) %>" title="<%= t "comic.layout.twitter_title" %>"><%= t "comic.layout.twitter" %></a>
|
9
|
+
<a class="google-plus" href="https://plus.google.com/share?url=<%= u @comic.absolute_url %>" title="<%= t "comic.layout.google_plus_title" %>"><%= t "comic.layout.google_plus" %></a>
|
10
|
+
<a class="rss" href="<%= rss_path %>" title="<%= rss_title %>"><%= t "comic.layout.rss" %></a>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% content_for :content do %>
|
15
|
+
<div class="comic-page">
|
16
|
+
<div class="nav-container top-nav">
|
17
|
+
<div class="nav">
|
18
|
+
<% if @disabled_prev %>
|
19
|
+
<a class="first-disabled">first</a>
|
20
|
+
<a class="prev-disabled">prev</a>
|
21
|
+
<% else %>
|
22
|
+
<a class="first" href="<%= comic_url 1 %>">first</a>
|
23
|
+
<a class="prev" href="<%= comic_url yield(:prev) %>">prev</a>
|
24
|
+
<% end %>
|
25
|
+
<% if @comic.real? %>
|
26
|
+
<a class="random" href="<%= random_url %>" rel="nofollow">random</a>
|
27
|
+
<% else %>
|
28
|
+
<a class="random-disabled" rel="nofollow">random</a>
|
29
|
+
<% end %>
|
30
|
+
<% if @disabled_next %>
|
31
|
+
<a class="next-disabled">next</a>
|
32
|
+
<a class="last-disabled">last</a>
|
33
|
+
<% else %>
|
34
|
+
<a class="next" href="<%= comic_url yield(:next) %>">next</a>
|
35
|
+
<a class="last" href="<%= comic_current_url %>">last</a>
|
36
|
+
<% end %>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<%= yield %>
|
41
|
+
|
42
|
+
<div class="nav-container bottom-nav">
|
43
|
+
<div class="nav">
|
44
|
+
<% if @disabled_prev %>
|
45
|
+
<a class="first-disabled">first</a>
|
46
|
+
<a class="prev-disabled">prev</a>
|
47
|
+
<% else %>
|
48
|
+
<a class="first" href="<%= comic_url 1 %>">first</a>
|
49
|
+
<a class="prev" href="<%= comic_url yield(:prev) %>">prev</a>
|
50
|
+
<% end %>
|
51
|
+
<% if @comic.real? %>
|
52
|
+
<a class="random" href="<%= random_url %>" rel="nofollow">random</a>
|
53
|
+
<% else %>
|
54
|
+
<a class="random-disabled" rel="nofollow">random</a>
|
55
|
+
<% end %>
|
56
|
+
<% if @disabled_next %>
|
57
|
+
<a class="next-disabled">next</a>
|
58
|
+
<a class="last-disabled">last</a>
|
59
|
+
<% else %>
|
60
|
+
<a class="next" href="<%= comic_url yield(:next) %>">next</a>
|
61
|
+
<a class="last" href="<%= comic_current_url %>">last</a>
|
62
|
+
<% end %>
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
</div>
|
66
|
+
<% end %>
|
67
|
+
|
68
|
+
<% content_for :post_date_content do %>
|
69
|
+
<p class="posted-date">Posted on <%= yield :post_date %></p>
|
70
|
+
<% end %>
|
71
|
+
|
72
|
+
<% content_for :admin_content do %>
|
73
|
+
<% if preview? %>
|
74
|
+
<p><a href="/admin/main">admin</a></p>
|
75
|
+
<% end %>
|
76
|
+
<% end %>
|
77
|
+
|
78
|
+
<%= render :template => "layouts/application" %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% content_for :subtabs do %>
|
2
|
+
<a class="subtab" href="/"><%= t "admin.comic.layout.latest" %></a>
|
3
|
+
<a class="subtab" href="/comic_admin"><%= t "admin.comic.layout.list" %></a>
|
4
|
+
<a class="subtab" href="/comic_admin/new"><%= t "admin.comic.layout.new" %></a>
|
5
|
+
<% if @edit_last_number && @edit_last_number > 0 %>
|
6
|
+
<a class="subtab" href="/comic_admin/<%= @edit_last_number %>/edit"><%= t "admin.comic.layout.edit_last" %></a>
|
7
|
+
<% end %>
|
8
|
+
<% if @edit_next_number %>
|
9
|
+
<a class="subtab" href="/comic_admin/<%= @edit_next_number %>/edit"><%= t "admin.comic.layout.edit_next" %></a>
|
10
|
+
<% end %>
|
11
|
+
<a class="subtab" href="/comic_admin/preview"><%= t "admin.comic.layout.preview" %></a>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<% content_for :page_title, t("admin.comic.layout.section") %>
|
15
|
+
<% content_for(:content) { yield } %>
|
16
|
+
<%= render :template => "layouts/admin" %>
|
data/cartoonist-comics.gemspec
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cartoonist-comics"
|
3
|
-
|
4
|
-
s.
|
3
|
+
raise "Cannot find version file!" unless File.exists?(File.join(File.dirname(__FILE__), "../CARTOONIST_VERSION"))
|
4
|
+
s.version = File.read File.join(File.dirname(__FILE__), "../CARTOONIST_VERSION")
|
5
|
+
s.date = Time.now.strftime "%Y-%m-%d"
|
5
6
|
s.summary = "Cartoonist Comics"
|
6
7
|
s.description = "This core plugin for Cartoonist adds comics."
|
7
8
|
s.authors = ["Mike Virata-Stone"]
|
@@ -0,0 +1,35 @@
|
|
1
|
+
en:
|
2
|
+
admin:
|
3
|
+
comic:
|
4
|
+
index:
|
5
|
+
not_posted: Not yet posted
|
6
|
+
posted: Posted
|
7
|
+
preview: preview
|
8
|
+
show: show
|
9
|
+
layout:
|
10
|
+
edit_last: Edit Last
|
11
|
+
edit_next: Edit Next
|
12
|
+
latest: View Latest
|
13
|
+
list: List
|
14
|
+
new: New Comic
|
15
|
+
preview: Preview
|
16
|
+
section: Comics
|
17
|
+
layout:
|
18
|
+
tab:
|
19
|
+
comics: Comics
|
20
|
+
application:
|
21
|
+
layout:
|
22
|
+
navigation:
|
23
|
+
comic: Comic
|
24
|
+
comic:
|
25
|
+
layout:
|
26
|
+
facebook: Facebook
|
27
|
+
facebook_text_message: Check out %{title}
|
28
|
+
facebook_title: Share this comic on Facebook
|
29
|
+
google_plus: Google Plus
|
30
|
+
google_plus_title: Post this comic to Google Plus
|
31
|
+
rss: RSS
|
32
|
+
rss_title: RSS Feed for %{site_name}
|
33
|
+
twitter: Twitter
|
34
|
+
twitter_text_message: "Check out %{title}: %{url}"
|
35
|
+
twitter_title: Tweet about this comic
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateComics < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :comics do |t|
|
4
|
+
t.integer :number, :null => false
|
5
|
+
t.date :posted_at, :null => false
|
6
|
+
t.string :title, :null => false
|
7
|
+
t.text :description, :null => false
|
8
|
+
t.text :scene_description, :null => false
|
9
|
+
t.text :dialogue, :null => false
|
10
|
+
t.text :title_text, :null => false
|
11
|
+
t.integer :database_file_id, :null => false
|
12
|
+
t.string :tweet, :null => false
|
13
|
+
t.datetime :tweeted_at
|
14
|
+
t.boolean :locked, :default => false, :null => false
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
|
18
|
+
add_index :comics, :number, :unique => true
|
19
|
+
add_index :comics, :posted_at
|
20
|
+
end
|
21
|
+
end
|
@@ -1,4 +1,48 @@
|
|
1
1
|
module CartoonistComics
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
+
Cartoonist::Admin::Tab.add :comics, :url => "/comic_admin", :order => 0
|
4
|
+
Cartoonist::Navigation::Link.add :url => "/", :preview_url => "/comic_admin/preview", :class => "comic", :label => "application.layout.navigation.comic", :order => 0
|
5
|
+
Cartoonist::Migration.add_for self
|
6
|
+
|
7
|
+
Cartoonist::Backup.for :comics do
|
8
|
+
Comic.order(:id).all
|
9
|
+
end
|
10
|
+
|
11
|
+
Cartoonist::Sitemap.add do
|
12
|
+
comics = Comic.sitemap
|
13
|
+
|
14
|
+
result = comics.map do |comic|
|
15
|
+
SitemapEntry.new "/#{comic.number}", comic.posted_at, :never
|
16
|
+
end
|
17
|
+
|
18
|
+
first = comics.first
|
19
|
+
result << SitemapEntry.new("/", first.posted_at, :daily, "1.0")
|
20
|
+
result
|
21
|
+
end
|
22
|
+
|
23
|
+
Cartoonist::Routes.add_begin do
|
24
|
+
root :to => "comic#current"
|
25
|
+
match ":id", :controller => "comic", :action => "show", :id => /\d+/
|
26
|
+
end
|
27
|
+
|
28
|
+
Cartoonist::Routes.add do
|
29
|
+
match "comic/:id.png", :controller => "comic", :action => "show", :id => /\d+/, :defaults => { :format => "png" }
|
30
|
+
match "current" => "comic#current"
|
31
|
+
match "random" => "comic#random"
|
32
|
+
match "feed" => "comic#index", :defaults => { :format => "rss" }
|
33
|
+
|
34
|
+
resources :comic_admin do
|
35
|
+
member do
|
36
|
+
post "lock"
|
37
|
+
get "preview"
|
38
|
+
post "unlock"
|
39
|
+
end
|
40
|
+
|
41
|
+
collection do
|
42
|
+
get "preview"
|
43
|
+
get "preview_random"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
3
47
|
end
|
4
48
|
end
|
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.4
|
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-04-
|
12
|
+
date: 2012-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This core plugin for Cartoonist adds comics.
|
15
15
|
email: reasonnumber@gmail.com
|
@@ -18,7 +18,22 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- .gitignore
|
21
|
+
- app/controllers/comic_admin_controller.rb
|
22
|
+
- app/controllers/comic_controller.rb
|
23
|
+
- app/helpers/comic_admin_helper.rb
|
24
|
+
- app/helpers/comic_helper.rb
|
25
|
+
- app/models/comic.rb
|
26
|
+
- app/models/comic_feed.rb
|
27
|
+
- app/views/comic/index.rss.erb
|
28
|
+
- app/views/comic/show.html.erb
|
29
|
+
- app/views/comic_admin/edit.html.erb
|
30
|
+
- app/views/comic_admin/index.html.erb
|
31
|
+
- app/views/comic_admin/new.html.erb
|
32
|
+
- app/views/layouts/comic.html.erb
|
33
|
+
- app/views/layouts/comic_admin.html.erb
|
21
34
|
- cartoonist-comics.gemspec
|
35
|
+
- config/locales/en.yml
|
36
|
+
- db/migrate/20120107035512_create_comics.rb
|
22
37
|
- lib/cartoonist-comics.rb
|
23
38
|
- lib/cartoonist-comics/engine.rb
|
24
39
|
homepage: http://reasonnumber.com/cartoonist
|