Nuevo plugin Redmine Questions 0.0.7 light

This commit is contained in:
Manuel Cillero 2018-02-02 23:35:10 +01:00
parent c5b56fffec
commit 7de6fb4627
51 changed files with 2162 additions and 0 deletions

View file

@ -0,0 +1 @@
gem "redmine_crm"

View file

@ -0,0 +1,3 @@
= redmine_qa
Description goes here

View file

@ -0,0 +1,117 @@
class QuestionsController < ApplicationController
unloadable
before_filter :find_optional_project, :only => [:autocomplete_for_topic, :topics]
before_filter :find_optional_board, :only => [:autocomplete_for_topic, :topics]
before_filter :find_topic, :authorize, :only => :vote
before_filter :find_topics, :only => [:topics, :autocomplete_for_topic]
helper :questions
if Redmine::VERSION.to_s > '2.1'
helper :boards
end
include QuestionsHelper
def index
@boards = Board.visible.includes(:last_message => :author).includes(:messages).order(:project_id)
# show the board if there is only one
if @boards.size == 1
@board = @boards.first
redirect_to project_board_url(@board, :project_id => @board.project)
else
render "boards/index"
end
end
def topics
end
def vote
User.current.voted_for?(@topic) ? @topic.dislike(User.current.becomes(Principal)) : @topic.like(User.current.becomes(Principal))
respond_to do |format|
format.html { redirect_to_referer_or {render :text => (watching ? 'Vote added.' : 'Vote removed.'), :layout => true}}
end
end
def autocomplete_for_topic
render :layout => false
end
def convert_issue
issue = Issue.visible.find(params[:issue_id])
board = Board.visible.find(params[:board_id])
message = Message.new
message.author = issue.author
message.created_on = issue.created_on
message.board = board
message.subject = issue.subject
message.content = issue.description.blank? ? issue.subject : issue.description
message.watchers = issue.watchers
message.add_watcher(issue.author)
message.attachments = issue.attachments
issue.journals.select{|j| !j.notes.blank?}.each do |journal|
reply = Message.new
reply.author = journal.user
reply.created_on = journal.created_on
reply.subject = "Re: #{message.subject}"
reply.content = journal.notes
reply.board = board
message.children << reply
end
if message.save
issue.destroy if params[:destroy]
redirect_to board_message_path(board, message)
else
redirect_back_or_default({:controller => 'issues', :action => 'show', :id => issue})
end
end
private
def find_topics
seach = params[:q] || params[:topic_search]
columns = ["subject", "content"]
tokens = seach.to_s.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect{|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}.uniq.select {|w| w.length > 1 }
tokens = [] << tokens unless tokens.is_a?(Array)
token_clauses = columns.collect {|column| "(LOWER(#{column}) LIKE ?)"}
sql = (['(' + token_clauses.join(' OR ') + ')'] * tokens.size).join(' AND ')
find_options = [sql, * (tokens.collect {|w| "%#{w.downcase}%"} * token_clauses.size).sort]
scope = Message.joins(:board).where({})
scope = scope.where("#{Message.table_name}.parent_id IS NULL")
scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project
scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board
scope = scope.where(find_options) unless tokens.blank?
scope = scope.visible.includes(:board).order("#{Message.table_name}.updated_on DESC")
@topic_count = scope.count
@limit = per_page_option
@topic_pages = Paginator.new(self, @topic_count, @limit, params[:page])
@offset = @topic_pages.current.offset
scope = scope.limit(@limit).offset(@offset)
scope = scope.tagged_with(params[:tag]) unless params[:tag].blank?
@topics = scope
end
def find_topic
@topic = Message.visible.find(params[:id]) unless params[:id].blank?
@board = @topic.board
@project = @board.project
rescue ActiveRecord::RecordNotFound
render_404
end
def find_optional_board
@board = Board.visible.find(params[:board_id]) unless params[:board_id].blank?
@project = @board.project if @board
allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true)
allowed ? true : deny_access
rescue ActiveRecord::RecordNotFound
render_404
end
end

View file

@ -0,0 +1,15 @@
module QuestionsHelper
def vote_tag(object, user, options={})
content_tag("span", vote_link(object, user))
end
def vote_link(object, user)
return '' unless user && user.logged? && user.respond_to?('voted_for?')
voted = user.voted_for?(object)
url = {:controller => 'questions', :action => 'vote', :id => object}
link_to((voted ? l(:button_questions_unvote) : l(:button_questions_vote)), url,
:class => (voted ? 'icon icon-vote' : 'icon icon-unvote'))
end
end

View file

@ -0,0 +1 @@
<%= render :partial => "questions/forums" %>

View file

@ -0,0 +1,64 @@
<%= board_breadcrumb(@board) %>
<div class="board details">
<div class="contextual">
<%= link_to_if_authorized l(:label_message_new),
{:controller => 'messages', :action => 'new', :board_id => @board},
:class => 'icon icon-add',
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' %>
<%= content_tag('span', watcher_link(@board, User.current), :id => 'watcher') %>
</div>
<div id="add-message" style="display:none;">
<% if authorize_for('messages', 'new') %>
<h2><%= link_to h(@board.name), :controller => 'boards', :action => 'show', :project_id => @project, :id => @board %> &#187; <%= l(:label_message_new) %></h2>
<%= form_for @message, :url => {:controller => 'messages', :action => 'new', :board_id => @board}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'messages/form', :locals => {:f => f} %>
<p><%= submit_tag l(:button_create) %>
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %> |
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' %></p>
<% end %>
<div id="preview" class="wiki"></div>
<% end %>
</div>
<h2><%=h @board.name %></h2>
<p class="subtitle"><%=h @board.description %></p>
<div class="filters">
<%= form_tag({:controller => "questions", :action => "topics" }, :method => :get, :id => "query_form") do %>
<%= hidden_field_tag('project_id', @project.to_param) if @project %>
<%= hidden_field_tag('board_id', @board.to_param) if @board %>
<% no_filters = true %>
<%= text_field_tag(:topic_search, params[:topic_search], :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %>
<%= javascript_tag "observeSearchfield('topic_search', 'topics_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %>
<% end %>
</div>
</div>
<div id="topics_list" >
<%= render :partial => "questions/topic_list" %>
</div>
<% other_formats_links do |f| %>
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
<% end %>
<% content_for :sidebar do %>
<%= render :partial => "questions/notice" %>
<%= render :partial => "questions/tag_cloud" %>
<%= render :partial => "questions/voted_topics" %>
<% end %>
<% html_title @board.name %>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
<%= javascript_include_tag :questions, :plugin => 'redmine_questions' %>
<% end %>

View file

@ -0,0 +1,39 @@
<%= error_messages_for 'message' %>
<% replying ||= false %>
<div class="box">
<!--[form:message]-->
<p style=<%= "display:none;" if replying %> ><label for="message_subject"><%= l(:field_subject) %></label><br />
<%= f.text_field :subject, :style => "width: 80%;", :id => "message_subject" %>
<% unless replying %>
<% if @message.safe_attribute? 'sticky' %>
<%= f.check_box :sticky %> <%= label_tag 'message_sticky', l(:label_board_sticky) %>
<% end %>
<% if @message.safe_attribute? 'locked' %>
<%= f.check_box :locked %> <%= label_tag 'message_locked', l(:label_board_locked) %>
<% end %>
<% end %>
</p>
<% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %>
<p><label><%= l(:label_board) %></label><br />
<%= f.select :board_id, boards_options_for_select(@message.project.boards) %></p>
<% end %>
<p>
<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %>
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %></p>
<%= wikitoolbar_for 'message_content' %>
<!--[eoform:message]-->
<% if !replying && @message.safe_attribute?('tag_list') %>
<p>
<label for="message_tag_list"><%= l(:field_questions_tags) %></label><br />
<%= render :partial => 'questions/form_tags' %>
</p>
<% end %>
<p><%= l(:label_attachment_plural) %><br />
<%= render :partial => 'attachments/form', :locals => {:container => @message} %></p>
</div>

View file

@ -0,0 +1,18 @@
<%= board_breadcrumb(@message) %>
<h2><%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %></h2>
<%= form_for @message, {
:as => :message,
:url => {:action => 'edit'},
:html => {:multipart => true,
:id => 'message-form',
:method => :post}
} do |f| %>
<%= render :partial => 'form',
:locals => {:f => f, :replying => !@message.parent.nil?} %>
<%= submit_tag l(:button_save) %>
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board, :id => @message}, 'message-form') %>
<% end %>
<div id="preview" class="wiki"></div>

