cartoonist-suggestions 0.0.13
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.
- data/app/controllers/admin/suggestions_controller.rb +19 -0
- data/app/controllers/suggestions_controller.rb +14 -0
- data/app/models/suggestion.rb +67 -0
- data/app/views/admin/suggestions/index.html.erb +19 -0
- data/app/views/admin/suggestions/show.html.erb +21 -0
- data/app/views/layouts/admin/suggestions.html.erb +3 -0
- data/app/views/layouts/suggestions.html.erb +15 -0
- data/app/views/suggestions/new.html.erb +28 -0
- data/cartoonist-suggestions.gemspec +15 -0
- data/config/locales/en.yml +33 -0
- data/db/migrate/20120911075843_create_suggestions.rb +13 -0
- data/lib/cartoonist-suggestions/engine.rb +34 -0
- data/lib/cartoonist-suggestions/version.rb +9 -0
- data/lib/cartoonist-suggestions.rb +4 -0
- metadata +69 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
class Admin::SuggestionsController < AdminCartoonistController
|
2
|
+
def index
|
3
|
+
@suggestions = Suggestion.shown.reverse_chronological
|
4
|
+
end
|
5
|
+
|
6
|
+
def toggle
|
7
|
+
Suggestion.toggle! params
|
8
|
+
|
9
|
+
if params[:id].present?
|
10
|
+
redirect_to "/admin/suggestions/#{params[:id]}"
|
11
|
+
else
|
12
|
+
redirect_to "/admin/suggestions"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def show
|
17
|
+
@suggestion = Suggestion.find params[:id].to_i
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class SuggestionsController < CartoonistController
|
2
|
+
skip_before_filter :verify_authenticity_token, :only => [:create]
|
3
|
+
|
4
|
+
def create
|
5
|
+
Suggestion.create_suggestion request.remote_ip, params
|
6
|
+
redirect_to "/"
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
cache_page_as "suggestions/new.#{cache_type}.html" do
|
11
|
+
render
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class Suggestion < ActiveRecord::Base
|
2
|
+
include ActionView::Helpers::TextHelper
|
3
|
+
|
4
|
+
def formatted_created_at
|
5
|
+
created_at.localtime.strftime "%-m/%-d/%Y at %-l:%M %P"
|
6
|
+
end
|
7
|
+
|
8
|
+
def shown?
|
9
|
+
!hidden
|
10
|
+
end
|
11
|
+
|
12
|
+
def hidden?
|
13
|
+
hidden
|
14
|
+
end
|
15
|
+
|
16
|
+
def toggle!
|
17
|
+
self.hidden = !hidden
|
18
|
+
save!
|
19
|
+
end
|
20
|
+
|
21
|
+
def truncated_content
|
22
|
+
truncate content, :length => 256
|
23
|
+
end
|
24
|
+
|
25
|
+
def description
|
26
|
+
"#{I18n.t "suggestion"}: #{truncated_content}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def search_url
|
30
|
+
"/admin/suggestions/#{id}"
|
31
|
+
end
|
32
|
+
|
33
|
+
class << self
|
34
|
+
def search(query)
|
35
|
+
reverse_chronological.shown.where "LOWER(name) LIKE :query OR LOWER(email) LIKE :query OR LOWER(ip) LIKE :query OR LOWER(content) LIKE :query", :query => "%#{query.downcase}%"
|
36
|
+
end
|
37
|
+
|
38
|
+
def toggle!(params)
|
39
|
+
if params[:id].present?
|
40
|
+
find(params[:id].to_i).toggle!
|
41
|
+
elsif params[:ids].present?
|
42
|
+
where(:id => params[:ids].map(&:to_i)).each &:toggle!
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_suggestion(ip, params)
|
47
|
+
return nil unless params[:content].present?
|
48
|
+
create :name => params[:name], :email => params[:email], :ip => ip, :content => params[:content]
|
49
|
+
end
|
50
|
+
|
51
|
+
def hidden
|
52
|
+
where :hidden => true
|
53
|
+
end
|
54
|
+
|
55
|
+
def shown
|
56
|
+
where :hidden => false
|
57
|
+
end
|
58
|
+
|
59
|
+
def chronological
|
60
|
+
order "created_at ASC"
|
61
|
+
end
|
62
|
+
|
63
|
+
def reverse_chronological
|
64
|
+
order "created_at DESC"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h2><%= t "admin.suggestions.index.shown" %></h2>
|
2
|
+
|
3
|
+
<%= form_tag "/admin/suggestions/toggle", :method => :post do %>
|
4
|
+
<ul>
|
5
|
+
<% @suggestions.each do |suggestion| %>
|
6
|
+
<li>
|
7
|
+
<label>
|
8
|
+
<input type="checkbox" name="ids[]" value="<%= suggestion.id %>" />
|
9
|
+
<%= suggestion.formatted_created_at %>:
|
10
|
+
<%= suggestion.truncated_content %><br />
|
11
|
+
<%= t "admin.suggestions.index.byline", :name => truncate(suggestion.name, :length => 32) %>
|
12
|
+
</label>
|
13
|
+
<a href="/admin/suggestions/<%= suggestion.id %>"><%= t "admin.suggestions.index.show" %></a>
|
14
|
+
</li>
|
15
|
+
<% end %>
|
16
|
+
</ul>
|
17
|
+
|
18
|
+
<input type="submit" value="<%= t "admin.suggestions.index.hide" %>" />
|
19
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= form_tag "/admin/suggestions/#{@suggestion.id}/toggle", :method => :post do %>
|
2
|
+
<% if @suggestion.shown? %>
|
3
|
+
<input type="submit" value="<%= t "admin.suggestions.show.hide" %>" />
|
4
|
+
<% else %>
|
5
|
+
<input type="submit" value="<%= t "admin.suggestions.show.show" %>" />
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<p>
|
10
|
+
<%= t "admin.suggestions.show.name", :name => @suggestion.name %><br />
|
11
|
+
<%= t "admin.suggestions.show.email", :email => @suggestion.email %><br />
|
12
|
+
<%= t "admin.suggestions.show.ip", :ip => @suggestion.ip %>
|
13
|
+
</p>
|
14
|
+
|
15
|
+
<p>
|
16
|
+
<%= t "admin.suggestions.show.date", :date => @suggestion.formatted_created_at %>
|
17
|
+
</p>
|
18
|
+
|
19
|
+
<p>
|
20
|
+
<%= t "admin.suggestions.show.content", :content => @suggestion.content %>
|
21
|
+
</p>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% content_for :content_class, "suggestion-content" %>
|
2
|
+
|
3
|
+
<% content_for :content do %>
|
4
|
+
<div class="suggestion-page">
|
5
|
+
<%= yield %>
|
6
|
+
</div>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% content_for :admin_content do %>
|
10
|
+
<% if preview? %>
|
11
|
+
<p><a href="/admin/main">admin</a></p>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= render :template => "layouts/cartoonist" %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<% content_for :title, t("suggestions.new.title") %>
|
2
|
+
|
3
|
+
<%= form_tag "/suggestions", :method => :post, :authenticity_token => false, :class => "suggestion-box" do %>
|
4
|
+
<p>
|
5
|
+
<label class="optional">
|
6
|
+
<span class="text"><%= t "suggestions.new.name" %></span>
|
7
|
+
<input type="text" name="name" />
|
8
|
+
</label>
|
9
|
+
</p>
|
10
|
+
|
11
|
+
<p>
|
12
|
+
<label class="optional">
|
13
|
+
<span class="text"><%= t "suggestions.new.email" %></span>
|
14
|
+
<input type="text" name="email" />
|
15
|
+
</label>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<label class="required">
|
20
|
+
<span class="text"><%= t "suggestions.new.suggestion" %></span>
|
21
|
+
<textarea name="content"></textarea>
|
22
|
+
</label>
|
23
|
+
</p>
|
24
|
+
|
25
|
+
<p>
|
26
|
+
<input type="submit" class="submit" value="<%= t "suggestions.new.submit" %>" />
|
27
|
+
</p>
|
28
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
raise "Cannot find version file!" unless File.exists?(File.join(File.dirname(__FILE__), "../CARTOONIST_VERSION"))
|
3
|
+
cartoonist_version = File.read(File.join(File.dirname(__FILE__), "../CARTOONIST_VERSION")).strip
|
4
|
+
s.name = "cartoonist-suggestions"
|
5
|
+
s.version = cartoonist_version
|
6
|
+
s.date = Time.now.strftime "%Y-%m-%d"
|
7
|
+
s.summary = "Cartoonist Suggestions"
|
8
|
+
s.description = "Plugin for community suggestion feedback."
|
9
|
+
s.authors = ["Mike Virata-Stone"]
|
10
|
+
s.email = "reasonnumber@gmail.com"
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.homepage = "http://reasonnumber.com/cartoonist"
|
14
|
+
s.add_dependency "cartoonist", cartoonist_version
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
en:
|
2
|
+
admin:
|
3
|
+
layout:
|
4
|
+
tab:
|
5
|
+
suggestions: Suggestions
|
6
|
+
suggestions:
|
7
|
+
index:
|
8
|
+
byline: from %{name}
|
9
|
+
hide: hide
|
10
|
+
show: (show)
|
11
|
+
shown: Shown
|
12
|
+
layout:
|
13
|
+
section: Suggestions
|
14
|
+
show:
|
15
|
+
content: "Suggestion: %{content}"
|
16
|
+
date: "Date: %{date}"
|
17
|
+
email: "Email: %{email}"
|
18
|
+
hide: hide
|
19
|
+
ip: "(ip: %{ip})"
|
20
|
+
name: "From: %{name}"
|
21
|
+
show: show
|
22
|
+
cartoonist:
|
23
|
+
layout:
|
24
|
+
navigation:
|
25
|
+
suggest: Suggest
|
26
|
+
suggestion: Suggestion
|
27
|
+
suggestions:
|
28
|
+
new:
|
29
|
+
email: Email
|
30
|
+
name: Name
|
31
|
+
submit: Submit
|
32
|
+
suggestion: Suggestion
|
33
|
+
title: Make a Suggestion
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateSuggestions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :suggestions do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :email
|
6
|
+
t.string :ip
|
7
|
+
t.text :content, :null => false
|
8
|
+
t.text :options
|
9
|
+
t.boolean :hidden, :null => false, :default => false
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# TODO: Searchables... perhaps as a mixin... lcase(blah) like lcase(?)
|
2
|
+
# Maybe make everything mixin, and use things like Cartoonist.register "MyEntity"
|
3
|
+
module CartoonistSuggestions
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
Cartoonist::Navigation::Link.add :url => "/suggestions/new", :class => "suggest", :label => "cartoonist.layout.navigation.suggest", :order => 3
|
6
|
+
Cartoonist::Admin::Tab.add :suggestions, :url => "/admin/suggestions"
|
7
|
+
Cartoonist::Migration.add_for self
|
8
|
+
Cartoonist::Searchable.add "Suggestion"
|
9
|
+
|
10
|
+
Cartoonist::Backup.for :suggestions do
|
11
|
+
Suggestion.order(:id)
|
12
|
+
end
|
13
|
+
|
14
|
+
Cartoonist::Sitemap.add do
|
15
|
+
[SitemapEntry.new("/suggestions/new", :yearly, "0.2")]
|
16
|
+
end
|
17
|
+
|
18
|
+
Cartoonist::Routes.add do
|
19
|
+
resources :suggestions, :only => [:new, :create]
|
20
|
+
|
21
|
+
namespace :admin do
|
22
|
+
resources :suggestions, :only => [:index, :show] do
|
23
|
+
collection do
|
24
|
+
post :toggle
|
25
|
+
end
|
26
|
+
|
27
|
+
member do
|
28
|
+
post :toggle
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cartoonist-suggestions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.13
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Virata-Stone
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cartoonist
|
16
|
+
requirement: &5799280 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - =
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.13
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *5799280
|
25
|
+
description: Plugin for community suggestion feedback.
|
26
|
+
email: reasonnumber@gmail.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files: []
|
30
|
+
files:
|
31
|
+
- app/controllers/admin/suggestions_controller.rb
|
32
|
+
- app/controllers/suggestions_controller.rb
|
33
|
+
- app/models/suggestion.rb
|
34
|
+
- app/views/admin/suggestions/index.html.erb
|
35
|
+
- app/views/admin/suggestions/show.html.erb
|
36
|
+
- app/views/layouts/admin/suggestions.html.erb
|
37
|
+
- app/views/layouts/suggestions.html.erb
|
38
|
+
- app/views/suggestions/new.html.erb
|
39
|
+
- cartoonist-suggestions.gemspec
|
40
|
+
- config/locales/en.yml
|
41
|
+
- db/migrate/20120911075843_create_suggestions.rb
|
42
|
+
- lib/cartoonist-suggestions.rb
|
43
|
+
- lib/cartoonist-suggestions/engine.rb
|
44
|
+
- lib/cartoonist-suggestions/version.rb
|
45
|
+
homepage: http://reasonnumber.com/cartoonist
|
46
|
+
licenses: []
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.17
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Cartoonist Suggestions
|
69
|
+
test_files: []
|