cartoonist-comics 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,29 +1,30 @@
1
1
  class ComicController < ApplicationController
2
- def current
2
+ def index
3
3
  @comic = Comic.current
4
4
  @disabled_prev = true if @comic.oldest?
5
5
  @disabled_next = true
6
6
  @title = Setting[:site_name]
7
7
  render :show
8
- cache_current_page
8
+ cache_page_as ".#{cache_type}.tmp.html" if Cartoonist::RootPath.current_key == :comics
9
+ cache_page_as "comic.#{cache_type}.tmp.html"
9
10
  end
10
11
 
11
12
  def random
12
- redirect_to "/#{rand(max_comic) + 1}"
13
+ redirect_to "/comic/#{rand(max_comic) + 1}"
13
14
  end
14
15
 
15
16
  def show
16
17
  respond_to do |format|
17
18
  format.html do
18
19
  begin
19
- return redirect_to "/1" if params[:id].to_i < 1
20
+ return redirect_to "/comic/1" if params[:id].to_i < 1
20
21
  @comic = Comic.from_number params[:id], true
21
22
  @disabled_prev = true if @comic.oldest?
22
23
  @disabled_next = @comic.maybe_newest?
23
24
  render
24
25
  cache_show_page
25
26
  rescue
26
- redirect_to "/"
27
+ redirect_to "/comic"
27
28
  end
28
29
  end
29
30
 
@@ -35,19 +36,19 @@ class ComicController < ApplicationController
35
36
  end
36
37
  end
37
38
 
38
- def index
39
+ def feed
39
40
  respond_to do |format|
40
- format.html { redirect_to "/" }
41
+ format.html { redirect_to "/comic" }
41
42
 
42
43
  format.rss do
43
- @feed = feed
44
+ @feed = feed_contents
44
45
  render :content_type => "application/xml"
45
46
  end
46
47
  end
47
48
  end
48
49
 
49
50
  private
50
- def feed
51
+ def feed_contents
51
52
  result = comic_cache.read "feed"
52
53
  return result if result
53
54
  result = ComicFeed.new Comic.feed
@@ -67,15 +68,11 @@ class ComicController < ApplicationController
67
68
  @@comic_cache ||= ActiveSupport::Cache::MemoryStore.new(:expires_in => 2.hours)
68
69
  end
69
70
 
70
- def cache_current_page
71
- cache_page_as ".#{cache_type}.tmp.html"
72
- end
73
-
74
71
  def cache_show_page
75
72
  if @disabled_next
76
- cache_page_as "#{@comic.number}.#{cache_type}.tmp.html"
73
+ cache_page_as "comic/#{@comic.number}.#{cache_type}.tmp.html"
77
74
  else
78
- cache_page_as "#{@comic.number}.#{cache_type}.html"
75
+ cache_page_as "comic/#{@comic.number}.#{cache_type}.html"
79
76
  end
80
77
  end
81
78
  end
@@ -3,7 +3,7 @@ module ComicHelper
3
3
  if preview?
4
4
  "/comic_admin/preview"
5
5
  else
6
- "/"
6
+ "/comic"
7
7
  end
8
8
  end
9
9
 
@@ -11,7 +11,7 @@ module ComicHelper
11
11
  if preview?
12
12
  "/comic_admin/#{number}/preview"
13
13
  else
14
- "/#{number}"
14
+ "/comic/#{number}"
15
15
  end
16
16
  end
17
17
 
@@ -27,7 +27,7 @@ module ComicHelper
27
27
  if preview?
28
28
  "/comic_admin/preview_random"
29
29
  else
30
- "/random"
30
+ "/comic/random"
31
31
  end
32
32
  end
33
33
  end
data/app/models/comic.rb CHANGED
@@ -41,7 +41,7 @@ class Comic < ActiveRecord::Base
41
41
  end
42
42
 
43
43
  def absolute_url
44
- "http://#{Setting[:domain]}/#{number}"
44
+ "http://#{Setting[:domain]}/comic/#{number}"
45
45
  end
46
46
 
47
47
  def img_url
@@ -22,8 +22,8 @@
22
22
  } %>
23
23
  <% end %>
24
24
  </description>
25
- <link>http://<%= Setting[:domain] %>/<%= item.number %></link>
26
- <guid>http://<%= Setting[:domain] %>/<%= item.number %></guid>
25
+ <link>http://<%= Setting[:domain] %>/comic/<%= item.number %></link>
26
+ <guid>http://<%= Setting[:domain] %>/comic/<%= item.number %></guid>
27
27
  <pubDate><%= item.pub_date %></pubDate>
28
28
  </item>
