cartoonist 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,4 @@
1
- class Admin::AccountsController < CartoonistController
2
- before_filter :ensure_ssl!
3
- before_filter :check_admin!
4
-
1
+ class Admin::AccountsController < AdminCartoonistController
5
2
  def index
6
3
  @users = User.order(:name).all
7
4
  end
@@ -1,6 +1,4 @@
1
- class Admin::CacheController < CartoonistController
2
- before_filter :ensure_ssl!
3
- before_filter :check_admin!
1
+ class Admin::CacheController < AdminCartoonistController
4
2
  layout "general_admin"
5
3
 
6
4
  def index
@@ -0,0 +1,7 @@
1
+ class Admin::SearchController < AdminCartoonistController
2
+ layout "general_admin"
3
+
4
+ def index
5
+ @search = Search.query params
6
+ end
7
+ end
@@ -1,6 +1,5 @@
1
- class Admin::SettingsController < CartoonistController
2
- before_filter :ensure_ssl!
3
- before_filter :check_admin!, :except => [:initial_setup, :save_initial_setup]
1
+ class Admin::SettingsController < AdminCartoonistController
2
+ skip_before_filter :check_admin!, :only => [:initial_setup, :save_initial_setup]
4
3
 
5
4
  def index
6
5
  redirect_to "/admin/settings/general"
@@ -1,6 +1,4 @@
1
- class Admin::StaticCacheController < CartoonistController
2
- before_filter :ensure_ssl!
3
- before_filter :check_admin!
1
+ class Admin::StaticCacheController < AdminCartoonistController
4
2
  layout "general_admin"
5
3
 
6
4
  def index
@@ -0,0 +1,34 @@
1
+ class AdminCartoonistController < CartoonistController
2
+ before_filter :ensure_ssl!
3
+ before_filter :check_admin!
4
+
5
+ private
6
+ def ensure_ssl!
7
+ return unless Rails.env.production?
8
+ redirect_to "https://#{request.host_with_port}#{request.fullpath}" unless request.ssl?
9
+ end
10
+
11
+ def check_admin!
12
+ if initial_setup_required?
13
+ redirect_to "/admin/settings/initial_setup"
14
+ else
15
+ authenticate_user!
16
+ end
17
+ end
18
+
19
+ def initial_setup_required?
20
+ User.count == 0
21
+ end
22
+
23
+ def after_sign_out_path_for(resource_or_scope)
24
+ "/admin"
25
+ end
26
+
27
+ def after_sign_in_path_for(resource_or_scope)
28
+ "/admin"
29
+ end
30
+
31
+ def preview!
32
+ @for_preview = true
33
+ end
34
+ end
@@ -1,6 +1,6 @@
1
- class AdminController < CartoonistController
2
- before_filter :ensure_ssl!, :except => [:cron]
3
- before_filter :check_admin!, :except => [:cron]
1
+ class AdminController < AdminCartoonistController
2
+ skip_before_filter :ensure_ssl!, :only => [:cron]
3
+ skip_before_filter :check_admin!, :only => [:cron]
4
4
 
5
5
  def show
6
6
  redirect_to "/admin/main"
@@ -4,39 +4,14 @@ class CartoonistController < ActionController::Base
4
4
  before_filter :check_mobile
5
5
 
6
6
  private
7
- def initial_setup_required?
8
- User.count == 0
9
- end
10
-
11
- def ensure_ssl!
12
- return unless Rails.env.production?
13
- redirect_to "https://#{request.host_with_port}#{request.fullpath}" unless request.ssl?
14
- end
15
-
16
- def check_admin!
17
- if initial_setup_required?
18
- redirect_to "/admin/settings/initial_setup"
19
- else
20
- authenticate_user!
21
- end
22
- end
23
-
24
- def after_sign_out_path_for(resource_or_scope)
25
- "/admin"
26
- end
27
-
28
- def after_sign_in_path_for(resource_or_scope)
29
- "/admin"
7
+ def handle_unverified_request
8
+ raise ActionController::InvalidAuthenticityToken.new
30
9
  end
31
10
 
32
11
  def check_mobile
33
12
  @mobile = (request.subdomain == "m") || params[:mobile]
34
13
  end
35
14
 
36
- def preview!
37
- @for_preview = true
38
- end
39
-
40
15
  def cache_type
41
16
  if @mobile
42
17
  "m"
data/app/models/entity.rb CHANGED
@@ -43,6 +43,10 @@ module Entity
43
43
  self.class.entity_edit_url.call self if self.class.entity_edit_url
44
44
  end
45
45
 
46
+ def search_url
47
+ entity_relative_preview_url
48
+ end
49
+
46
50
  def self.included(base)
47
51
  base.extend ClassMethods
48
52
 
