cartoonist-comics 0.0.8 → 0.0.9

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.
@@ -1,4 +1,4 @@
1
- class ComicAdminController < CartoonistController
1
+ class Admin::ComicController < CartoonistController
2
2
  helper :comic
3
3
  before_filter :preview!, :only => [:preview, :preview_random]
4
4
  before_filter :ensure_ssl!
@@ -14,11 +14,11 @@ class ComicAdminController < CartoonistController
14
14
  format.html do
15
15
  if params[:id].present?
16
16
  begin
17
- return redirect_to "/comic_admin/1/preview" if params[:id].to_i < 1
17
+ return redirect_to "/admin/comic/1/preview" if params[:id].to_i < 1
18
18
  @comic = Comic.from_number params[:id]
19
19
  @disabled_next = @comic.maybe_newest?
20
20
  rescue
21
- return redirect_to "/comic_admin/preview"
21
+ return redirect_to "/admin/comic/preview"
22
22
  end
23
23
  else
24
24
  @comic = Comic.preview_current
@@ -37,7 +37,7 @@ class ComicAdminController < CartoonistController
37
37
  end
38
38
 
39
39
  def preview_random
40
- redirect_to "/comic_admin/#{rand(max_preview_comic) + 1}/preview"
40
+ redirect_to "/admin/comic/#{rand(max_preview_comic) + 1}/preview"
41
41
  end
42
42
 
43
43
  def new
@@ -50,11 +50,11 @@ class ComicAdminController < CartoonistController
50
50
  def create
51
51
  unless params[:image]
52
52
  flash[:message] = "Error: You must include an image when creating a new comic."
53
- return redirect_to "/comic_admin/new"
53
+ return redirect_to "/admin/comic/new"
54
54
  end
55
55
 
56
56
  comic = Comic.create_comic params
57
- redirect_to "/comic_admin/#{comic.number}/edit"
57
+ redirect_to "/admin/comic/#{comic.number}/edit"
58
58
  end
59
59
 
60
60
  def edit
@@ -62,24 +62,24 @@ class ComicAdminController < CartoonistController
62
62
  @edit_last_number = @comic.number - 1
63
63
  @edit_next_number = @comic.number + 1
64
64
  rescue ActiveRecord::RecordNotFound
65
- redirect_to "/comic_admin/new"
65
+ redirect_to "/admin/comic/new"
66
66
  end
67
67
 
68
68
  def lock
69
69
  comic = Comic.from_number params[:id].to_i
70
70
  comic.lock!
71
- redirect_to "/comic_admin/#{comic.number}/edit"
71
+ redirect_to "/admin/comic/#{comic.number}/edit"
72
72
  end
73
73
 
74
74
  def unlock
75
75
  comic = Comic.from_number params[:id].to_i
76
76
  comic.unlock!
77
- redirect_to "/comic_admin/#{comic.number}/edit"
77
+ redirect_to "/admin/comic/#{comic.number}/edit"
78
78
  end
79
79
 
80
80
  def update
81
81
  comic = Comic.update_comic params
82
- redirect_to "/comic_admin/#{comic.number}/edit"
82
+ redirect_to "/admin/comic/#{comic.number}/edit"
83
83
  end
84
84
 
85
85
  private
@@ -1,4 +1,4 @@
1
- module ComicAdminHelper
1
+ module Admin::ComicHelper
2
2
  def lock_toggle_target
3
3
  if @comic.locked
4
4
  "unlock"
@@ -1,7 +1,7 @@
1
1
  module ComicHelper
2
2
  def comic_current_url
3
3
  if preview?
4
- "/comic_admin/preview"
4
+ "/admin/comic/preview"
5
5
  else
6
6
  "/comic"
7
7
  end
@@ -9,7 +9,7 @@ module ComicHelper
9
9
 
10
10
  def comic_url(number)
11
11
  if preview?
12
- "/comic_admin/#{number}/preview"
12
+ "/admin/comic/#{number}/preview"
13
13
  else
14
14
  "/comic/#{number}"
15
15
  end
@@ -25,7 +25,7 @@ module ComicHelper
25
25
 
26
26
  def random_url
27
27
  if preview?
28
- "/comic_admin/preview_random"
28
+ "/admin/comic/preview_random"
29
29
  else
30
30
  "/comic/random"