View file

@ -0,0 +1,144 @@
<%= board_breadcrumb(@message) %>
<div class="contextual">
<%= content_tag('span', watcher_link(@topic, User.current), :id => 'watcher') %>
<% voted = User.current.voted_for?(@topic) %>
<%= link_to(
voted ? l(:button_questions_unvote) : l(:button_questions_vote),
{:controller => 'questions', :action => 'vote', :id => @topic},
:class => 'icon ' + (voted ? 'icon-vote' : 'icon-unvote')
) if User.current.allowed_to?(:vote_messages, @project) %>
<%= link_to(
l(:button_quote),
{:action => 'quote', :id => @topic},
:remote => true,
:method => 'get',
:class => 'icon icon-comment',
:remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
<%= link_to(
l(:button_edit),
{:action => 'edit', :id => @topic},
:class => 'icon icon-edit'
) if @message.editable_by?(User.current) %>
<%= link_to(
l(:button_delete),
{:action => 'destroy', :id => @topic},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'icon icon-del'
) if @message.destroyable_by?(User.current) %>
</div>
<div class="message details">
<h2><%=h @topic.subject %></h2>
<%= avatar(@topic.author, :size => "32") %>
<p class="author"><%= link_to_user @topic.author %><br>
<%= l(:label_questions_added_time, :value => time_tag(@topic.created_on)).html_safe %>
</p>
<div class="wiki">
<%= textilizable(@topic, :content) %>
</div>
<%= link_to_attachments @topic, :author => false %>
</div>
<br />
<% unless @replies.empty? %>
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @reply_count %>)</h3>
<% @replies.each do |message| %>
<div class="message reply" id="<%= "message-#{message.id}" %>">
<div class="contextual">
<% liked = User.current.voted_for?(message) %>
<%= link_to(
message.count_votes_up > 0 ? "(#{message.count_votes_up})" : "",
{:controller => 'questions', :action => 'vote', :id => message},
:class => 'vote icon ' + (liked ? 'icon-vote' : 'icon-unvote')
) if true || User.current.allowed_to?(:vote_messages, @project) %>
<%= link_to(
image_tag('comment.png'),
{:action => 'quote', :id => message},
:remote => true,
:method => 'get',
:title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %>
<%= link_to(
image_tag('edit.png'),
{:action => 'edit', :id => message},
:title => l(:button_edit)
) if message.editable_by?(User.current) %>
<%= link_to(
image_tag('delete.png'),
{:action => 'destroy', :id => message},
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if message.destroyable_by?(User.current) %>
</div>
<% if Setting.gravatar_enabled? %>
<div class="avatar">
<%= message_avatar = avatar(message.author, :size => "32") %>
</div>
<% end %>
<div class="reply-details <%= 'use-avatar' unless message_avatar.blank? %>">
<h4 class="author"><%= authoring message.created_on, message.author %></h4>
<div class="wiki"><%= textilizable message, :content, :attachments => message.attachments %></div>
<%= link_to_attachments message, :author => false %>
</div>
</div>
<% end %>
<p class="pagination"><%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %></p>
<% end %>
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
<p><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></p>
<div id="reply" style="display:none;">
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
<%= submit_tag l(:button_submit) %>
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<% end %>
<div id="preview" class="wiki"></div>
</div>
<% end %>
<% content_for :sidebar do %>
<h3><%= l(:label_questions_message) %></h3>
<ul class="question-meta">
<li class="votes icon icon-vote">
<%= l(:label_questions_votes, :count => @topic.count_votes_up - @topic.count_votes_down ) %>
</li>
<li class="views icon icon-view">
<%= l(:label_questions_views, :count => @topic.view_count ) %>
</li>
<% unless @topic.tags.blank? %>
<li class="tags icon icon-tag">
<%=
@topic.tags.collect do |tag|
link_to tag, {:controller => "questions", :action => "topics", :project_id => @project, :tag => tag.name}
end.join(', ').html_safe
%>
</li>
<% end %>
</ul>
<h3><%= l(:label_questions_related_messages) %></h3>
<ul class="related-topics">
<%# Board.all.map(&:topics).flatten.first(5).each do |topic| %>
<% tokens = @topic.subject.strip.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')} || "" %>
<% if ActiveRecord::VERSION::MAJOR >= 4 %>
<% related_topics = Message.where(tokens.map{ |t| "subject LIKE '%#{t}%'" }.join(' OR ')).to_a.compact if tokens %>
<% else %>
<% related_topics = Message.search(tokens, @project, :limit => 5)[0].select{|m| m != @topic && m.parent_id == nil }.compact if tokens %>
<% end %>
<% related_topics.each do |topic| %>
<li class="related-topic">
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
</li>
<% end if related_topics %>
</ul>
<% end %>
<% html_title @topic.subject %>

View file

@ -0,0 +1,23 @@
<script type="text/javascript">
$(function(){
<% available_tags = RedmineCrm::Tag.joins(:taggings).joins("INNER JOIN messages ON taggings.taggable_id = messages.id AND taggings.taggable_type = 'Message'").joins("INNER JOIN boards ON messages.board_id = boards.id").where(["boards.project_id = ?", @project]) %>
var currentTags = ['<%= available_tags.map(&:name).join("\',\'").html_safe %>'];
$('#allowSpacesTags').tagit({
availableTags: currentTags,
allowSpaces: true,
caseSensitive: false,
removeConfirmation: true
});
});
</script>
<span class="message-tags-edit">
<%= text_field_tag 'message[tag_list]', "#{@message.tags.map(&:name).join(',').html_safe}", :size => 10, :class => 'hol', :id => "allowSpacesTags" %>
</span>
<% content_for :header_tags do %>
<%= javascript_include_tag :"tag-it", :plugin => 'redmine_questions' %>
<%= stylesheet_link_tag :"jquery.tagit.css", :plugin => 'redmine_questions' %>
<% end %>

View file

@ -0,0 +1,68 @@
<h2><%= l(:label_questions) %></h2>
<div class="filters">
<%= form_tag({:controller => "questions", :action => "topics"}, :method => :get, :id => "query_form") do %>
<%= hidden_field_tag('project_id', @project.to_param) if @project %>
<%= text_field_tag(:topic_search, params[:topic_search] , :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %>
<%= javascript_tag "observeSearchfield('topic_search', 'forum_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %>
<% end %>
</div>
<div id="forum_list">
<% previous_group = false %>
<% boards = @project ? @boards : @boards.select{|b| b.topics_count > 0} %>
<% if @project %>
<ul>
<% end %>
<% boards.each do |board| %>
<% cache(Message.last.updated_on.to_s + board.id.to_s) do %>
<% if @project.blank? && (group = board.project) != previous_group %>
<% reset_cycle %>
</ul>
<div class="project-forums">
<h3><%= group.blank? ? 'None' : group.name %><%= link_to " \xc2\xbb", project_boards_path(:project_id => group) %></h3>
</div>
<ul>
<% previous_group = group %>
<% end %>
<li class="<%= cycle('odd', 'even') %> ">
<h3>
<%= link_to h(board.name), {:controller => "boards", :action => 'show', :id => board, :project_id => board.project_id}, :class => "board" %>
<span class="topic-count"><%= "(#{board.topics.count})" %></span>
</h3>
<div class="topic-list">
<% board.topics.sort_by{|m| [m.sticky, m.updated_on] }.reverse.first(5).each do |topic| %>
<div class="list-item">
<span class="topic-subject">
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => board, :id => topic } %>
</span><br>
<span class="last-author">
<% last_update = [topic.last_reply ? topic.last_reply.updated_on : topic.created_on, topic.updated_on].max %>
<% last_author = (topic.last_reply && topic.last_reply.updated_on) ? topic.last_reply.author : topic.author %>
<%= authoring last_update, last_author, :label => :label_updated_time_by %><br />
</span>
</div>
<% end %>
</div>
</li>
<% end %>
<% end %>
</ul>
</div>
<% content_for :sidebar do %>
<%= render :partial => "questions/notice" %>
<%= render :partial => "questions/tag_cloud" %>
<%= render :partial => "questions/latest_topics" %>
<%= render :partial => "questions/voted_topics" %>
<% end %>
<% content_for :header_tags do %>
<%= javascript_include_tag :questions, :plugin => 'redmine_questions' %>
<% end %>

View file

@ -0,0 +1,14 @@
<%
scope = Message.where({})
scope = scope.where("#{Message.table_name}.parent_id IS NULL")
scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project
@latest_topics = scope.visible.includes(:board).order("#{Message.table_name}.created_on DESC").limit(5)
%>
<h3><%= l(:label_questions_latest_messages) %></h3>
<ul class="related-topics">
<% @latest_topics.each do |topic| %>
<li class="related-topic">
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
</li>
<% end unless @latest_topics.blank? %>
</ul>

View file

@ -0,0 +1,3 @@
<% unless Setting.plugin_redmine_questions[:sidebar_message].blank? %>
<div class="wiki"><%= textilizable(Setting.plugin_redmine_questions[:sidebar_message]) %></div>
<% end %>

View file

@ -0,0 +1,35 @@
<%
limit = 30
scope = RedmineCrm::Tag.where({})
scope = scope.where("#{Project.table_name}.id = ?", @project) if @project
scope = scope.where(Project.allowed_to_condition(User.current, :view_messages))
join = []
join << "JOIN #{RedmineCrm::Tagging.table_name} ON #{RedmineCrm::Tagging.table_name}.tag_id = #{RedmineCrm::Tag.table_name}.id "
join << "JOIN #{Message.table_name} ON #{Message.table_name}.id = #{RedmineCrm::Tagging.table_name}.taggable_id AND #{RedmineCrm::Tagging.table_name}.taggable_type = '#{Message.name}' "
join << "JOIN #{Board.table_name} ON #{Board.table_name}.id = #{Message.table_name}.board_id"
join << "JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Board.table_name}.project_id"
group_fields = ""
group_fields << ", #{RedmineCrm::Tag.table_name}.created_at" if RedmineCrm::Tag.respond_to?(:created_at)
group_fields << ", #{RedmineCrm::Tag.table_name}.updated_at" if RedmineCrm::Tag.respond_to?(:updated_at)
scope = scope.joins(join.join(' '))
scope = scope.select("#{RedmineCrm::Tag.table_name}.*, COUNT(DISTINCT #{RedmineCrm::Tagging.table_name}.taggable_id) AS count")
scope = scope.group("#{RedmineCrm::Tag.table_name}.id, #{RedmineCrm::Tag.table_name}.name #{group_fields} HAVING COUNT(*) > 0")
scope = scope.order("#{RedmineCrm::Tag.table_name}.name")
scope = scope.limit(limit) if limit
@available_tags = scope
%>
<h3><%= l(:label_questions_tags) %></h3>
<ul class="questions-tags">
<% @available_tags.each do |tag| %>
<li>
<%= link_to tag, {:controller => "questions", :action => "topics", :project_id => @project, :tag => tag.name} %>
<span class="count"><%= tag.count %></span>
</li>
<% end if @available_tags %>
</ul>

View file

@ -0,0 +1,16 @@
<%
scope = Message.scoped({})
scope = scope.where("#{Message.table_name}.parent_id IS NULL")
scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project
scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board
scope = scope.where(:sticky => true)
@sticky_topics = scope.visible.includes(:board).order("#{Message.table_name}.cached_votes_up DESC").limit(10)
%>
<h3><%= l(:label_questions_most_voted) %></h3>
<ul class="related-topics">
<% @sticky_topics.each do |topic| %>
<li class="related-topic">
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
</li>
<% end unless @sticky_topics.blank? %>
</ul>

View file

@ -0,0 +1,30 @@
<% if @topics && @topics.any? %>
<% unless params[:tag].blank? %>
<div class="title-bar">
<h4><%= l(:label_questions_tagged_by, :count => @topics.size, :tag => params[:tag]) %></h4>
</div>
<% end %>
<div id="topics_container">
<% @topics.each do |topic| %>
<div class="topic">
<h3 class="subject">
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
</h3>
<p><%= truncate(topic.content.gsub(/\r\n/, ' ').strip , :length => 100) %></p>
<ul class="meta">
<li class="votes icon icon-vote"><%= l(:label_questions_votes, :count => topic.count_votes_up - topic.count_votes_down ) %></li>
<li class="answers icon icon-comment"><%= l(:label_questions_answers, :count => topic.replies_count) %></li>
</ul>
</div>
<% end %>
</div>
<% if @topic_pages %>
<% params[:controller] = 'questions'
params[:action] = 'topics'
%>
<p class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></p>
<% end %>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>

View file

@ -0,0 +1,16 @@
<%
scope = Message.where({})
scope = scope.where("#{Message.table_name}.parent_id IS NULL")
scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project
scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board
scope = scope.where("#{Message.table_name}.cached_votes_up > 0")
@most_voted_topics = scope.visible.includes(:board).order("#{Message.table_name}.cached_votes_up DESC").limit(5)
%>
<h3><%= l(:label_questions_most_voted) %></h3>
<ul class="related-topics">
<% @most_voted_topics.each do |topic| %>
<li class="related-topic">
<%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => topic.board, :id => topic } %>
</li>
<% end unless @most_voted_topics.blank? %>
</ul>

View file

@ -0,0 +1 @@
<%= render :partial => "questions/topic_list" %>

View file

@ -0,0 +1,9 @@
<h2><%= l(:label_message_new) %></h2>
<%= form_for @message, :url => {:controller => "messages", :action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'messages/form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %>
<%# preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
<% end %>
<div id="preview" class="wiki"></div>

View file

@ -0,0 +1,31 @@
<% if @board %>
<%= board_breadcrumb(@board) %>
<div class="board details">
<h2><%=h @board.name %></h2>
<p class="subtitle"><%=h @board.description %></p>
<% else %>
<h2><%= l(:label_questions) %></h2>
<% end %>
<div class="filters">
<%= form_tag({:controller => "questions", :action => "topics"}, :method => :get, :id => "query_form") do %>
<%= hidden_field_tag('project_id', @project.to_param) if @project %>
<%= hidden_field_tag('board_id', @board.to_param) if @board %>
<%= text_field_tag(:topic_search, params[:topic_search], :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %>
<%= javascript_tag "observeSearchfield('topic_search', 'topics_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %>
<% end %>
</div>
<% if @board %>
</div>
<% end %>
<div id="topics_list" >
<%= render :partial => "questions/topic_list" %>
</div>
<% content_for :sidebar do %>
<%= render :partial => "questions/latest_topics" %>
<% end %>

View file

@ -0,0 +1,3 @@
<p><label for="settings_sidebar_message"><%= l(:label_questions_sidebar_message) %></label>
<%= text_area_tag 'settings[sidebar_message]', @settings[:sidebar_message], :class => 'wiki-edit', :rows => 5 %>
</p>

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 601 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 667 B

View file

@ -0,0 +1,392 @@
/*
* jQuery UI Tag-it!
*
* @version v2.0 (06/2011)
*
* Copyright 2011, Levy Carneiro Jr.
* Released under the MIT license.
* http://aehlke.github.com/tag-it/LICENSE
*
* Homepage:
* http://aehlke.github.com/tag-it/
*
* Authors:
* Levy Carneiro Jr.
* Martin Rehfeld
* Tobias Schmidt
* Skylar Challand
* Alex Ehlke
*
* Maintainer:
* Alex Ehlke - Twitter: @aehlke
*
* Dependencies:
* jQuery v1.4+
* jQuery UI v1.8+
*/
(function($) {
$.widget('ui.tagit', {
options: {
itemName : 'item',
fieldName : 'tags',
availableTags : [],
tagSource : null,
removeConfirmation: false,
caseSensitive : true,
placeholderText : null,
// When enabled, quotes are not neccesary
// for inputting multi-word tags.
allowSpaces: false,
// Whether to animate tag removals or not.
animate: true,
// The below options are for using a single field instead of several
// for our form values.
//
// When enabled, will use a single hidden field for the form,
// rather than one per tag. It will delimit tags in the field
// with singleFieldDelimiter.
//
// The easiest way to use singleField is to just instantiate tag-it
// on an INPUT element, in which case singleField is automatically
// set to true, and singleFieldNode is set to that element. This
// way, you don't need to fiddle with these options.
singleField: false,
singleFieldDelimiter: ',',
// Set this to an input DOM node to use an existing form field.
// Any text in it will be erased on init. But it will be
// populated with the text of tags as they are created,
// delimited by singleFieldDelimiter.
//
// If this is not set, we create an input node for it,
// with the name given in settings.fieldName,
// ignoring settings.itemName.
singleFieldNode: null,
// Optionally set a tabindex attribute on the input that gets
// created for tag-it.
tabIndex: null,
// Event callbacks.
onTagAdded : null,
onTagRemoved: null,
onTagClicked: null
},
_create: function() {
// for handling static scoping inside callbacks
var that = this;
// There are 2 kinds of DOM nodes this widget can be instantiated on:
// 1. UL, OL, or some element containing either of these.
// 2. INPUT, in which case 'singleField' is overridden to true,
// a UL is created and the INPUT is hidden.
if (this.element.is('input')) {
this.tagList = $('<ul></ul>').insertAfter(this.element);
this.options.singleField = true;
this.options.singleFieldNode = this.element;
this.element.css('display', 'none');
} else {
this.tagList = this.element.find('ul, ol').andSelf().last();
}
this._tagInput = $('<input type="text" />').addClass('ui-widget-content');
if (this.options.tabIndex) {
this._tagInput.attr('tabindex', this.options.tabIndex);
}
if (this.options.placeholderText) {
this._tagInput.attr('placeholder', this.options.placeholderText);
}
this.options.tagSource = this.options.tagSource || function(search, showChoices) {
var filter = search.term.toLowerCase();
var choices = $.grep(this.options.availableTags, function(element) {
// Only match autocomplete options that begin with the search term.
// (Case insensitive.)
return (element.toLowerCase().indexOf(filter) === 0);
});
showChoices(this._subtractArray(choices, this.assignedTags()));
};
// Bind tagSource callback functions to this context.
if ($.isFunction(this.options.tagSource)) {
this.options.tagSource = $.proxy(this.options.tagSource, this);
}
this.tagList
.addClass('tagit')
.addClass('ui-widget ui-widget-content ui-corner-all')
// Create the input field.
.append($('<li class="tagit-new"></li>').append(this._tagInput))
.click(function(e) {
var target = $(e.target);
if (target.hasClass('tagit-label')) {
that._trigger('onTagClicked', e, target.closest('.tagit-choice'));
} else {
// Sets the focus() to the input field, if the user
// clicks anywhere inside the UL. This is needed
// because the input field needs to be of a small size.
that._tagInput.focus();
}
});
// Add existing tags from the list, if any.
this.tagList.children('li').each(function() {
if (!$(this).hasClass('tagit-new')) {
that.createTag($(this).html(), $(this).attr('class'));
$(this).remove();
}
});
// Single field support.
if (this.options.singleField) {
if (this.options.singleFieldNode) {
// Add existing tags from the input field.
var node = $(this.options.singleFieldNode);
var tags = node.val().split(this.options.singleFieldDelimiter);
node.val('');
$.each(tags, function(index, tag) {
that.createTag(tag);
});
} else {
// Create our single field input after our list.
this.options.singleFieldNode = this.tagList.after('<input type="hidden" style="display:none;" value="" name="' + this.options.fieldName + '" />');
}
}
// Events.
this._tagInput
.keydown(function(event) {
// Backspace is not detected within a keypress, so it must use keydown.
if (event.which == $.ui.keyCode.BACKSPACE && that._tagInput.val() === '') {
var tag = that._lastTag();
if (!that.options.removeConfirmation || tag.hasClass('remove')) {
// When backspace is pressed, the last tag is deleted.
that.removeTag(tag);
} else if (that.options.removeConfirmation) {
tag.addClass('remove ui-state-highlight');
}
} else if (that.options.removeConfirmation) {
that._lastTag().removeClass('remove ui-state-highlight');
}
// Comma/Space/Enter are all valid delimiters for new tags,
// except when there is an open quote or if setting allowSpaces = true.
// Tab will also create a tag, unless the tag input is empty, in which case it isn't caught.
if (
// event.which == $.ui.keyCode.COMMA ||
event.which == $.ui.keyCode.ENTER ||
(
event.which == $.ui.keyCode.TAB &&
that._tagInput.val() !== ''
) ||
(
event.which == $.ui.keyCode.SPACE &&
that.options.allowSpaces !== true &&
(
$.trim(that._tagInput.val()).replace( /^s*/, '' ).charAt(0) != '"' ||
(
$.trim(that._tagInput.val()).charAt(0) == '"' &&
$.trim(that._tagInput.val()).charAt($.trim(that._tagInput.val()).length - 1) == '"' &&
$.trim(that._tagInput.val()).length - 1 !== 0
)
)
)
) {
event.preventDefault();
that.createTag(that._cleanedInput());
// The autocomplete doesn't close automatically when TAB is pressed.
// So let's ensure that it closes.
that._tagInput.autocomplete('close');
}
}).blur(function(e){
// Create a tag when the element loses focus (unless it's empty).
that.createTag(that._cleanedInput());
});
// Autocomplete.
if (this.options.availableTags || this.options.tagSource) {
this._tagInput.autocomplete({
source: this.options.tagSource,
select: function(event, ui) {
// Delete the last tag if we autocomplete something despite the input being empty
// This happens because the input's blur event causes the tag to be created when
// the user clicks an autocomplete item.
// The only artifact of this is that while the user holds down the mouse button
// on the selected autocomplete item, a tag is shown with the pre-autocompleted text,
// and is changed to the autocompleted text upon mouseup.
if (that._tagInput.val() === '') {
that.removeTag(that._lastTag(), false);
}
that.createTag(ui.item.value);
// Preventing the tag input to be updated with the chosen value.
return false;
}
});
}
},
_cleanedInput: function() {
// Returns the contents of the tag input, cleaned and ready to be passed to createTag
return $.trim(this._tagInput.val().replace(/^"(.*)"$/, '$1'));
},
_lastTag: function() {
return this.tagList.children('.tagit-choice:last');
},
assignedTags: function() {
// Returns an array of tag string values
var that = this;
var tags = [];
if (this.options.singleField) {
tags = $(this.options.singleFieldNode).val().split(this.options.singleFieldDelimiter);
if (tags[0] === '') {
tags = [];
}
} else {
this.tagList.children('.tagit-choice').each(function() {
tags.push(that.tagLabel(this));
});
}
return tags;
},
_updateSingleTagsField: function(tags) {
// Takes a list of tag string values, updates this.options.singleFieldNode.val to the tags delimited by this.options.singleFieldDelimiter
$(this.options.singleFieldNode).val(tags.join(this.options.singleFieldDelimiter));
},
_subtractArray: function(a1, a2) {
var result = [];
for (var i = 0; i < a1.length; i++) {
if ($.inArray(a1[i], a2) == -1) {
result.push(a1[i]);
}
}
return result;
},
tagLabel: function(tag) {
// Returns the tag's string label.
if (this.options.singleField) {
return $(tag).children('.tagit-label').text();
} else {
return $(tag).children('input').val();
}
},
_isNew: function(value) {
var that = this;
var isNew = true;
this.tagList.children('.tagit-choice').each(function(i) {
if (that._formatStr(value) == that._formatStr(that.tagLabel(this))) {
isNew = false;
return false;
}
});
return isNew;
},
_formatStr: function(str) {
if (this.options.caseSensitive) {
return str;
}
return $.trim(str.toLowerCase());
},
createTag: function(value, additionalClass) {
var that = this;
// Automatically trims the value of leading and trailing whitespace.
value = $.trim(value);
if (!this._isNew(value) || value === '') {
return false;
}
var label = $(this.options.onTagClicked ? '<a class="tagit-label"></a>' : '<span class="tagit-label"></span>').text(value);
// Create tag.
var tag = $('<li></li>')
.addClass('tagit-choice ui-widget-content ui-state-default ui-corner-all')
.addClass(additionalClass)
.append(label);
// Button for removing the tag.
var removeTagIcon = $('<span></span>')
.addClass('ui-icon ui-icon-close');
var removeTag = $('<a><span class="text-icon">\xd7</span></a>') // \xd7 is an X
.addClass('tagit-close')
.append(removeTagIcon)
.click(function(e) {
// Removes a tag when the little 'x' is clicked.
that.removeTag(tag);
});
tag.append(removeTag);
// Unless options.singleField is set, each tag has a hidden input field inline.
if (this.options.singleField) {
var tags = this.assignedTags();
tags.push(value);
this._updateSingleTagsField(tags);
} else {
var escapedValue = label.html();
tag.append('<input type="hidden" style="display:none;" value="' + escapedValue + '" name="' + this.options.itemName + '[' + this.options.fieldName + '][]" />');
}
this._trigger('onTagAdded', null, tag);
// Cleaning the input.
this._tagInput.val('');
// insert tag
this._tagInput.parent().before(tag);
},
removeTag: function(tag, animate) {
animate = animate || this.options.animate;
tag = $(tag);
this._trigger('onTagRemoved', null, tag);
if (this.options.singleField) {
var tags = this.assignedTags();
var removedTagLabel = this.tagLabel(tag);
tags = $.grep(tags, function(el){
return el != removedTagLabel;
});
this._updateSingleTagsField(tags);
}
// Animate the removal.
if (animate) {
tag.fadeOut('fast').hide('blind', {direction: 'horizontal'}, 'fast', function(){
tag.remove();
}).dequeue();
} else {
tag.remove();
}
},
removeAll: function() {
// Removes all tags.
var that = this;
this.tagList.children('.tagit-choice').each(function(index, tag) {
that.removeTag(tag, false);
});
}
});
})(jQuery);

View file

@ -0,0 +1,54 @@
ul.tagit {
padding: 1px 5px;
overflow: auto;
margin-left: inherit; /* usually we don't want the regular ul margins. */
margin-right: inherit;
}
ul.tagit li {
display: block;
float: left;
margin: 2px 5px 2px 0;
}
ul.tagit li.tagit-choice {
padding: .2em 18px .2em .5em;
position: relative;
line-height: inherit;
}
ul.tagit li.tagit-new {
padding: .25em 4px .25em 0;
}
ul.tagit li.tagit-choice a.tagit-label {
cursor: pointer;
text-decoration: none;
}
ul.tagit li.tagit-choice .tagit-close {
cursor: pointer;
position: absolute;
right: .1em;
top: 50%;
margin-top: -8px;
}
/* used for some custom themes that don't need image icons */
ul.tagit li.tagit-choice .tagit-close .text-icon {
display: none;
}
ul.tagit li.tagit-choice input {
display: block;
float: left;
margin: 2px 5px 2px 0;
}
ul.tagit input[type="text"] {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border: none;
margin: 0;
padding: 0;
width: inherit;
background-color: inherit;
outline: none;
}

View file

@ -0,0 +1,239 @@
#forum_list div.list-item {
margin-bottom: 10px;
}
#forum_list div.list-item .last-author {
font-size: 80%;
color: gray;
}
#forum_list div.list-item .last-author a {
color: gray;
}
#forum_list > ul > li {
float: left;
width: 44%;
padding: 0;
margin: 15px 3% 0 0;
}
#forum_list div.project-forums {
border-bottom: 1px solid #CCC;
padding-top: 20px;
clear: left;
}
#forum_list > ul {
list-style: none;
padding: 0px;
margin-top: 0px;
}
#forum_list > ul > li.even {
margin-right: 0;
width: 46%;
}
#forum_list > ul > li.odd {
clear: left;
}
#forum_list > ul > li.odd, #forum_list > ul > li.even {
background-color: inherit;
}
.topic {
padding: 10px 0 20px;
}
div.topic p {
margin: 5px 0;
}
div.topic h3.subject {
margin: 0px;
}
div.topic ul.meta {
margin: 0px;
padding: 0px;
}
div.topic ul.meta li {
display: block;
float: left;
font-size: 11px;
color: #999;
margin-right: 8px;
list-style: none;
}
#topics_list div.title-bar h4 {
padding: 15px 0;
border-bottom: 1px dotted #bbb;
}
input.questions-search {
background: url(/images/magnifier.png) no-repeat 6px 50%;
border: 1px solid #D7D7D7;
background-color: white;
padding-left: 30px;
border-radius: 3px;
height: 1.5em;
width: 94%;
font-size: 16px;
}
input.questions-search.ajax-loading {
background-image: url(/images/loading.gif);
}
div.message.reply {
margin-bottom: 20px;
}
div.message.reply div.avatar {
position: absolute;
}
div.message.reply div.reply-details.use-avatar {
padding-left: 50px;
}
div.message.reply .author{
margin-bottom: 5px;
}
div.message.reply .wiki > p:first-child {
margin-top: 0px;
}
div.message.reply .contextual .icon.vote {
position: relative;
bottom: 5px;
}
div.message.details img.gravatar {
float: left;
margin-right: 5px;
}
div.message.details p.author {
margin-top: 15px;
}
div.message.details .wiki {
margin-top: 15px;
padding-top: 10px;
border-top: 1px dotted #BBB;
}
/* Question meta */
#sidebar ul.question-meta, #sidebar ul.related-topics {
list-style: none;
padding: 0px;
}
#sidebar ul.question-meta li {
margin-bottom: 10px;
padding-left: 20px;
padding-top: 2px;
padding-bottom: 3px;
}
#sidebar ul.related-topics li {
margin-bottom: 5px;
}
/* Tags cloud */
#sidebar ul.questions-tags {
list-style: none;
padding: 0px;
}
#sidebar ul.questions-tags li {
margin-bottom: 5px;
}
#sidebar ul.questions-tags span.count {
color: gray;
}
/**********************************************************************/
/* TAGS
/**********************************************************************/
.message-tags-edit ul.tagit li.tagit-choice:hover, ul.tagit li.tagit-choice.remove {
background-color: #E5E5E5;
text-decoration: none;
color: black;
}
.message-tags-edit ul.tagit {
border: 1px solid #D7D7D7;
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
-khtml-border-radius: 0px;
border-radius: 0px;
background: white;
padding: 0px;
margin-top: 0px;
}
.message-tags-edit ul.tagit li.tagit-choice {
font-weight: normal;
-moz-border-radius: 0px;
-webkit-border-radius: 0px;
border-radius: 0px;
font-size: 11px;
color: inherit;
padding-top: 0px;
padding-bottom: 0px;
background-color: #F7F7F7;
margin: 1px;
}
.message-tags-edit ul.tagit li.tagit-choice {
font-weight: normal;
font-size: 11px;
color: inherit;
}
.message-tags-edit ul.tagit li.tagit-choice a.tagit-close {
text-decoration: none;
}
.message-tags-edit ul.tagit li.tagit-choice .tagit-close .text-icon {
display: inline;
line-height: 16px;
}
.message-tags-edit ul.tagit li.tagit-choice .ui-icon {
display: none;
}
.message-tags-edit ul.tagit li.tagit-new {
padding: 0px;
}
.message-tags-edit ul.tagit li.tagit-new input {
font-size: 11px;
background: white;
margin-bottom: 2px;
margin-left: 2px;
width: 200px;
}
/**********************************************************************/
/* ICONS
/**********************************************************************/
.icon-vote { background-image: url(../images/thumb_up.png); }
.icon-unvote { background-image: url(../images/unvote.png); }
.icon-view { background-image: url(../images/eye.png); }
.icon-calendar { background-image: url(/images/calendar.png); }
.icon-tag { background-image: url(../images/tag_blue.png); }

