sunrise-feedbacks 0.1.0
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/README.rdoc +26 -0
- data/Rakefile +46 -0
- data/app/controllers/feedbacks_controller.rb +17 -0
- data/app/controllers/manage/feedback_answers_controller.rb +22 -0
- data/app/controllers/manage/feedbacks_controller.rb +37 -0
- data/app/helpers/manage/feedbacks_helper.rb +9 -0
- data/app/views/feedbacks/_form.html.erb +22 -0
- data/app/views/feedbacks/new.html.erb +7 -0
- data/app/views/manage/feedback_answers/_answer.html.erb +17 -0
- data/app/views/manage/feedback_answers/_form.html.erb +17 -0
- data/app/views/manage/feedback_answers/create.js.erb +8 -0
- data/app/views/manage/feedback_answers/destroy.js.erb +1 -0
- data/app/views/manage/feedbacks/_feedback.html.erb +44 -0
- data/app/views/manage/feedbacks/_form.html.erb +15 -0
- data/app/views/manage/feedbacks/_message.html.erb +19 -0
- data/app/views/manage/feedbacks/_model_filter.html.erb +36 -0
- data/app/views/manage/feedbacks/edit.html.erb +6 -0
- data/app/views/manage/feedbacks/index.html.erb +30 -0
- data/app/views/manage/feedbacks/new.html.erb +6 -0
- data/app/views/manage/feedbacks/show.html.erb +36 -0
- data/config/locales/ru.yml +25 -0
- data/config/locales/uk.yml +29 -0
- data/config/routes.rb +8 -0
- data/lib/generators/sunrise/feedbacks/USAGE +11 -0
- data/lib/generators/sunrise/feedbacks/install_generator.rb +36 -0
- data/lib/generators/sunrise/feedbacks/templates/create_feedback_answers.rb +20 -0
- data/lib/generators/sunrise/feedbacks/templates/create_feedback_messages.rb +25 -0
- data/lib/generators/sunrise/feedbacks/templates/feedback_answer.rb +9 -0
- data/lib/generators/sunrise/feedbacks/templates/feedback_message.rb +27 -0
- data/lib/sunrise-feedbacks.rb +2 -0
- data/lib/sunrise/feedbacks.rb +20 -0
- data/lib/sunrise/feedbacks/author.rb +21 -0
- data/lib/sunrise/feedbacks/engine.rb +19 -0
- data/lib/sunrise/feedbacks/version.rb +5 -0
- data/lib/sunrise/models/feedback_answer.rb +26 -0
- data/lib/sunrise/models/feedback_message.rb +60 -0
- metadata +116 -0
data/README.rdoc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
= Sunrise Feedbacks
|
2
|
+
|
3
|
+
== Install
|
4
|
+
|
5
|
+
rails generate sunrise:feedbacks:install
|
6
|
+
|
7
|
+
rake db:migrate
|
8
|
+
|
9
|
+
== Usage
|
10
|
+
|
11
|
+
=== Configuration
|
12
|
+
|
13
|
+
Sunrise::Feedbacks.setup do |config|
|
14
|
+
config.navigational_formats = [:html, :js]
|
15
|
+
config.siblings_keys = [:user_email]
|
16
|
+
end
|
17
|
+
|
18
|
+
=== ActiveRecord
|
19
|
+
|
20
|
+
class User < ActiveRecord::Base
|
21
|
+
include Sunrise::Feedbacks::Author
|
22
|
+
end
|
23
|
+
|
24
|
+
user.feedback_messages
|
25
|
+
|
26
|
+
Copyright (c) 2011 Aimbulance, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require File.join(File.dirname(__FILE__), 'lib', 'sunrise', 'feedbacks', 'version')
|
6
|
+
|
7
|
+
desc 'Default: run unit tests.'
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
desc 'Test the sunrise plugin.'
|
11
|
+
Rake::TestTask.new(:test) do |t|
|
12
|
+
t.libs << 'lib'
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
t.verbose = true
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Generate documentation for the sunrise plugin.'
|
19
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
20
|
+
rdoc.rdoc_dir = 'rdoc'
|
21
|
+
rdoc.title = 'Sunrise Feedbacks'
|
22
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
+
rdoc.rdoc_files.include('README')
|
24
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'jeweler'
|
29
|
+
Jeweler::Tasks.new do |s|
|
30
|
+
s.name = "sunrise-feedbacks"
|
31
|
+
s.version = Sunrise::Feedbacks::VERSION.dup
|
32
|
+
s.summary = "Rails CMS"
|
33
|
+
s.description = "Sunrise is a Aimbulance CMS"
|
34
|
+
s.email = "galeta.igor@gmail.com"
|
35
|
+
s.homepage = "https://github.com/galetahub/sunrise-feedbacks"
|
36
|
+
s.authors = ["Igor Galeta", "Pavlo Galeta"]
|
37
|
+
s.files = FileList["[A-Z]*", "{app,config,lib}/**/*"]
|
38
|
+
s.extra_rdoc_files = FileList["[A-Z]*"] - %w(Gemfile Rakefile)
|
39
|
+
|
40
|
+
s.add_dependency('sunrise-cms')
|
41
|
+
end
|
42
|
+
|
43
|
+
Jeweler::GemcutterTasks.new
|
44
|
+
rescue LoadError
|
45
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
46
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class FeedbacksController < ApplicationController
|
2
|
+
respond_to *Sunrise::Feedbacks.navigational_formats
|
3
|
+
|
4
|
+
def new
|
5
|
+
@feedback = FeedbackMessage.new
|
6
|
+
@feedback.author = current_user
|
7
|
+
respond_with(@feedback)
|
8
|
+
end
|
9
|
+
|
10
|
+
def create
|
11
|
+
@feedback = FeedbackMessage.new(params[:feedback])
|
12
|
+
@feedback.author = current_user
|
13
|
+
@feedback.save
|
14
|
+
|
15
|
+
respond_with(@feedback, :location => root_path)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Manage::FeedbackAnswersController < Manage::BaseController
|
2
|
+
inherit_resources
|
3
|
+
defaults :route_prefix => 'manage', :resource_class => FeedbackAnswer
|
4
|
+
|
5
|
+
load_and_authorize_resource :class => FeedbackAnswer
|
6
|
+
|
7
|
+
respond_to :js
|
8
|
+
|
9
|
+
def create
|
10
|
+
@feedback_answer = FeedbackAnswer.new(params[:feedback_answer])
|
11
|
+
@feedback_answer.author = current_user
|
12
|
+
create!{ manage_feedbacks_path }
|
13
|
+
end
|
14
|
+
|
15
|
+
def update
|
16
|
+
update!{ manage_feedbacks_path }
|
17
|
+
end
|
18
|
+
|
19
|
+
def destroy
|
20
|
+
destroy!{ manage_feedbacks_path }
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Manage::FeedbacksController < Manage::BaseController
|
2
|
+
inherit_resources
|
3
|
+
defaults :route_prefix => 'manage', :resource_class => FeedbackMessage
|
4
|
+
|
5
|
+
before_filter :make_filter, :only=>[:index]
|
6
|
+
|
7
|
+
load_and_authorize_resource :class => FeedbackMessage
|
8
|
+
|
9
|
+
def show
|
10
|
+
@feedbacks = @feedback.siblings
|
11
|
+
@feedback_answer = FeedbackAnswer.new
|
12
|
+
respond_with(@feedbacks)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
create!{ manage_feedbacks_path }
|
17
|
+
end
|
18
|
+
|
19
|
+
def update
|
20
|
+
update!{ manage_feedbacks_path }
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy
|
24
|
+
destroy!{ manage_feedbacks_path }
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def collection
|
30
|
+
@feedbacks = (@feedbacks || end_of_association_chain).merge(@search.scoped).page(params[:page])
|
31
|
+
end
|
32
|
+
|
33
|
+
def make_filter
|
34
|
+
@search = Sunrise::ModelFilter.new(FeedbackMessage, :attributes => [:user_email, :phone_number])
|
35
|
+
@search.update_attributes(params[:search])
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%= form_for feedback, :url => feedbacks_path, :as => :feedback do |f| %>
|
2
|
+
<div class="form-holder">
|
3
|
+
<%= f.label :user_name %>
|
4
|
+
<div class="input">
|
5
|
+
<div><%= f.text_field :user_name %></div>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<%= f.label :user_email %>
|
9
|
+
<div class="input">
|
10
|
+
<div><%= f.text_field :user_email %></div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<%= f.label :content %>
|
14
|
+
<div class="textarea">
|
15
|
+
<div><%= f.text_area :content %></div>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="buttons">
|
20
|
+
<%= f.submit t('sunrise.feedbacks.create') %>
|
21
|
+
</div>
|
22
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= content_tag(:div, :class => "white-row", :style => "margin-top:10px;", :id => dom_id(answer)) do %>
|
2
|
+
<div class="r-corn">
|
3
|
+
<div class="buttons" style="padding-top:0px;">
|
4
|
+
<div class="act-bl">
|
5
|
+
<%= link_to image_tag("manage/ico_del.gif", :title=>t('manage.delete')),
|
6
|
+
manage_feedback_answer_path(:id=>answer.id),
|
7
|
+
:method=>:delete,
|
8
|
+
:confirm=>t("manage.confirm_delete"),
|
9
|
+
:class=>"icons",
|
10
|
+
:remote => true %>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= answer.author.name %>:
|
15
|
+
<%= answer.content %>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div id="answer_form_block" style="padding-top:20px;display:none;">
|
2
|
+
<div class="edit-bl">
|
3
|
+
<div class="bot-bg">
|
4
|
+
<%= manage_form_for @feedback_answer, :remote => true do |f| %>
|
5
|
+
<%= f.hidden_field :message_id %>
|
6
|
+
|
7
|
+
<div class="edit-cont">
|
8
|
+
<div class="inputs-bl">
|
9
|
+
<%= f.input :content, :input_html => { :cols => 70, :rows => 10 } %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<%= f.button :submit, :url => "#cancel" %>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
</div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if @feedback_answer.errors.empty? %>
|
2
|
+
$('#new_feedback_answer').get(0).reset();
|
3
|
+
$('#answer_form_block').hide();
|
4
|
+
$('#<%= dom_id(@feedback_answer.message) %>').replaceWith("<%= escape_javascript(render(:partial=>"manage/feedbacks/message", :object => @feedback_answer.message)) %>");
|
5
|
+
<% else %>
|
6
|
+
$('#answer_form_block').replaceWith("<%= escape_javascript(render(:partial=>"manage/feedback_answers/form")) %>")
|
7
|
+
$('#answer_form_block').show();
|
8
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#<%= dom_id(@feedback_answer) %>').remove();
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<%= content_tag(:div, :id=>dom_id(feedback), :class=>"dinamic-bl") do %>
|
2
|
+
<div class="act-bl" style="display:none;">
|
3
|
+
<%= link_to image_tag("manage/ico_edit.gif", :alt=>t('manage.edit'), :title=>t('manage.edit')), edit_manage_feedback_path(:id=>feedback.id), :class=>"icons" %>
|
4
|
+
|
5
|
+
<%= link_to image_tag("manage/ico_del.gif", :alt=>t('manage.delete'), :title=>t('manage.delete')), manage_feedback_path(:id=>feedback.id),
|
6
|
+
:method=>:delete, :confirm=>t("manage.confirm_delete"), :class=>"icons" %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="bot-bg">
|
10
|
+
<div class="dinamic-container">
|
11
|
+
<div class="right-data">
|
12
|
+
<div class="right-data-cont">
|
13
|
+
<div class="dinamic-inner">
|
14
|
+
<div class="r-block">
|
15
|
+
<div class="block-cont">
|
16
|
+
<%= link_to feedback.user_name, manage_feedback_path(:id=>feedback.id), :class=>"title" %>
|
17
|
+
|
18
|
+
<table border="0" width="100%" cellspacing="0" cellpadding="0" class="inf">
|
19
|
+
<tbody>
|
20
|
+
<tr>
|
21
|
+
<td class="left">Email:</td>
|
22
|
+
<td><%= mail_to feedback.user_email %></td>
|
23
|
+
</tr>
|
24
|
+
<tr>
|
25
|
+
<td class="left">Phone:</td>
|
26
|
+
<td><%= feedback.phone_number %></td>
|
27
|
+
</tr>
|
28
|
+
<tr>
|
29
|
+
<td class="left">Answers:</td>
|
30
|
+
<td><%= feedback.answers_count %></td>
|
31
|
+
</tr>
|
32
|
+
</tbody>
|
33
|
+
</table>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
<div class="left-data">
|
40
|
+
<span class="data"><%= raw I18n.l(feedback.created_at, :format=>"<span>%d/%m</span>%Y") %></span>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= manage_form_for @feedback, :as => :feedback do |f| %>
|
2
|
+
<div class="edit-cont">
|
3
|
+
<div class="inputs-bl">
|
4
|
+
<%= f.input :user_email %>
|
5
|
+
|
6
|
+
<%= f.input :user_name %>
|
7
|
+
|
8
|
+
<%= f.input :phone_number %>
|
9
|
+
|
10
|
+
<%= f.input :content %>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= f.button :submit %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<%= content_tag(:div, :class => "feedback_message", :id => dom_id(message), :style => "padding-top:10px;") do %>
|
2
|
+
<div class="edit-bl">
|
3
|
+
<div class="bot-bg">
|
4
|
+
<div class="buttons">
|
5
|
+
<div class="act-bl">
|
6
|
+
<%= link_to image_tag("manage/ico_down.gif", :title=>t('manage.feedbacks.answers.new')),
|
7
|
+
"#" + dom_id(message), :class => "icons answer" %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="block-title"><%= message.user_name %>:</div>
|
12
|
+
<div class="edit-cont">
|
13
|
+
<%= message.content %>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
|
18
|
+
<%= render :partial => 'manage/feedback_answers/answer', :collection => message.answers.includes(:author) %>
|
19
|
+
<% end %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<div class="bot-bg">
|
2
|
+
<div class="filt-bl">
|
3
|
+
<%= link_to_function t('manage.model_filter.title'), "Manage.toggle_element('block_filter')", :class=>"dark-arr" %>
|
4
|
+
|
5
|
+
<%= cookie_content_tag(:div, :id=>"block_filter", :class=>"filt") do %>
|
6
|
+
<%= form_for @search, :as => :search, :url=>manage_feedbacks_path, :html=>{:method=>:get, :id=>"form_filter"} do |f| %>
|
7
|
+
|
8
|
+
<%= f.label :phone_number, t('feedback_message.phone_number', :scope => [:activerecord, :attributes]) %>
|
9
|
+
<%= f.text_field :phone_number, :class=>"text" %>
|
10
|
+
|
11
|
+
<%= f.label :user_email, t('feedback_message.user_email', :scope => [:activerecord, :attributes]) %>
|
12
|
+
<%= f.text_field :user_email, :class=>"text" %>
|
13
|
+
|
14
|
+
<div class="buts">
|
15
|
+
<%= content_tag(:button, :value=>"search", :type=>"submit", :name=>"commit", :class=>"gr cupid-green") do %>
|
16
|
+
<%= t('manage.model_filter.search') %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= link_to t('manage.model_filter.clear'), manage_feedbacks_path, :class=>"erase" %>
|
20
|
+
</div>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
</div>
|
24
|
+
<div class="sort">
|
25
|
+
<label><%= t('manage.sort') %></label>
|
26
|
+
<div class="select-input"><%= link_to_function t("feedbacks.#{@search.order_column}_#{@search.order_type}", :scope => [:manage, :sort_columns], :default => :"#{@search.order_column}_#{@search.order_type}"), "SelectList.toggle(event)", :class=>"corn", :id=>'sort_select' %></div>
|
27
|
+
<div id='sort_select_list' class="select-list" style='display:none;'>
|
28
|
+
|
29
|
+
<%= link_to_sort(t('feedback_message.created_at_desc', :scope => [:manage, :sort_columns], :default => :created_at_desc), :name => "created_at", :order_type => 'desc') %>
|
30
|
+
<%= link_to_sort(t('feedback.created_at_asc', :scope => [:manage, :sort_columns], :default => :created_at_asc), :name => "created_at", :order_type => 'asc') %>
|
31
|
+
|
32
|
+
<%= link_to_sort(t('feedback_message.updated_at_desc', :scope => [:manage, :sort_columns], :default => :updated_at_desc), :name => "updated_at", :order_type => 'desc') %>
|
33
|
+
<%= link_to_sort(t('feedbacks.updated_at_asc', :scope => [:manage, :sort_columns], :default => :updated_at_asc), :name => "updated_at", :order_type => 'asc') %>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
</div>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<div class="duo-bl">
|
2
|
+
<div class="left-part">
|
3
|
+
<div class="content">
|
4
|
+
<div class="row-container">
|
5
|
+
<div class="white-row">
|
6
|
+
<div class="r-corn">
|
7
|
+
<%= link_to t('manage.menu.feedback_messages'), manage_feedbacks_path, :class=>"dark-text" %>
|
8
|
+
<div class="act-bl">
|
9
|
+
<%= link_to t('manage.add'), new_manage_feedback_path, :class=>"create" %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<div id="feedbacks" class="stage">
|
15
|
+
<%= render :partial=>"manage/feedbacks/feedback", :collection => @feedbacks %>
|
16
|
+
<%= paginate @feedbacks %>
|
17
|
+
</div>
|
18
|
+
<script type='text/javascript'>
|
19
|
+
$(document).ready(function(){
|
20
|
+
Manage.init_collection('feedbacks', 'dinamic-bl');
|
21
|
+
});
|
22
|
+
</script>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
<div class="right-part">
|
26
|
+
<div class="filter-right">
|
27
|
+
<%= render :partial => "manage/feedbacks/model_filter" %>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
</div>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<div class="buttons">
|
2
|
+
<div class="back-but-bl">
|
3
|
+
<%= link_to content_tag(:span, t('manage.menu.feedback_messages')), manage_feedbacks_path, :class=>"back" %>
|
4
|
+
</div>
|
5
|
+
|
6
|
+
<div class="act-bl">
|
7
|
+
<%= link_to image_tag("manage/ico_edit.gif", :title=>t('manage.edit')), edit_manage_feedback_path(:id=>@feedback.id), :class=>"icons" %>
|
8
|
+
|
9
|
+
<%= link_to image_tag("manage/ico_del.gif", :title=>t('manage.delete')), manage_feedback_path(:id=>@feedback.id), :method=>:delete, :confirm=>t("manage.confirm_delete"), :class=>"icons" %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
<%= render :partial => 'manage/feedbacks/message', :collection => @feedbacks %>
|
14
|
+
|
15
|
+
<%= render :partial => 'manage/feedback_answers/form' %>
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
$(document).ready(function(){
|
19
|
+
$('div.buttons a.answer').live('click', function(e){
|
20
|
+
var message_id = $(this).attr('href').replace('#feedback_message_', '');
|
21
|
+
$('#answer_form_block').show();
|
22
|
+
$('#feedback_answer_message_id').val(message_id);
|
23
|
+
|
24
|
+
//answer_form_block
|
25
|
+
var pos = $("#answer_form_block").position();
|
26
|
+
$(document).scrollTop(pos.top + 100);
|
27
|
+
|
28
|
+
return false;
|
29
|
+
});
|
30
|
+
|
31
|
+
$('a.erase').live('click', function(e){
|
32
|
+
$('#answer_form_block').hide();
|
33
|
+
return false;
|
34
|
+
});
|
35
|
+
});
|
36
|
+
</script>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
ru:
|
2
|
+
manage:
|
3
|
+
plugins:
|
4
|
+
feedbacks: "Обратная связь"
|
5
|
+
|
6
|
+
menu:
|
7
|
+
feedback_messages: "Обратная связь"
|
8
|
+
|
9
|
+
feedbacks:
|
10
|
+
answers:
|
11
|
+
new: "Ответить"
|
12
|
+
|
13
|
+
activerecord:
|
14
|
+
attributes:
|
15
|
+
feedback_message:
|
16
|
+
user_name: "Имя"
|
17
|
+
user_email: "Email"
|
18
|
+
phone_number: "Телефон"
|
19
|
+
content: "Сообщение"
|
20
|
+
author: "Автор"
|
21
|
+
|
22
|
+
sunrise:
|
23
|
+
feedback:
|
24
|
+
new: "Обратная связь"
|
25
|
+
create: "Отправить"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
uk:
|
2
|
+
manage:
|
3
|
+
plugins:
|
4
|
+
feedbacks: "Зворотній зв'язок"
|
5
|
+
|
6
|
+
menu:
|
7
|
+
feedback_messages: "Зворотній зв'язок"
|
8
|
+
|
9
|
+
feedbacks:
|
10
|
+
answers:
|
11
|
+
new: "Відповісти"
|
12
|
+
|
13
|
+
activerecord:
|
14
|
+
attributes:
|
15
|
+
feedback_message:
|
16
|
+
user_name: "Ім'я"
|
17
|
+
user_email: "Email"
|
18
|
+
phone_number: "Телефон"
|
19
|
+
content: "Повідомлення"
|
20
|
+
author: "Автор"
|
21
|
+
|
22
|
+
feedback_answer:
|
23
|
+
author: "Автор"
|
24
|
+
content: "Відповідь"
|
25
|
+
|
26
|
+
sunrise:
|
27
|
+
feedback:
|
28
|
+
new: "Зворотній зв'язок"
|
29
|
+
create: "Відправити"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
module Sunrise
|
5
|
+
module Feedbacks
|
6
|
+
class InstallGenerator < Rails::Generators::Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
|
9
|
+
source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
10
|
+
class_option :migrations, :type => :boolean, :default => true, :description => "Generate migrations files"
|
11
|
+
|
12
|
+
desc "Generates comment migration and model"
|
13
|
+
|
14
|
+
def self.current_time
|
15
|
+
@current_time ||= Time.now
|
16
|
+
@current_time += 1.minute
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.next_migration_number(dirname)
|
20
|
+
current_time.strftime("%Y%m%d%H%M%S")
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_model
|
24
|
+
copy_file('feedback_message.rb', 'app/models/feedback_message.rb')
|
25
|
+
copy_file('feedback_answer.rb', 'app/models/feedback_answer.rb')
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_migration
|
29
|
+
if options.migrations
|
30
|
+
migration_template "create_feedback_messages.rb", File.join('db/migrate', "sunrise_create_feedback_messages.rb")
|
31
|
+
migration_template "create_feedback_answers.rb", File.join('db/migrate', "sunrise_create_feedback_answers.rb")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class SunriseCreateFeedbackAnswers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :feedback_answers do |t|
|
4
|
+
t.text :content, :null => false
|
5
|
+
t.integer :message_id, :null => false
|
6
|
+
|
7
|
+
t.integer :author_id
|
8
|
+
t.string :author_type, :limit => 30
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index :feedback_answers, [:author_type, :author_id]
|
14
|
+
add_index :feedback_answers, :message_id
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.down
|
18
|
+
drop_table :feedback_answers
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class SunriseCreateFeedbackMessages < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :feedback_messages do |t|
|
4
|
+
t.string :user_name, :limit => 50
|
5
|
+
t.string :user_email, :limit => 50
|
6
|
+
t.integer :phone_number, :limit => 8
|
7
|
+
t.text :content, :null => false
|
8
|
+
t.text :content_html
|
9
|
+
t.integer :answers_count, :default => 0
|
10
|
+
|
11
|
+
t.integer :author_id
|
12
|
+
t.string :author_type, :limit => 30
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
|
17
|
+
add_index :feedback_messages, [:author_type, :author_id]
|
18
|
+
add_index :feedback_messages, :user_email
|
19
|
+
add_index :feedback_messages, :phone_number
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.down
|
23
|
+
drop_table :feedback_messages
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class FeedbackAnswer < ActiveRecord::Base
|
2
|
+
include Sunrise::Models::FeedbackAnswer
|
3
|
+
|
4
|
+
attr_accessible :content, :message_id
|
5
|
+
|
6
|
+
# Validations
|
7
|
+
validates :content, :presence => true, :length => { :maximum => 500 }
|
8
|
+
validates :author_type, :inclusion => { :in => %w( User ) }
|
9
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class FeedbackMessage < ActiveRecord::Base
|
2
|
+
include Sunrise::Models::FeedbackMessage
|
3
|
+
|
4
|
+
attr_accessible :user_name, :user_email, :content
|
5
|
+
|
6
|
+
# Validations
|
7
|
+
validates :content, :presence => true, :length => { :maximum => 500 }
|
8
|
+
validates :author_type, :inclusion => { :in => %w( User ) }, :allow_blank => true
|
9
|
+
|
10
|
+
with_options :if => :anonymous? do |anonymous|
|
11
|
+
anonymous.validates :user_name, :length => { :maximum => 100 }, :presence => true,
|
12
|
+
:format => { :with => /\A[^[:cntrl:]\\<>\/&]*\z/ }
|
13
|
+
anonymous.validates :user_email, :length => { :within => 6..100 }, :presence => true,
|
14
|
+
:format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i }
|
15
|
+
end
|
16
|
+
|
17
|
+
# Format feedback content
|
18
|
+
auto_html_for :content do
|
19
|
+
html_escape
|
20
|
+
image
|
21
|
+
youtube :width => 500, :height => 300
|
22
|
+
vimeo :width => 500, :height => 300
|
23
|
+
link :target => "_blank", :rel => "nofollow"
|
24
|
+
simple_format
|
25
|
+
sanitize
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Sunrise
|
3
|
+
module Feedbacks
|
4
|
+
autoload :Author, 'sunrise/feedbacks/author'
|
5
|
+
|
6
|
+
mattr_accessor :navigational_formats
|
7
|
+
@@navigational_formats = [:html]
|
8
|
+
|
9
|
+
mattr_accessor :siblings_keys
|
10
|
+
@@siblings_keys = [:user_email]
|
11
|
+
|
12
|
+
# Default way to setup Sunrise Feedbacks.
|
13
|
+
def self.setup
|
14
|
+
yield self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'sunrise/feedbacks/version'
|
20
|
+
require 'sunrise/feedbacks/engine'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Sunrise
|
2
|
+
module Feedbacks
|
3
|
+
module Author
|
4
|
+
def self.included(base)
|
5
|
+
base.send :include, InstanceMethods
|
6
|
+
base.send :extend, ClassMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module ClassMethods
|
10
|
+
def self.extended(base)
|
11
|
+
base.class_eval do
|
12
|
+
has_many :feedback_messages, :as => :author, :dependent => :delete_all
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module InstanceMethods
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'sunrise-feedbacks'
|
3
|
+
|
4
|
+
module Sunrise
|
5
|
+
module Feedbacks
|
6
|
+
class Engine < ::Rails::Engine
|
7
|
+
config.before_initialize do
|
8
|
+
Sunrise::Plugin.register :feedbacks do |plugin|
|
9
|
+
plugin.model = [:feedback_message, :feedback_answer]
|
10
|
+
plugin.menu = 'select'
|
11
|
+
plugin.klass_name = 'FeedbackMessage'
|
12
|
+
plugin.version = Sunrise::Feedbacks::VERSION.dup
|
13
|
+
end
|
14
|
+
|
15
|
+
Sunrise::Plugins.activate(:feedbacks)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Sunrise
|
3
|
+
module Models
|
4
|
+
module FeedbackAnswer
|
5
|
+
def self.included(base)
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
base.send :extend, ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def self.extended(base)
|
12
|
+
base.class_eval do
|
13
|
+
belongs_to :author, :polymorphic => true
|
14
|
+
belongs_to :message, :class_name => 'FeedbackMessage', :foreign_key => :message_id, :counter_cache => :answers_count
|
15
|
+
|
16
|
+
default_scope order("#{quoted_table_name}.id DESC")
|
17
|
+
scope :recently, order("#{quoted_table_name}.created_at DESC")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module InstanceMethods
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Sunrise
|
3
|
+
module Models
|
4
|
+
module FeedbackMessage
|
5
|
+
def self.included(base)
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
base.send :extend, ClassMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
def self.extended(base)
|
12
|
+
base.class_eval do
|
13
|
+
has_many :answers, :class_name => 'FeedbackAnswer', :foreign_key => :message_id, :dependent => :delete_all
|
14
|
+
belongs_to :author, :polymorphic => true
|
15
|
+
|
16
|
+
before_validation :make_author
|
17
|
+
|
18
|
+
default_scope order("#{quoted_table_name}.id DESC")
|
19
|
+
scope :recently, order("#{quoted_table_name}.created_at DESC")
|
20
|
+
scope :with_author, lambda { |item| where(["author_type = ? AND author_id = ?", item.author_type, item.author_id]) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def siblings_for(record)
|
25
|
+
query = scoped
|
26
|
+
|
27
|
+
Sunrise::Feedbacks.siblings_keys.each do |key|
|
28
|
+
query = query.where(["#{key} = ?", record.send(key)])
|
29
|
+
end
|
30
|
+
|
31
|
+
query
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
module InstanceMethods
|
36
|
+
|
37
|
+
def anonymous?
|
38
|
+
author.nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
def siblings
|
42
|
+
self.class.siblings_for(self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def email_address_with_name
|
46
|
+
"#{user_name} <#{user_email}>"
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def make_author
|
52
|
+
unless author.nil?
|
53
|
+
self.user_email = author.email if author.respond_to?(:email)
|
54
|
+
self.user_name = author.name if author.respond_to?(:name)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sunrise-feedbacks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Igor Galeta
|
14
|
+
- Pavlo Galeta
|
15
|
+
autorequire:
|
16
|
+
bindir: bin
|
17
|
+
cert_chain: []
|
18
|
+
|
19
|
+
date: 2011-07-21 00:00:00 +03:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
23
|
+
name: sunrise-cms
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
hash: 3
|
31
|
+
segments:
|
32
|
+
- 0
|
33
|
+
version: "0"
|
34
|
+
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
description: Sunrise is a Aimbulance CMS
|
37
|
+
email: galeta.igor@gmail.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- README.rdoc
|
46
|
+
- Rakefile
|
47
|
+
- app/controllers/feedbacks_controller.rb
|
48
|
+
- app/controllers/manage/feedback_answers_controller.rb
|
49
|
+
- app/controllers/manage/feedbacks_controller.rb
|
50
|
+
- app/helpers/manage/feedbacks_helper.rb
|
51
|
+
- app/views/feedbacks/_form.html.erb
|
52
|
+
- app/views/feedbacks/new.html.erb
|
53
|
+
- app/views/manage/feedback_answers/_answer.html.erb
|
54
|
+
- app/views/manage/feedback_answers/_form.html.erb
|
55
|
+
- app/views/manage/feedback_answers/create.js.erb
|
56
|
+
- app/views/manage/feedback_answers/destroy.js.erb
|
57
|
+
- app/views/manage/feedbacks/_feedback.html.erb
|
58
|
+
- app/views/manage/feedbacks/_form.html.erb
|
59
|
+
- app/views/manage/feedbacks/_message.html.erb
|
60
|
+
- app/views/manage/feedbacks/_model_filter.html.erb
|
61
|
+
- app/views/manage/feedbacks/edit.html.erb
|
62
|
+
- app/views/manage/feedbacks/index.html.erb
|
63
|
+
- app/views/manage/feedbacks/new.html.erb
|
64
|
+
- app/views/manage/feedbacks/show.html.erb
|
65
|
+
- config/locales/ru.yml
|
66
|
+
- config/locales/uk.yml
|
67
|
+
- config/routes.rb
|
68
|
+
- lib/generators/sunrise/feedbacks/USAGE
|
69
|
+
- lib/generators/sunrise/feedbacks/install_generator.rb
|
70
|
+
- lib/generators/sunrise/feedbacks/templates/create_feedback_answers.rb
|
71
|
+
- lib/generators/sunrise/feedbacks/templates/create_feedback_messages.rb
|
72
|
+
- lib/generators/sunrise/feedbacks/templates/feedback_answer.rb
|
73
|
+
- lib/generators/sunrise/feedbacks/templates/feedback_message.rb
|
74
|
+
- lib/sunrise-feedbacks.rb
|
75
|
+
- lib/sunrise/feedbacks.rb
|
76
|
+
- lib/sunrise/feedbacks/author.rb
|
77
|
+
- lib/sunrise/feedbacks/engine.rb
|
78
|
+
- lib/sunrise/feedbacks/version.rb
|
79
|
+
- lib/sunrise/models/feedback_answer.rb
|
80
|
+
- lib/sunrise/models/feedback_message.rb
|
81
|
+
has_rdoc: true
|
82
|
+
homepage: https://github.com/galetahub/sunrise-feedbacks
|
83
|
+
licenses: []
|
84
|
+
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
98
|
+
version: "0"
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
version: "0"
|
108
|
+
requirements: []
|
109
|
+
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 1.6.2
|
112
|
+
signing_key:
|
113
|
+
specification_version: 3
|
114
|
+
summary: Rails CMS
|
115
|
+
test_files: []
|
116
|
+
|