@@ -0,0 +1,63 @@
1
+ class Search
2
+ attr_reader :query
3
+
4
+ def initialize(query)
5
+ @query = query
6
+ end
7
+
8
+ def results
9
+ return [] if @query.blank?
10
+ @results ||= entity_results + searchable_results
11
+ end
12
+
13
+ private
14
+ def entity_results
15
+ Cartoonist::Entity.all.map do |entity|
16
+ if entity.respond_to? :search
17
+ entity.search(@query).map { |x| Search::EntityResult.new x }
18
+ else
19
+ []
20
+ end
21
+ end.flatten
22
+ end
23
+
24
+ def searchable_results
25
+ Cartoonist::Searchable.all.map do |searchable|
26
+ searchable.search(@query).map { |x| Search::SearchableResult.new x }
27
+ end.flatten
28
+ end
29
+
30
+ class << self
31
+ def query(params)
32
+ new params[:q]
33
+ end
34
+ end
35
+
36
+ class EntityResult
37
+ include BelongsToEntity
38
+
39
+ def initialize(entity)
40
+ @entity = entity
41
+ end
42
+
43
+ def url
44
+ entity.search_url
45
+ end
46
+ end
47
+
48
+ class SearchableResult
49
+ attr_reader :searchable
50
+
51
+ def initialize(searchable)
52
+ @searchable = searchable
53
+ end
54
+
55
+ def description
56
+ searchable.description
57
+ end
58
+
59
+ def url
60
+ searchable.search_url
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,16 @@
1
+ <form>
2
+ <input type="text" name="q" value="<%= params[:q] %>" />
3
+ <input type="submit" value="<%= t "search.index.submit" %>" />
4
+ </form>
5
+
6
+ <% if @search.query.present? %>
7
+ <h2>Search results for '<em><%= @search.query %></em>'</h2>
8
+
9
+ <ul>
10
+ <% @search.results.each do |result| %>
11
+ <li>
12
+ <a href="<%= result.url %>"><%= result.description %><a/>
13
+ </li>
14
+ <% end %>
15
+ </ul>
16
+ <% end %>
@@ -3,9 +3,11 @@
3
3
  <head>
4
4
  <title><%= yield(:title) || Setting[:site_name] %></title>
5
5
  <%= stylesheet_link_tag "admin.css" %>
6
+ <%= stylesheet_link_tag controller_path if Rails.application.assets.find_asset("#{controller_path}.css").present? %>
6
7
  <%= csrf_meta_tags %>
7
8
  <link rel="icon" href="http://<%= Setting[:domain] %><%= asset_path Cartoonist::Theme.favicon %>" type="image/x-icon" />
8
9
  <link rel="shortcut icon" href="http://<%= Setting[:domain] %><%= asset_path Cartoonist::Theme.favicon %>" type="image/x-icon" />
10
+ <%= javascript_include_tag controller_path if Rails.application.assets.find_asset("#{controller_path}.js").present? %>
9
11
  </head>
10
12
  <body>
11
13
  <%= form_tag "/users/sign_out", :method => :delete do %>
@@ -61,9 +61,6 @@
61
61
  <% if @disqus_enabled %>
62
62
  <div class="comments-container">
63
63
  <div id="disqus_thread">
64
- <% if @disqus_options[:count_link] %>
65
- <a id="disqus_comments" href="#disqus_thread" data-disqus-identifier="/<%= @disqus_options[:path] %>"></a>
66
- <% end %>
67
64
  </div>
68
65
  <noscript>
69
66
  <%= t "cartoonist.layout.disqus.noscript_pre_link" %><a href="http://disqus.com/?ref_noscript"><%= t "cartoonist.layout.disqus.noscript_link" %></a><%= t "cartoonist.layout.disqus.noscript_post_link" %>
@@ -102,29 +99,11 @@
102
99
  var disqus_category_id = "<%= j @disqus_options[:category].to_s %>";
103
100
  var disqus_identifier = "/<%= j @disqus_options[:path] %>";
104
101
  var disqus_url = "http://<%= j Setting[:domain] %>/<%= j @disqus_options[:path] %>";
105
- <% if @disqus_options[:count_link] %>
106
- (function () {
107
- var s = document.createElement('script'); s.async = true;
108
- s.type = 'text/javascript';
109
- s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
110
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(s);
111
- }());
112
-
113
- var comments = document.getElementById("disqus_comments");
114
- comments.onclick = function() {
115
- document.getElementById("disqus_thread").removeChild(comments);
116
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
117
- dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
118
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
119
- return false;
120
- };
121
- <% else %>
122
- (function() {
123
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
124
- dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
125
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
126
- })();
127
- <% end %>
102
+ (function() {
103
+ var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
104
+ dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
105
+ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
106
+ })();
128
107
  </script>