View file

@ -0,0 +1,108 @@
# encoding: utf-8
# English strings go here for Rails i18n
en:
label_questions: 'Help & Support'
label_questions_search: 'Search for a specific question, answer or topic ...'
label_questions_new: New question
label_questions_message: Message
label_questions_added_time: "Added %{value} ago"
label_questions_related_messages: Related messages
label_questions_latest_messages: Latest messages
label_questions_views: '%{count} views'
label_questions_votes: '%{count} votes'
label_questions_answers: '%{count} answers'
label_questions_tags: Tags
label_questions_tagged_by: '%{count} topic(s) tagged by %{tag}'
label_questions_sidebar_message: Sidebar message
label_questions_notice: Notice
label_questions_most_voted: Most voted
button_questions_vote: Vote
button_questions_unvote: Unvote
button_questions_like: Like
button_questions_unlike: Unlike
field_questions_tags: Tags
permission_view_questions: View Help & Support
permission_edit_messages_tags: Edit tags
permission_edit_vote_messages: Vote messages
i18n:
transliterate:
rule:
і: 'i'
ґ: 'g'
ё: 'yo'
: '#'
є: 'e'
ї: 'yi'
а: 'a'
б: 'b'
в: 'v'
г: 'g'
д: 'd'
е: 'e'
ж: 'zh'
з: 'z'
и: 'i'
й: 'y'
к: 'k'
л: 'l'
м: 'm'
н: 'n'
о: 'o'
п: 'p'
р: 'r'
с: 's'
т: 't'
у: 'u'
ф: 'f'
х: 'h'
ц: 'ts'
ч: 'ch'
ш: 'sh'
щ: 'sch'
ъ: ''
ы: 'y'
ь: ''
э: 'e'
ю: 'yu'
я: 'ya'
"Ґ": "G"
"Ё": "YO"
"Є": "E"
"Ї": "YI"
"І": "I"
"А": "A"
"Б": "B"
"В": "V"
"Г": "G"
"Д": "D"
"Е": "E"
"Ж": "ZH"
"З": "Z"
"И": "I"
"Й": "Y"
"К": "K"
"Л": "L"
"М": "M"
"Н": "N"
"О": "O"
"П": "P"
"Р": "R"
"С": "S"
"Т": "T"
"У": "U"
"Ф": "F"
"Х": "H"
"Ц": "TS"
"Ч": "CH"
"Ш": "SH"
"Щ": "SCH"
"Ъ": "'"
"Ы": "Y"
"Ь": ""
"Э": "E"
"Ю": "YU"
"Я": "YA"