29
29
  <% end %>
@@ -18,7 +18,7 @@
18
18
  <%= comic.formatted_posted_at "" %>
19
19
  <a href="/comic_admin/<%= comic.number %>/edit"><%= comic.title %></a>
20
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>)
21
+ (<a href="/comic/<%= comic.number %>"><%= t "admin.comic.index.show" %></a>)
22
22
  </li>
23
23
  <% end %>
24
24
  </ul>
@@ -1,6 +1,6 @@
1
1
  <% content_for :content_class, "comic-content" %>
2
2
  <% licensed! %>
3
- <% rss! "/feed", t("comic.layout.rss_title", :site_name => Setting[:site_name]) %>
3
+ <% rss! "/comic/feed", t("comic.layout.rss_title", :site_name => Setting[:site_name]) %>
4
4
 
5
5
  <% content_for :small_buttons do %>
6
6
  <% if @comic.real? %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :subtabs do %>
2
- <a class="subtab" href="/"><%= t "admin.comic.layout.latest" %></a>
2
+ <a class="subtab" href="/comic"><%= t "admin.comic.layout.latest" %></a>
3
3
  <a class="subtab" href="/comic_admin"><%= t "admin.comic.layout.list" %></a>
4
4
  <a class="subtab" href="/comic_admin/new"><%= t "admin.comic.layout.new" %></a>
5
5
  <% if @edit_last_number && @edit_last_number > 0 %>
@@ -1,7 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
- s.name = "cartoonist-comics"
3
2
  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")
3
+ cartoonist_version = File.read(File.join(File.dirname(__FILE__), "../CARTOONIST_VERSION")).strip
4
+ s.name = "cartoonist-comics"
5
+ s.version = cartoonist_version
5
6
  s.date = Time.now.strftime "%Y-%m-%d"
6
7
  s.summary = "Cartoonist Comics"
7
8
  s.description = "This core plugin for Cartoonist adds comics."
@@ -10,4 +11,5 @@ Gem::Specification.new do |s|
10
11
  s.files = `git ls-files`.split("\n")
11
12
  s.require_paths = ["lib"]
12
13
  s.homepage = "http://reasonnumber.com/cartoonist"
14
+ s.add_dependency "cartoonist", cartoonist_version
13
15
  end
@@ -1,7 +1,8 @@
1
1
  module CartoonistComics
2
2
  class Engine < ::Rails::Engine
3
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
4
+ Cartoonist::RootPath.add :comics, "comic#index"
5
+ Cartoonist::Navigation::Link.add :url => "/comic", :preview_url => "/comic_admin/preview", :class => "comic", :label => "application.layout.navigation.comic", :order => 0
5
6
  Cartoonist::Migration.add_for self
6
7
 
7
8
  Cartoonist::Backup.for :comics do
@@ -12,24 +13,24 @@ module CartoonistComics
12
13
  comics = Comic.sitemap
13
14
 
14
15
  result = comics.map do |comic|
15
- SitemapEntry.new "/#{comic.number}", comic.posted_at, :never
16
+ SitemapEntry.new "/comic/#{comic.number}", comic.posted_at, :never
16
17
  end
17
18
 
18
- first = comics.first
19
- result << SitemapEntry.new("/", first.posted_at, :daily, "1.0")
20
- result
21
- end
19
+ unless result.empty?
20
+ first = comics.first
21
+ result << SitemapEntry.new("/comic", first.posted_at, :daily, "1.0")
22
+ end
22
23
 
23
- Cartoonist::Routes.add_begin do
24
- root :to => "comic#current"
25
- match ":id", :controller => "comic", :action => "show", :id => /\d+/
24
+ result
26
25
  end
27
26
 
28
27
  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" }
28
+ resources :comic do
29
+ collection do
30
+ get "random"
31
+ get "feed", :defaults => { :format => "rss" }
32
+ end
33
+ end
33
34
 
34
35
  resources :comic_admin do
35
36
  member do
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
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,19 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-16 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-04-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cartoonist
16
+ requirement: &9936240 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - =
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *9936240
14
25
  description: This core plugin for Cartoonist adds comics.
15
26
  email: reasonnumber@gmail.com
16
27
  executables: []
@@ -24,7 +35,7 @@ files:
24
35
  - app/helpers/comic_helper.rb
25
36
  - app/models/comic.rb
26
37
  - app/models/comic_feed.rb
27
- - app/views/comic/index.rss.erb
38
+ - app/views/comic/feed.rss.erb
28
39
  - app/views/comic/show.html.erb
29
40
  - app/views/comic_admin/edit.html.erb
30
41
  - app/views/comic_admin/index.html.erb