129
108
  <% end %>
130
109
  <% if Cartoonist::Asset.included_js? %>
@@ -3,6 +3,7 @@
3
3
  <a class="subtab" href="/admin/settings"><%= t "admin.general.layout.settings" %></a>
4
4
  <a class="subtab" href="/admin/cache"><%= t "admin.general.layout.cache" %></a>
5
5
  <a class="subtab" href="/admin/static_cache"><%= t "admin.general.layout.static_cache" %></a>
6
+ <a class="subtab" href="/admin/search"><%= t "admin.general.layout.search" %></a>
6
7
  <% end %>
7
8
 
8
9
  <% content_for :page_title, t("admin.general.layout.section") %>
data/cartoonist.gemspec CHANGED
@@ -10,10 +10,10 @@ Gem::Specification.new do |s|
10
10
  s.files = `git ls-files`.split("\n")
11
11
  s.require_paths = ["lib"]
12
12
  s.homepage = "http://reasonnumber.com/cartoonist"
13
- s.add_dependency "devise", "~> 2.0.0"
14
- s.add_dependency "jquery-rails", "~> 2.0.0"
15
- s.add_dependency "railties", "~> 3.2.0"
16
- s.add_dependency "redcarpet", "~> 2.1.0"
17
- s.add_dependency "rubyzip", "~> 0.9.0"
18
- s.add_dependency "minitar", "~> 0.5.0"
13
+ s.add_dependency "devise", "~> 2.1.2"
14
+ s.add_dependency "jquery-rails", "~> 2.1.3"
15
+ s.add_dependency "railties", "~> 3.2.8"
16
+ s.add_dependency "redcarpet", "~> 2.2.2"
17
+ s.add_dependency "rubyzip", "~> 0.9.9"
18
+ s.add_dependency "minitar", "~> 0.5.3"
19
19
  end
@@ -40,6 +40,7 @@ en:
40
40
  layout:
41
41
  actions: Actions
42
42
  cache: Cache
43
+ search: Search
43
44
  section: General
44
45
  settings: Settings
45
46
  static_cache: Static Cache
@@ -72,6 +73,9 @@ en:
72
73
  page: Page
73
74
  www: www
74
75
  www_tmp: www tmp
76
+ search:
77
+ index:
78
+ submit: Search
75
79
  settings:
76
80
  initial_setup:
77
81
  confirm_password: "Confirmation: "
@@ -13,9 +13,6 @@ module Cartoonist
13
13
  # Configure the class responsible to send e-mails.
14
14
  # devise_config.mailer = "Devise::Mailer"
15
15
 
16
- # Automatically apply schema changes in tableless databases
17
- devise_config.apply_schema = false
18
-
19
16
  # ==> ORM configuration
20
17
  # Load and configure the ORM. Supports :active_record (default) and
21
18
  # :mongoid (bson_ext recommended) by default. Other ORMs may be
@@ -115,10 +112,6 @@ module Cartoonist
115
112
  # If true, extends the user's remember period when remembered via cookie.
116
113
  # devise_config.extend_remember_period = false
117
114
 
118
- # If true, uses the password salt as remember token. This should be turned
119
- # to false if you are not using database authenticatable.
120
- devise_config.use_salt_as_remember_token = true
121
-
122
115
  # Options to be passed to the created cookie. For instance, you can set
123
116
  # :secure => true in order to force SSL only cookies.
124
117
  # devise_config.cookie_options = {}
@@ -326,7 +319,7 @@ module Cartoonist
326
319
  match "sitemap" => "site#sitemap", :defaults => { :format => "xml" }
327
320
  match "robots" => "site#robots", :defaults => { :format => "text" }
328
321
 
329
- resource :admin, :controller => :admin do
322
+ resource :admin, :controller => :admin, :only => [:show] do
330
323
  collection do
331
324
  get "cron"
332
325
  get "backup"
@@ -338,9 +331,9 @@ module Cartoonist
338
331
  devise_for :users
339
332
 
340
333
  namespace :admin do
341
- resources :accounts
334
+ resources :accounts, :only => [:create, :destroy, :edit, :index, :show, :update]
342
335
 
343
- resources :cache, :constraints => { :id => /.*/ } do
336
+ resources :cache, :constraints => { :id => /.*/ }, :only => [:destroy, :index] do
344
337
  collection do
345
338
  post "expire_www"
346
339
  post "expire_m"
@@ -349,18 +342,20 @@ module Cartoonist
349
342
  end
350
343
  end
351
344
 
352
- resources :static_cache, :constraints => { :id => /.*/ } do
345
+ resources :static_cache, :constraints => { :id => /.*/ }, :only => [:destroy, :index] do
353
346
  collection do
354
347
  post "expire_all"
355
348
  end
356
349
  end