31
31
  end
data/app/models/comic.rb CHANGED
@@ -1,7 +1,21 @@
1
1
  class Comic < ActiveRecord::Base
2
- attr_accessible :number, :posted_at, :title, :description, :scene_description, :dialogue, :title_text, :database_file_id, :database_file, :tweet, :tweeted_at, :locked
2
+ include Postable
3
+ include Entity
4
+ entity_type :comic
5
+ entity_global_url "/comic"
6
+ entity_url &:url
7
+ entity_edit_url &:edit_url
8
+ entity_description &:title
9
+ attr_accessible :number, :posted_at, :title, :description, :scene_description, :dialogue, :title_text, :database_file_id, :database_file, :locked
3
10
  belongs_to :database_file
4
- include Tweetable
11
+
12
+ def url
13
+ "/comic/#{number}"
14
+ end
15
+
16
+ def edit_url
17
+ "/admin/comic/#{number}/edit"
18
+ end
5
19
 
6
20
  def lock!
7
21
  self.locked = true
@@ -13,18 +27,6 @@ class Comic < ActiveRecord::Base
13
27
  save!
14
28
  end
15
29
 
16
- def expected_tweet_time
17
- Time.local posted_at.year, posted_at.month, posted_at.day, 8, 0
18
- end
19
-
20
- def formatted_posted_at(default_msg = "not yet posted")
21
- if posted_at
22
- posted_at.strftime "%-m/%-d/%Y"
23
- else
24
- default_msg
25
- end
26
- end
27
-
28
30
  def real?
29
31
  number
30
32
  end
@@ -51,16 +53,12 @@ class Comic < ActiveRecord::Base
51
53
  end
52
54
  end
53
55
 
54
- def absolute_url
55
- "http://#{Setting[:domain]}/comic/#{number}"
56
- end
57
-
58
56
  def img_url
59
57
  "/comic/#{number}.png"
60
58
  end
61
59
 
62
60
  def preview_img_url
63
- "/comic_admin/#{number}/preview.png"
61
+ "/admin/comic/#{number}/preview.png"
64
62
  end
65
63
 
66
64
  def absolute_img_url
@@ -76,7 +74,7 @@ class Comic < ActiveRecord::Base
76
74
 
77
75
  def create_comic(params)
78
76
  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
77
+ 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], :database_file => DatabaseFile.create(:content => params[:image].read), :locked => true
80
78
  end
81
79
 
82
80
  def update_comic(params)
@@ -87,7 +85,6 @@ class Comic < ActiveRecord::Base
87
85
  comic.scene_description = params[:scene_description]
88
86
  comic.dialogue = params[:dialogue]
89
87
  comic.title_text = params[:title_text]
90
- comic.tweet = params[:tweet] unless comic.tweeted?
91
88
  comic.locked = true
92
89
  comic.database_file = DatabaseFile.create(:content => params[:image].read) if params[:image]
93
90
  comic.save!
@@ -122,18 +119,6 @@ class Comic < ActiveRecord::Base
122
119
  preview_current.number
123
120
  end
124
121
 
125
- def untweeted
126
- posted.where(:tweeted_at => nil).all
127
- end
128
-
129
- def posted
130
- where "comics.posted_at <= ?", Date.today
131
- end
132
-
133
- def unposted
134
- where "comics.posted_at > ?", Date.today
135
- end
136
-
137
122
  def reverse_numerical
138
123
  order "comics.number DESC"
139
124
  end
@@ -1,10 +1,15 @@
1
+ <% Cartoonist::Entity.hooks_with(:edit_entity_before_partial).each do |hook| %>
2
+ <%= render :partial => hook.edit_entity_before_partial, :locals => { :entity => @comic } %>
3
+ <hr />
4
+ <% end %>
5
+
1
6
  <p>
2
- <%= form_tag "/comic_admin/#{@comic.number}/#{lock_toggle_target}", :method => :post do %>
7
+ <%= form_tag "/admin/comic/#{@comic.number}/#{lock_toggle_target}", :method => :post do %>
3
8
  <input type="submit" value="<%= lock_toggle_target %>" />
4
9
  <% end %>
5
10
  </p>
6
11
 
7
- <%= form_tag "/comic_admin/#{@comic.number}", :method => :put, :multipart => true do %>
12
+ <%= form_tag "/admin/comic/#{@comic.number}", :method => :put, :multipart => true do %>
8
13
  <table>