View file

@ -0,0 +1,27 @@
es:
label_questions: 'Ayuda y Soporte'
label_questions_search: 'Buscar una pregunta, respuesta o tópico...'
label_questions_new: Nueva pregunta
label_questions_message: Mensaje
label_questions_added_time: "Agregado hace %{value}"
label_questions_related_messages: Mensajes relacionados
label_questions_latest_messages: Últimos mensajes
label_questions_views: '%{count} vistas'
label_questions_votes: '%{count} votos'
label_questions_answers: '%{count} respuestas'
label_questions_tags: Etiquetas
label_questions_tagged_by: '%{count} tópico(s) etiquetado como %{tag}'
label_questions_notice_message: Mensaje noticia
label_questions_notice: Noticia
label_questions_most_voted: Más votados
button_questions_vote: Votar
button_questions_unvote: Quitar Voto
button_questions_like: Me gusta
button_questions_unlike: Ya no me gusta
field_questions_tags: Etiquetas
permission_view_questions: Ver Ayuda y Soporte
permission_edit_messages_tags: Editar etiquetas
permission_edit_vote_messages: Votar mensajes

View file

@ -0,0 +1,28 @@
# Russian strings go here for Rails i18n
ru:
label_questions: 'Поддержка'
label_questions_search: 'Поиск вопросов и ответов ...'
label_questions_new: Новая тема
label_questions_message: Сообщение
label_questions_added_time: "Добавлена %{value} назад"
label_questions_related_messages: Связанные темы
label_questions_latest_messages: Последние сообщения
label_questions_views: '%{count} просмотров'
label_questions_votes: '%{count} голосов'
label_questions_answers: '%{count} ответов'
label_questions_tags: Тэги
label_questions_tagged_by: '%{count} тем с тэгом %{tag}'
label_questions_sidebar_message: Сообщение справа
label_questions_notice: Информация
label_questions_most_voted: Больше голосов
button_questions_vote: Голосовать
button_questions_unvote: Отменить голос
button_questions_like: Like
button_questions_unlike: Unlike
field_questions_tags: Тэги
permission_view_questions: Просматривать вопросы ответы
permission_edit_messages_tags: Редактирвоать тэги
permission_edit_vote_messages: Голосовать