357
350
 
358
- resources :settings do
351
+ resources :settings, :only => [:index, :show, :update] do
359
352
  collection do
360
353
  get "initial_setup"
361
354
  post "save_initial_setup"
362
355
  end
363
356
  end
357
+
358
+ resources :search, :only => [:index]
364
359
  end
365
360
  end
366
361
  end
@@ -0,0 +1,9 @@
1
+ module Cartoonist
2
+ class Version
3
+ class << self
4
+ def to_s
5
+ "0.0.13"
6
+ end
7
+ end
8
+ end
9
+ end
data/lib/cartoonist.rb CHANGED
@@ -263,6 +263,20 @@ module Cartoonist
263
263
  end
264
264
  end
265
265
 
266
+ class Searchable
267
+ @@all = []
268
+
269
+ class << self
270
+ def all
271
+ @@all.map &:constantize
272
+ end
273
+
274
+ def add(model_name)
275
+ @@all << model_name
276
+ end
277
+ end
278
+ end
279
+
266
280
  class Sitemap
267
281
  @@all = []
268
282
 
@@ -318,4 +332,5 @@ module Cartoonist
318
332
  end
319
333
 
320
334
  require "cartoonist/engine"
335
+ require "cartoonist/version"
321
336
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cartoonist
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,74 +9,74 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-05 00:00:00.000000000 Z
12
+ date: 2012-11-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
16
- requirement: &19441520 !ruby/object:Gem::Requirement
16
+ requirement: &14316380 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 2.0.0
21
+ version: 2.1.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19441520
24
+ version_requirements: *14316380
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &19440720 !ruby/object:Gem::Requirement
27
+ requirement: &14315100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 2.0.0
32
+ version: 2.1.3
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *19440720
35
+ version_requirements: *14315100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: railties
38
- requirement: &19439640 !ruby/object:Gem::Requirement
38
+ requirement: &14313640 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 3.2.0
43
+ version: 3.2.8
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *19439640
46
+ version_requirements: *14313640
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: redcarpet
49
- requirement: &19438680 !ruby/object:Gem::Requirement
49
+ requirement: &14311140 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.0
54
+ version: 2.2.2
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *19438680
57
+ version_requirements: *14311140
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rubyzip
60
- requirement: &19437180 !ruby/object:Gem::Requirement
60
+ requirement: &14310300 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
64
64
  - !ruby/object:Gem::Version
65
- version: 0.9.0
65
+ version: 0.9.9
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *19437180
68
+ version_requirements: *14310300
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitar
71
- requirement: &19436380 !ruby/object:Gem::Requirement
71
+ requirement: &14309620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
75
75
  - !ruby/object:Gem::Version
76
- version: 0.5.0
76
+ version: 0.5.3
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *19436380
79
+ version_requirements: *14309620
80
80
  description: This provides the main functionality and plugin api for Cartoonist.
81
81
  email: reasonnumber@gmail.com
82
82
  executables: []
@@ -87,8 +87,10 @@ files:
87
87
  - app/assets/stylesheets/admin.css.scss
88
88
  - app/controllers/admin/accounts_controller.rb
89
89
  - app/controllers/admin/cache_controller.rb
90
+ - app/controllers/admin/search_controller.rb
90
91
  - app/controllers/admin/settings_controller.rb
91
92
  - app/controllers/admin/static_cache_controller.rb
93
+ - app/controllers/admin_cartoonist_controller.rb
92
94
  - app/controllers/admin_controller.rb
93
95
  - app/controllers/cartoonist_controller.rb
94
96
  - app/controllers/site_controller.rb
@@ -102,6 +104,7 @@ files:
102
104
  - app/models/markdown.rb
103
105
  - app/models/page_cache.rb
104
106
  - app/models/postable.rb
107
+ - app/models/search.rb
105
108
  - app/models/setting.rb
106
109
  - app/models/simple_template.rb
107
110
  - app/models/sitemap_entry.rb
@@ -113,6 +116,7 @@ files:
113
116
  - app/views/admin/accounts/show.html.erb
114
117
  - app/views/admin/cache/index.html.erb
115
118
  - app/views/admin/main.html.erb
119
+ - app/views/admin/search/index.html.erb
116
120
  - app/views/admin/settings/initial_setup.html.erb
117
121
  - app/views/admin/settings/show.html.erb
118
122
  - app/views/admin/static_cache/index.html.erb
@@ -135,6 +139,7 @@ files:
135
139
  - db/migrate/20120524032959_add_extension_to_database_files.rb
136
140
  - lib/cartoonist.rb
137
141
  - lib/cartoonist/engine.rb
142
+ - lib/cartoonist/version.rb
138
143
  - public/errors/404.html
139
144
  - public/errors/422.html
140
145
  - public/errors/500.html