cartoonist-pages 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/{page_admin_controller.rb → admin/page_controller.rb} +6 -6
- data/app/helpers/{page_admin_helper.rb → admin/page_helper.rb} +1 -1
- data/app/models/page.rb +14 -8
- data/app/views/{page_admin → admin/page}/edit.html.erb +14 -4
- data/app/views/{page_admin → admin/page}/index.html.erb +4 -4
- data/app/views/{page_admin → admin/page}/new.html.erb +2 -2
- data/app/views/layouts/{page_admin.html.erb → admin/page.html.erb} +2 -2
- data/config/locales/en.yml +3 -0
- data/lib/cartoonist-pages/engine.rb +15 -12
- metadata +11 -11
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class Admin::PageController < CartoonistController
|
2
2
|
before_filter :preview!, :only => [:preview]
|
3
3
|
before_filter :ensure_ssl!
|
4
4
|
before_filter :check_admin!
|
@@ -21,13 +21,13 @@ class PageAdminController < CartoonistController
|
|
21
21
|
path = params[:path].downcase
|
22
22
|
raise "Invalid path" unless path =~ /^[-_a-z0-9]+$/
|
23
23
|
page = Page.create :title => params[:title], :path => path, :content => params[:content], :locked => true
|
24
|
-
redirect_to "/
|
24
|
+
redirect_to "/admin/page/#{page.id}/edit"
|
25
25
|
end
|
26
26
|
|
27
27
|
def edit
|
28
28
|
@page = Page.find params[:id].to_i
|
29
29
|
rescue ActiveRecord::RecordNotFound
|
30
|
-
redirect_to "/
|
30
|
+
redirect_to "/admin/page/new"
|
31
31
|
end
|
32
32
|
|
33
33
|
def update
|
@@ -49,20 +49,20 @@ class PageAdminController < CartoonistController
|
|
49
49
|
end
|
50
50
|
|
51
51
|
page.save!
|
52
|
-
redirect_to "/
|
52
|
+
redirect_to "/admin/page/#{page.id}/edit"
|
53
53
|
end
|
54
54
|
|
55
55
|
def lock
|
56
56
|
page = Page.find params[:id].to_i
|
57
57
|
page.locked = true
|
58
58
|
page.save!
|
59
|
-
redirect_to "/
|
59
|
+
redirect_to "/admin/page/#{page.id}/edit"
|
60
60
|
end
|
61
61
|
|
62
62
|
def unlock
|
63
63
|
page = Page.find params[:id].to_i
|
64
64
|
page.locked = false
|
65
65
|
page.save!
|
66
|
-
redirect_to "/
|
66
|
+
redirect_to "/admin/page/#{page.id}/edit"
|
67
67
|
end
|
68
68
|
end
|
data/app/models/page.rb
CHANGED
@@ -1,6 +1,20 @@
|
|
1
1
|
class Page < ActiveRecord::Base
|
2
|
+
include Postable
|
3
|
+
include Entity
|
4
|
+
entity_type :page
|
5
|
+
entity_url &:url
|
6
|
+
entity_edit_url &:edit_url
|
7
|
+
entity_description &:title
|
2
8
|
attr_accessible :title, :path, :posted_at, :content, :locked, :comments, :in_sitemap
|
3
9
|
|
10
|
+
def url
|
11
|
+
"/#{path}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def edit_url
|
15
|
+
"/admin/page/#{id}/edit"
|
16
|
+
end
|
17
|
+
|
4
18
|
def has_comments?
|
5
19
|
comments
|
6
20
|
end
|
@@ -18,14 +32,6 @@ class Page < ActiveRecord::Base
|
|
18
32
|
where :in_sitemap => true
|
19
33
|
end
|
20
34
|
|
21
|
-
def posted
|
22
|
-
where "posted_at IS NOT NULL"
|
23
|
-
end
|
24
|
-
|
25
|
-
def unposted
|
26
|
-
where "posted_at IS NULL"
|
27
|
-
end
|
28
|
-
|
29
35
|
def ordered
|
30
36
|
order "pages.title ASC"
|
31
37
|
end
|
@@ -1,14 +1,19 @@
|
|
1
|
+
<% Cartoonist::Entity.hooks_with(:edit_entity_before_partial).each do |hook| %>
|
2
|
+
<%= render :partial => hook.edit_entity_before_partial, :locals => { :entity => @page } %>
|
3
|
+
<hr />
|
4
|
+
<% end %>
|
5
|
+
|
1
6
|
<p>
|
2
|
-
<a href="/
|
7
|
+
<a href="/admin/page/<%= @page.path %>/preview">Preview this page</a>
|
3
8
|
</p>
|
4
9
|
|
5
10
|
<p>
|
6
|
-
<%= form_tag "/
|
11
|
+
<%= form_tag "/admin/page/#{@page.id}/#{lock_toggle_target}", :method => :post do %>
|
7
12
|
<input type="submit" value="<%= lock_toggle_target %>" />
|
8
13
|
<% end %>
|
9
14
|
</p>
|
10
15
|
|
11
|
-
<%= form_tag "/
|
16
|
+
<%= form_tag "/admin/page/#{@page.id}", :method => :put do %>
|
12
17
|
<p>
|
13
18
|
<label>
|
14
19
|
<input type="checkbox" name="posted" value="true" <%= checked="checked".html_safe if @page.posted_at %> <%= lock_disabled %> />
|
@@ -65,7 +70,7 @@
|
|
65
70
|
$(".preview-content").click(function() {
|
66
71
|
var $this = $(this).attr("disabled", "disabled");
|
67
72
|
$.ajax({
|
68
|
-
url: "/
|
73
|
+
url: "/admin/page/preview_content",
|
69
74
|
type: "post",
|
70
75
|
data: {
|
71
76
|
authenticity_token: $("form input[name='authenticity_token']").val(),
|
@@ -85,3 +90,8 @@
|
|
85
90
|
});
|
86
91
|
});
|
87
92
|
<% end %>
|
93
|
+
|
94
|
+
<% Cartoonist::Entity.hooks_with(:edit_entity_after_partial).each do |hook| %>
|
95
|
+
<hr />
|
96
|
+
<%= render :partial => hook.edit_entity_after_partial, :locals => { :entity => @page } %>
|
97
|
+
<% end %>
|
@@ -3,8 +3,8 @@
|
|
3
3
|
<ul>
|
4
4
|
<% @unposted.each do |page| %>
|
5
5
|
<li>
|
6
|
-
<a href="/
|
7
|
-
(<a href="/
|
6
|
+
<a href="/admin/page/<%= page.id %>/edit"><%= page.title %></a>
|
7
|
+
(<a href="/admin/page/<%= page.path %>/preview"><%= t "admin.page.index.preview" %></a>)
|
8
8
|
</li>
|
9
9
|
<% end %>
|
10
10
|
</ul>
|
@@ -14,8 +14,8 @@
|
|
14
14
|
<ul>
|
15
15
|
<% @posted.each do |page| %>
|
16
16
|
<li>
|
17
|
-
<a href="/
|
18
|
-
(<a href="/
|
17
|
+
<a href="/admin/page/<%= page.id %>/edit"><%= page.title %></a>
|
18
|
+
(<a href="/admin/page/<%= page.path %>/preview"><%= t "admin.page.index.preview" %></a>)
|
19
19
|
(<a href="/<%= page.path %>"><%= t "admin.page.index.show" %></a>)
|
20
20
|
</li>
|
21
21
|
<% end %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<%= form_tag "/
|
1
|
+
<%= form_tag "/admin/page", :method => :post do %>
|
2
2
|
<p>
|
3
3
|
Path: <input type="text" name="path" autofocus="autofocus" size="20" /><br />
|
4
4
|
</p>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
$(".preview-content").click(function() {
|
30
30
|
var $this = $(this).attr("disabled", "disabled");
|
31
31
|
$.ajax({
|
32
|
-
url: "/
|
32
|
+
url: "/admin/page/preview_content",
|
33
33
|
type: "post",
|
34
34
|
data: {
|
35
35
|
authenticity_token: $("form input[name='authenticity_token']").val(),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% content_for :subtabs do %>
|
2
|
-
<a class="subtab" href="/
|
3
|
-
<a class="subtab" href="/
|
2
|
+
<a class="subtab" href="/admin/page"><%= t "admin.page.layout.list" %></a>
|
3
|
+
<a class="subtab" href="/admin/page/new"><%= t "admin.page.layout.new" %></a>
|
4
4
|
<% end %>
|
5
5
|
|
6
6
|
<% content_for :page_title, t("admin.page.layout.section") %>
|
data/config/locales/en.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module CartoonistPages
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
-
Cartoonist::
|
3
|
+
Cartoonist::Entity.add :page, "Page"
|
4
|
+
Cartoonist::Admin::Tab.add :pages, :url => "/admin/page", :order => 2
|
4
5
|
Cartoonist::Migration.add_for self
|
5
6
|
|
6
7
|
Cartoonist::Backup.for :pages do
|
@@ -9,7 +10,7 @@ module CartoonistPages
|
|
9
10
|
|
10
11
|
Cartoonist::Sitemap.add do
|
11
12
|
Page.sitemap.map do |page|
|
12
|
-
SitemapEntry.new
|
13
|
+
SitemapEntry.new page.entity_relative_url, page.posted_at, :monthly, "0.4"
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
@@ -18,17 +19,19 @@ module CartoonistPages
|
|
18
19
|
end
|
19
20
|
|
20
21
|
Cartoonist::Routes.add do
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
namespace :admin do
|
23
|
+
resources :page do
|
24
|
+
member do
|
25
|
+
post "lock"
|
26
|
+
post "post"
|
27
|
+
get "preview"
|
28
|
+
post "unlock"
|
29
|
+
post "unpost"
|
30
|
+
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
collection do
|
33
|
+
post "preview_content"
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cartoonist-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
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-
|
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: &
|
16
|
+
requirement: &13672880 !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.9
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13672880
|
25
25
|
description: This core plugin for Cartoonist adds arbitrary pages.
|
26
26
|
email: reasonnumber@gmail.com
|
27
27
|
executables: []
|
@@ -29,16 +29,16 @@ extensions: []
|
|
29
29
|
extra_rdoc_files: []
|
30
30
|
files:
|
31
31
|
- .gitignore
|
32
|
-
- app/controllers/
|
32
|
+
- app/controllers/admin/page_controller.rb
|
33
33
|
- app/controllers/page_controller.rb
|
34
|
-
- app/helpers/
|
34
|
+
- app/helpers/admin/page_helper.rb
|
35
35
|
- app/models/page.rb
|
36
|
+
- app/views/admin/page/edit.html.erb
|
37
|
+
- app/views/admin/page/index.html.erb
|
38
|
+
- app/views/admin/page/new.html.erb
|
39
|
+
- app/views/layouts/admin/page.html.erb
|
36
40
|
- app/views/layouts/page.html.erb
|
37
|
-
- app/views/layouts/page_admin.html.erb
|
38
41
|
- app/views/page/show.html.erb
|
39
|
-
- app/views/page_admin/edit.html.erb
|
40
|
-
- app/views/page_admin/index.html.erb
|
41
|
-
- app/views/page_admin/new.html.erb
|
42
42
|
- cartoonist-pages.gemspec
|
43
43
|
- config/locales/en.yml
|
44
44
|
- db/migrate/20120316072549_create_pages.rb
|