View file

@ -0,0 +1,32 @@
# encoding: utf-8
# Simplified Chinese strings go here for Rails i18n
# Author: Salivaxiu@163.com
# Based on file: en.yml
zh:
label_questions: '帮助与支持'
label_questions_search: '搜索特定的问题或回答或帖子...'
label_questions_new: 新问题
label_questions_message: 消息
label_questions_added_time: "在 %{value} 之前增加"
label_questions_related_messages: 相关的消息
label_questions_latest_messages: 最后的消息
label_questions_views: '显示 %{count} 次'
label_questions_votes: '投票 %{count} 次'
label_questions_answers: '回答 %{count} 次'
label_questions_tags: 标签
label_questions_tagged_by: '%{count} 个主题包含标签 %{tag}'
label_questions_notice_message: 通知消息
label_questions_notice: 通知
label_questions_most_voted: 大多数投票
button_questions_vote: 投票
button_questions_unvote: 取消投票
button_questions_like: 喜欢
button_questions_unlike: 不喜欢
field_questions_tags: 标签
permission_view_questions: 查看帮助和支持
permission_edit_messages_tags: 编辑标签
permission_edit_vote_messages: 投票消息

View file

@ -0,0 +1,14 @@
# Plugin's routes
# See: http://guides.rubyonrails.org/routing.html
resources :questions do
collection do
get :autocomplete_for_topic
get :topics
end
member do
get :vote
end
end
match "issues/:issue_id/move_to_forum/:board_id" => "questions#convert_issue", :via => [:get, :post]