9
14
  <tr><td colspan="2">Comic: <%= @comic.number %></td></tr>
10
15
  <tr><td colspan="2">Post Date: <%= @comic.posted_at.strftime "%a, %-m/%-d/%Y" %></td></tr>
@@ -38,17 +43,6 @@
38
43
  </td>
39
44
  </tr>
40
45
 
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
46
  <tr>
53
47
  <td colspan="2">
54
48
  Image:<br />
@@ -68,3 +62,8 @@
68
62
  Current Image:<br />
69
63
  <img src="<%= @comic.preview_img_url %>" />
70
64
  </p>
65
+
66
+ <% Cartoonist::Entity.hooks_with(:edit_entity_after_partial).each do |hook| %>
67
+ <hr />
68
+ <%= render :partial => hook.edit_entity_after_partial, :locals => { :entity => @comic } %>
69
+ <% end %>
@@ -4,8 +4,8 @@
4
4
  <% @unposted.each do |comic| %>
5
5
  <li>
6
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>)
7
+ <a href="/admin/comic/<%= comic.number %>/edit"><%= comic.title %></a>
8
+ (<a href="/admin/comic/<%= comic.number %>/preview"><%= t "admin.comic.index.preview" %></a>)
9
9
  </li>
10
10
  <% end %>
11
11
  </ul>
@@ -16,8 +16,8 @@
16
16
  <% @posted.each do |comic| %>
17
17
  <li>
18
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>)
19
+ <a href="/admin/comic/<%= comic.number %>/edit"><%= comic.title %></a>
20
+ (<a href="/admin/comic/<%= comic.number %>/preview"><%= t "admin.comic.index.preview" %></a>)
21
21
  (<a href="/comic/<%= comic.number %>"><%= t "admin.comic.index.show" %></a>)
22
22
  </li>
23
23
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= form_tag "/comic_admin", :method => :post, :multipart => true do %>
1
+ <%= form_tag "/admin/comic", :method => :post, :multipart => true do %>
2
2
  <table>
3
3
  <tr><td colspan="2">Comic: <%= @next_number %></td></tr>
4
4
  <tr><td colspan="2">Post Date: <%= @next_post_date.strftime "%a, %-m/%-d/%Y" %></td></tr>
@@ -32,13 +32,6 @@
32
32
  </td>
33
33
  </tr>
34
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
35
  <tr>
43
36
  <td colspan="2">
44
37
  Image:<br />
@@ -1,14 +1,14 @@
1
1
  <% content_for :subtabs do %>
2
2
  <a class="subtab" href="/comic"><%= 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>
3
+ <a class="subtab" href="/admin/comic"><%= t "admin.comic.layout.list" %></a>
4
+ <a class="subtab" href="/admin/comic/new"><%= t "admin.comic.layout.new" %></a>
5
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>
6
+ <a class="subtab" href="/admin/comic/<%= @edit_last_number %>/edit"><%= t "admin.comic.layout.edit_last" %></a>
7
7
  <% end %>
8
8
  <% if @edit_next_number %>
9
- <a class="subtab" href="/comic_admin/<%= @edit_next_number %>/edit"><%= t "admin.comic.layout.edit_next" %></a>
9
+ <a class="subtab" href="/admin/comic/<%= @edit_next_number %>/edit"><%= t "admin.comic.layout.edit_next" %></a>
10
10
  <% end %>
11
- <a class="subtab" href="/comic_admin/preview"><%= t "admin.comic.layout.preview" %></a>
11
+ <a class="subtab" href="/admin/comic/preview"><%= t "admin.comic.layout.preview" %></a>
12
12
  <% end %>
13
13
 
14
14
  <% content_for :page_title, t("admin.comic.layout.section") %>
@@ -4,9 +4,9 @@
4
4
 
5
5
  <% content_for :small_buttons do %>
6
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>
7
+ <a class="facebook" href="https://www.facebook.com/sharer.php?u=<%= u @comic.entity_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.entity_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.entity_absolute_url %>" title="<%= t "comic.layout.google_plus_title" %>"><%= t "comic.layout.google_plus" %></a>
10
10
  <a class="rss" href="<%= rss_path %>" title="<%= rss_title %>"><%= t "comic.layout.rss" %></a>