View file

@ -0,0 +1,18 @@
class ActsAsVotableMigration < ActiveRecord::Migration
def self.up
ActiveRecord::Base.create_votable_table
add_column :messages, :cached_votes_total, :integer, :default => 0
add_column :messages, :cached_votes_up, :integer, :default => 0
add_column :messages, :cached_votes_down, :integer, :default => 0
add_index :messages, :cached_votes_total
add_index :messages, :cached_votes_up
add_index :messages, :cached_votes_down
end
def self.down
ActiveRecord::Base.drop_votable_table
remove_column :messages, :cached_votes_total
remove_column :messages, :cached_votes_up
remove_column :messages, :cached_votes_down
end
end

View file

@ -0,0 +1,10 @@
class AddViewingMigration < ActiveRecord::Migration
def self.up
ActiveRecord::Base.create_viewings_table
end
def self.down
ActiveRecord::Base.drop_viewings_table
end
end

View file

@ -0,0 +1,8 @@
class AddTaggingMigration < ActiveRecord::Migration
def up
ActiveRecord::Base.create_taggable_table
end
def down
end
end

View file

@ -0,0 +1,26 @@
== Redmine Q&A plugin changelog
Redmine Q&A plugin
Copyright (C) 2011-2016 Kirill Bezrukov
http://www.redminecrm.com/
== 2016-01-18 v0.0.7
* Chinese translation (zhoutt)
* Redmine 3+ support
== 2014-02-04 v0.0.6
* Redmine 2.4 support
* View count fixes for topic
* Topic count fixed in boards view
== 2013-05-28 v0.0.5
* Redmine 2.3 support
* Search by all words
== 2013-01-20 v0.0.3
* Redmine 2.2.0 support
* License files

View file

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View file

@ -0,0 +1,26 @@
LICENSING
RedmineCRM Licencing
This End User License Agreement is a binding legal agreement between you and RedmineCRM. Purchase, installation or use of RedmineCRM Extensions provided on redminecrm.com signifies that you have read, understood, and agreed to be bound by the terms outlined below.
RedmineCRM GPL Licencing
All Redmine Extensions produced by RedmineCRM are released under the GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html). Specifically, the Ruby code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript are NOT GPL, and are released under the RedmineCRM Proprietary Use License v1.0 (See below) unless specifically authorized by RedmineCRM. Elements of the extensions released under this proprietary license may not be redistributed or repackaged for use other than those allowed by the Terms of Service.
RedmineCRM Proprietary Use License (v1.0)
The RedmineCRM Proprietary Use License covers any images, cascading stylesheets, manuals and JavaScript files in any extensions produced and/or distributed by redminecrm.com. These files are copyrighted by redminecrm.com (RedmineCRM) and cannot be redistributed in any form without prior consent from redminecrm.com (RedmineCRM)
Usage Terms
You are allowed to use the Extensions on one or many "production" domains, depending on the type of your license
You are allowed to make any changes to the code, however modified code will not be supported by us.
Modification Of Extensions Produced By RedmineCRM.
You are authorized to make any modification(s) to RedmineCRM extension Ruby code. However, if you change any Ruby code and it breaks functionality, support may not be available to you.
In accordance with the RedmineCRM Proprietary Use License v1.0, you may not release any proprietary files (modified or otherwise) under the GPL license. The terms of this license and the GPL v2 prohibit the removal of the copyright information from any file.
Please contact us if you have any requirements that are not covered by these terms.