11
11
  <% end %>
12
12
  <% end %>
@@ -18,6 +18,8 @@ en:
18
18
  tab:
19
19
  comics: Comics
20
20
  cartoonist:
21
+ entity:
22
+ comic: Comic
21
23
  layout:
22
24
  navigation:
23
25
  comic: Comic
@@ -9,8 +9,6 @@ class CreateComics < ActiveRecord::Migration
9
9
  t.text :dialogue, :null => false
10
10
  t.text :title_text, :null => false
11
11
  t.integer :database_file_id, :null => false
12
- t.string :tweet, :null => false
13
- t.datetime :tweeted_at
14
12
  t.boolean :locked, :default => false, :null => false
15
13
  t.timestamps
16
14
  end
@@ -1,8 +1,9 @@
1
1
  module CartoonistComics
2
2
  class Engine < ::Rails::Engine
3
- Cartoonist::Admin::Tab.add :comics, :url => "/comic_admin", :order => 0
3
+ Cartoonist::Entity.add :comic, "Comic"
4
+ Cartoonist::Admin::Tab.add :comics, :url => "/admin/comic", :order => 0
4
5
  Cartoonist::RootPath.add :comics, "comic#index"
5
- Cartoonist::Navigation::Link.add :url => "/comic", :preview_url => "/comic_admin/preview", :class => "comic", :label => "cartoonist.layout.navigation.comic", :order => 0
6
+ Cartoonist::Navigation::Link.add :url => "/comic", :preview_url => "/admin/comic/preview", :class => "comic", :label => "cartoonist.layout.navigation.comic", :order => 0
6
7
  Cartoonist::Migration.add_for self
7
8
 
8
9
  Cartoonist::Backup.for :comics do
@@ -32,16 +33,18 @@ module CartoonistComics
32
33
  end
33
34
  end
34
35
 
35
- resources :comic_admin do
36
- member do
37
- post "lock"
38
- get "preview"
39
- post "unlock"
40
- end
41
-
42
- collection do
43
- get "preview"
44
- get "preview_random"
36
+ namespace :admin do
37
+ resources :comic do
38
+ member do
39
+ post "lock"
40
+ get "preview"
41
+ post "unlock"
42
+ end
43
+
44
+ collection do
45
+ get "preview"
46
+ get "preview_random"
47
+ end
45
48
  end
46
49
  end
47
50
  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.8
4
+ version: 0.0.9
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-24 00:00:00.000000000 Z
12
+ date: 2012-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cartoonist
16
- requirement: &19861160 !ruby/object:Gem::Requirement
16
+ requirement: &6936700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - =
20
20
  - !ruby/object:Gem::Version
21
- version: 0.0.8
21
+ version: 0.0.9
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19861160
24
+ version_requirements: *6936700
25
25
  description: This core plugin for Cartoonist adds comics.
26
26
  email: reasonnumber@gmail.com
27
27
  executables: []
@@ -29,19 +29,19 @@ extensions: []
29
29
  extra_rdoc_files: []
30
30
  files:
31
31
  - .gitignore
32
- - app/controllers/comic_admin_controller.rb
32
+ - app/controllers/admin/comic_controller.rb
33
33
  - app/controllers/comic_controller.rb
34
- - app/helpers/comic_admin_helper.rb
34
+ - app/helpers/admin/comic_helper.rb
35
35
  - app/helpers/comic_helper.rb
36
36
  - app/models/comic.rb
37
37
  - app/models/comic_feed.rb
38
+ - app/views/admin/comic/edit.html.erb
39
+ - app/views/admin/comic/index.html.erb
40
+ - app/views/admin/comic/new.html.erb
38
41
  - app/views/comic/feed.rss.erb
39
42
  - app/views/comic/show.html.erb
40
- - app/views/comic_admin/edit.html.erb
41
- - app/views/comic_admin/index.html.erb
42
- - app/views/comic_admin/new.html.erb
43
+ - app/views/layouts/admin/comic.html.erb
43
44
  - app/views/layouts/comic.html.erb
44
- - app/views/layouts/comic_admin.html.erb
45
45
  - cartoonist-comics.gemspec
46
46
  - config/locales/en.yml
47
47
  - db/migrate/20120107035512_create_comics.rb