View file

@ -0,0 +1,38 @@
requires_redmine_crm(:version_or_higher => '0.0.17')
require 'redmine_questions'
Redmine::Plugin.register :redmine_questions do
name 'Redmine Q&A plugin'
author 'RedmineCRM'
description 'This is a Q&A plugin for Redmine'
version '0.0.7'
url 'http://www.redminecrm.com/projects/questions'
author_url 'mailto:support@redminecrm.com'
requires_redmine :version_or_higher => '2.1.2'
settings :default => {
:sidebar_message => '*Can\'t find the answer you\'re looking for?* Email us at ...'
}, :partial => 'settings/questions'
permission :view_questions, {
:questions => [:index, :autocomplete_for_topic, :topics]
}
delete_menu_item(:top_menu, :help)
menu :top_menu, :questions, {:controller => 'questions', :action => 'index'},
:last => true,
:caption => :label_questions,
:if => Proc.new {User.current.allowed_to?({:controller => 'questions', :action => 'index'}, nil, {:global => true})}
Redmine::AccessControl.map do |map|
map.project_module :boards do |map|
map.permission :view_questions, {:questions => [:autocomplete_for_topic, :topics]}
map.permission :vote_messages, {:questions => [:vote]}
map.permission :convert_issues, {:questions => [:convert_issue]}
map.permission :edit_messages_tags, {}
end
end
end

View file

@ -0,0 +1,16 @@
module RedmineQuestions
module Patches
module ActsAsVotableVotePatch
def self.included(base) # :nodoc:
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
attr_accessible :votable, :voter, :vote_scope
end
end
end
end
end
unless RedmineCrm::ActsAsVotable::Vote.included_modules.include?(RedmineQuestions::Patches::ActsAsVotableVotePatch)
RedmineCrm::ActsAsVotable::Vote.send(:include, RedmineQuestions::Patches::ActsAsVotableVotePatch)
end

View file

@ -0,0 +1,7 @@
require_dependency 'redmine_questions/hooks/views_layouts_hook'
# require_dependency 'redmine_questions/patches/boards_controller_patch'
require_dependency 'redmine_questions/patches/message_patch'
require_dependency 'redmine_questions/patches/user_patch'
require_dependency 'redmine_questions/patches/messages_controller_patch'
require_dependency 'acts_as_votable_vote_patch' if ActiveRecord::VERSION::MAJOR >= 4

View file

@ -0,0 +1,9 @@
module RedmineQuestions
module Hooks
class ViewsLayoutsHook < Redmine::Hook::ViewListener
def view_layouts_base_html_head(context={})
return stylesheet_link_tag(:questions, :plugin => 'redmine_questions')
end
end
end
end

View file

@ -0,0 +1,21 @@
require_dependency 'boards_controller'
require_dependency 'board'
module RedmineQuestions
module Patches
module BoardsControllerPatch
def self.included(base) # :nodoc:
base.class_eval do
helper :questions
end
end
end
end
end
unless MessagesController.included_modules.include?(RedmineQuestions::Patches::BoardsControllerPatch)
MessagesController.send(:include, RedmineQuestions::Patches::BoardsControllerPatch)
end

View file

@ -0,0 +1,44 @@
module RedmineQuestions
module Patches
module MessagePatch
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
rcrm_acts_as_taggable
rcrm_acts_as_votable
rcrm_acts_as_viewed
safe_attributes 'tag_list',
:if => lambda {|message, user|
user.allowed_to?(:edit_messages_tags, message.project)
}
end
end
module InstanceMethods
def to_param
"#{id}-#{ActiveSupport::Inflector.transliterate(subject).parameterize}"
end
def like(user)
liked_by(user)
end
def dislike(user)
unvote(:voter => user)
end
end
end
end
end
unless Message.included_modules.include?(RedmineQuestions::Patches::MessagePatch)
Message.send(:include, RedmineQuestions::Patches::MessagePatch)
end

View file

@ -0,0 +1,29 @@
module RedmineQuestions
module Patches
module MessagesControllerPatch
module InstanceMethods
def view_message
@message.view(request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip || request.remote_addr, User.current.logged? ? User.current : nil) unless @message.author == User.current
end
end
def self.included(base) # :nodoc:
base.send(:include, InstanceMethods)
base.class_eval do
after_filter :view_message, :only => :show
end
end
end
end
end
unless MessagesController.included_modules.include?(RedmineQuestions::Patches::MessagesControllerPatch)
MessagesController.send(:include, RedmineQuestions::Patches::MessagesControllerPatch)
end

View file

@ -0,0 +1,16 @@
module RedmineQuestions
module Patches
module UserPatch
def self.included(base) # :nodoc:
base.class_eval do
unloadable # Send unloadable so it will not be unloaded in development
rcrm_acts_as_voter
end
end
end
end
end
unless User.included_modules.include?(RedmineQuestions::Patches::UserPatch)
User.send(:include, RedmineQuestions::Patches::UserPatch)
end

View file

@ -0,0 +1,8 @@
require File.expand_path('../../test_helper', __FILE__)
class QuestionsControllerTest < ActionController::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end

View file

@ -0,0 +1,2 @@
# Load the Redmine helper
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')