REMOVE: Discourse Task gem -- It's not a plugin, I don't think anyone
uses it and I doubt it works.
This commit is contained in:
parent
19ea20e4cc
commit
b0179bd3d2
|
@ -1,13 +0,0 @@
|
||||||
source 'https://rubygems.org'
|
|
||||||
|
|
||||||
group :test do
|
|
||||||
gem 'rails'
|
|
||||||
gem 'rspec'
|
|
||||||
gem 'mocha'
|
|
||||||
end
|
|
||||||
|
|
||||||
# TODO: We need our own gem server
|
|
||||||
gem 'discourse_plugin', path: '../discourse_plugin'
|
|
||||||
|
|
||||||
# Specify your gem's dependencies in rails_multisite.gemspec
|
|
||||||
gemspec
|
|
|
@ -1,111 +0,0 @@
|
||||||
PATH
|
|
||||||
remote: .
|
|
||||||
specs:
|
|
||||||
discourse_task (0.0.1)
|
|
||||||
|
|
||||||
PATH
|
|
||||||
remote: ../discourse_plugin
|
|
||||||
specs:
|
|
||||||
discourse_plugin (0.0.1)
|
|
||||||
|
|
||||||
GEM
|
|
||||||
remote: https://rubygems.org/
|
|
||||||
specs:
|
|
||||||
actionmailer (3.2.8)
|
|
||||||
actionpack (= 3.2.8)
|
|
||||||
mail (~> 2.4.4)
|
|
||||||
actionpack (3.2.8)
|
|
||||||
activemodel (= 3.2.8)
|
|
||||||
activesupport (= 3.2.8)
|
|
||||||
builder (~> 3.0.0)
|
|
||||||
erubis (~> 2.7.0)
|
|
||||||
journey (~> 1.0.4)
|
|
||||||
rack (~> 1.4.0)
|
|
||||||
rack-cache (~> 1.2)
|
|
||||||
rack-test (~> 0.6.1)
|
|
||||||
sprockets (~> 2.1.3)
|
|
||||||
activemodel (3.2.8)
|
|
||||||
activesupport (= 3.2.8)
|
|
||||||
builder (~> 3.0.0)
|
|
||||||
activerecord (3.2.8)
|
|
||||||
activemodel (= 3.2.8)
|
|
||||||
activesupport (= 3.2.8)
|
|
||||||
arel (~> 3.0.2)
|
|
||||||
tzinfo (~> 0.3.29)
|
|
||||||
activeresource (3.2.8)
|
|
||||||
activemodel (= 3.2.8)
|
|
||||||
activesupport (= 3.2.8)
|
|
||||||
activesupport (3.2.8)
|
|
||||||
i18n (~> 0.6)
|
|
||||||
multi_json (~> 1.0)
|
|
||||||
arel (3.0.2)
|
|
||||||
builder (3.0.3)
|
|
||||||
diff-lcs (1.1.3)
|
|
||||||
erubis (2.7.0)
|
|
||||||
hike (1.2.1)
|
|
||||||
i18n (0.6.1)
|
|
||||||
journey (1.0.4)
|
|
||||||
json (1.7.5)
|
|
||||||
mail (2.4.4)
|
|
||||||
i18n (>= 0.4.0)
|
|
||||||
mime-types (~> 1.16)
|
|
||||||
treetop (~> 1.4.8)
|
|
||||||
metaclass (0.0.1)
|
|
||||||
mime-types (1.19)
|
|
||||||
mocha (0.12.7)
|
|
||||||
metaclass (~> 0.0.1)
|
|
||||||
multi_json (1.3.6)
|
|
||||||
polyglot (0.3.3)
|
|
||||||
rack (1.4.1)
|
|
||||||
rack-cache (1.2)
|
|
||||||
rack (>= 0.4)
|
|
||||||
rack-ssl (1.3.2)
|
|
||||||
rack
|
|
||||||
rack-test (0.6.2)
|
|
||||||
rack (>= 1.0)
|
|
||||||
rails (3.2.8)
|
|
||||||
actionmailer (= 3.2.8)
|
|
||||||
actionpack (= 3.2.8)
|
|
||||||
activerecord (= 3.2.8)
|
|
||||||
activeresource (= 3.2.8)
|
|
||||||
activesupport (= 3.2.8)
|
|
||||||
bundler (~> 1.0)
|
|
||||||
railties (= 3.2.8)
|
|
||||||
railties (3.2.8)
|
|
||||||
actionpack (= 3.2.8)
|
|
||||||
activesupport (= 3.2.8)
|
|
||||||
rack-ssl (~> 1.3.2)
|
|
||||||
rake (>= 0.8.7)
|
|
||||||
rdoc (~> 3.4)
|
|
||||||
thor (>= 0.14.6, < 2.0)
|
|
||||||
rake (0.9.2.2)
|
|
||||||
rdoc (3.12)
|
|
||||||
json (~> 1.4)
|
|
||||||
rspec (2.11.0)
|
|
||||||
rspec-core (~> 2.11.0)
|
|
||||||
rspec-expectations (~> 2.11.0)
|
|
||||||
rspec-mocks (~> 2.11.0)
|
|
||||||
rspec-core (2.11.1)
|
|
||||||
rspec-expectations (2.11.3)
|
|
||||||
diff-lcs (~> 1.1.3)
|
|
||||||
rspec-mocks (2.11.3)
|
|
||||||
sprockets (2.1.3)
|
|
||||||
hike (~> 1.2)
|
|
||||||
rack (~> 1.0)
|
|
||||||
tilt (~> 1.1, != 1.3.0)
|
|
||||||
thor (0.16.0)
|
|
||||||
tilt (1.3.3)
|
|
||||||
treetop (1.4.10)
|
|
||||||
polyglot
|
|
||||||
polyglot (>= 0.3.1)
|
|
||||||
tzinfo (0.3.33)
|
|
||||||
|
|
||||||
PLATFORMS
|
|
||||||
ruby
|
|
||||||
|
|
||||||
DEPENDENCIES
|
|
||||||
discourse_plugin!
|
|
||||||
discourse_task!
|
|
||||||
mocha
|
|
||||||
rails
|
|
||||||
rspec
|
|
|
@ -1,22 +0,0 @@
|
||||||
Copyright (c) 2012 Robin Ward
|
|
||||||
|
|
||||||
MIT License
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
@ -1,3 +0,0 @@
|
||||||
# Discourse Task Gem
|
|
||||||
|
|
||||||
Add support for a topic that can be marked as "Closed."
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/usr/bin/env rake
|
|
||||||
require "bundler/gem_tasks"
|
|
||||||
require "rspec/core/rake_task"
|
|
||||||
|
|
||||||
RSpec::Core::RakeTask.new(:test) do |spec|
|
|
||||||
spec.pattern = 'spec/*_spec.rb'
|
|
||||||
end
|
|
|
@ -1,5 +0,0 @@
|
||||||
Rails.application.routes.draw do
|
|
||||||
|
|
||||||
put 't/:slug/:topic_id/complete' => 'topics#complete', :constraints => {:topic_id => /\d+/}
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,19 +0,0 @@
|
||||||
# -*- encoding: utf-8 -*-
|
|
||||||
require File.expand_path('../lib/discourse_task/version', __FILE__)
|
|
||||||
|
|
||||||
Gem::Specification.new do |gem|
|
|
||||||
gem.authors = ["Robin Ward"]
|
|
||||||
gem.email = ["robin.ward@gmail.com"]
|
|
||||||
gem.description = %q{This gem add a Task archetype to discourse that can be closed}
|
|
||||||
gem.summary = %q{This gem add a Task archetype to discourse that can be closed}
|
|
||||||
gem.homepage = ""
|
|
||||||
|
|
||||||
# when this is extracted comment it back in, prd has no .git
|
|
||||||
gem.files = Dir['README*','LICENSE','lib/**/*.rb']
|
|
||||||
|
|
||||||
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
||||||
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
||||||
gem.name = "discourse_task"
|
|
||||||
gem.require_paths = ["lib"]
|
|
||||||
gem.version = DiscourseTask::VERSION
|
|
||||||
end
|
|
|
@ -1,4 +0,0 @@
|
||||||
require 'discourse_task/version'
|
|
||||||
require 'discourse_task/engine' if defined?(Rails) && (!Rails.env.test?)
|
|
||||||
|
|
||||||
I18n.load_path << "#{File.dirname(__FILE__)}/discourse_task/locale/en.yml"
|
|
|
@ -1,20 +0,0 @@
|
||||||
require 'discourse_task/plugin'
|
|
||||||
|
|
||||||
module DiscourseTask
|
|
||||||
class Engine < Rails::Engine
|
|
||||||
|
|
||||||
engine_name 'discourse_task'
|
|
||||||
|
|
||||||
initializer "discourse_task.configure_rails_initialization" do |app|
|
|
||||||
|
|
||||||
app.config.after_initialize do
|
|
||||||
DiscoursePluginRegistry.setup(DiscourseTask::Plugin)
|
|
||||||
end
|
|
||||||
|
|
||||||
app.config.to_prepare do
|
|
||||||
DiscourseTask::Plugin.include_mixins
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,21 +0,0 @@
|
||||||
en:
|
|
||||||
archetypes:
|
|
||||||
task:
|
|
||||||
title: "Task"
|
|
||||||
|
|
||||||
task:
|
|
||||||
completed: "This task has been marked as complete."
|
|
||||||
reversed: "This task has been re-opened."
|
|
||||||
|
|
||||||
js:
|
|
||||||
topic_statuses:
|
|
||||||
task:
|
|
||||||
help: "this topic is a task"
|
|
||||||
|
|
||||||
task:
|
|
||||||
title: "Task"
|
|
||||||
description: "This topic can be marked as complete by its creator or a moderator."
|
|
||||||
complete_action: "Complete Task"
|
|
||||||
complete_help: "mark this task as complete"
|
|
||||||
complete: "This task was marked as complete on {{completed_at}}."
|
|
||||||
reverse: "Undo Complete"
|
|
|
@ -1,92 +0,0 @@
|
||||||
require 'discourse_plugin'
|
|
||||||
|
|
||||||
module DiscourseTask
|
|
||||||
|
|
||||||
class Plugin < DiscoursePlugin
|
|
||||||
|
|
||||||
def self.archetype
|
|
||||||
'task'
|
|
||||||
end
|
|
||||||
|
|
||||||
def setup
|
|
||||||
# Add our Assets
|
|
||||||
register_js('discourse_task')
|
|
||||||
register_css('discourse_task')
|
|
||||||
|
|
||||||
# Add the archetype
|
|
||||||
register_archetype(DiscourseTask::Plugin.archetype)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
module TopicViewSerializerMixin
|
|
||||||
def self.included(base)
|
|
||||||
base.attributes :can_complete_task, :complete, :completed_at
|
|
||||||
end
|
|
||||||
|
|
||||||
def can_complete_task
|
|
||||||
scope.can_complete_task?(object.topic)
|
|
||||||
end
|
|
||||||
|
|
||||||
def complete
|
|
||||||
object.topic.has_meta_data_boolean?(:complete)
|
|
||||||
end
|
|
||||||
|
|
||||||
def completed_at
|
|
||||||
dt = Date.parse(object.topic.meta_data_string(:completed_at)).strftime("%d %b, %Y")
|
|
||||||
end
|
|
||||||
def include_completed_at?
|
|
||||||
object.topic.meta_data_string(:completed_at).present?
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
module GuardianMixin
|
|
||||||
|
|
||||||
# We need to be able to determine if a user can complete a task
|
|
||||||
def can_complete_task?(topic)
|
|
||||||
return false if @user.blank?
|
|
||||||
return false if topic.blank?
|
|
||||||
return false unless topic.archetype == DiscourseTask::Plugin.archetype
|
|
||||||
return true if @user.moderator?
|
|
||||||
return true if @user.admin?
|
|
||||||
|
|
||||||
# The OP can complete the topic
|
|
||||||
return @user == topic.user
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
module TopicsControllerMixin
|
|
||||||
|
|
||||||
def complete
|
|
||||||
topic = Topic.find_by(id: params[:topic_id])
|
|
||||||
guardian.ensure_can_complete_task!(topic)
|
|
||||||
|
|
||||||
Topic.transaction do
|
|
||||||
if params[:complete] == 'true'
|
|
||||||
topic.update_meta_data(complete: true, completed_at: Time.now)
|
|
||||||
topic.add_moderator_post(current_user, I18n.t(:'task.completed'))
|
|
||||||
else
|
|
||||||
topic.update_meta_data(complete: false)
|
|
||||||
topic.add_moderator_post(current_user, I18n.t(:'task.reversed'))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
render nothing: true
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
module TopicListItemSerializerMixin
|
|
||||||
def self.included(base)
|
|
||||||
base.attributes :complete
|
|
||||||
end
|
|
||||||
|
|
||||||
def complete
|
|
||||||
object.has_meta_data_boolean?(:complete)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,3 +0,0 @@
|
||||||
module DiscourseTask
|
|
||||||
VERSION = "0.0.1"
|
|
||||||
end
|
|
|
@ -1,28 +0,0 @@
|
||||||
require 'spec_helper'
|
|
||||||
require 'discourse_task/plugin'
|
|
||||||
|
|
||||||
describe DiscourseTask::Plugin do
|
|
||||||
|
|
||||||
let(:registry) { stub_everything }
|
|
||||||
let(:plugin) { DiscourseTask::Plugin.new(registry) }
|
|
||||||
|
|
||||||
context '.setup' do
|
|
||||||
|
|
||||||
it 'registers its js' do
|
|
||||||
plugin.expects(:register_js).with('discourse_task')
|
|
||||||
plugin.setup
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'registers its css' do
|
|
||||||
plugin.expects(:register_css).with('discourse_task')
|
|
||||||
plugin.setup
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'registers a task archetype' do
|
|
||||||
plugin.expects(:register_archetype).with('task')
|
|
||||||
plugin.setup
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
require 'rubygems'
|
|
||||||
require 'rails'
|
|
||||||
|
|
||||||
ENV["RAILS_ENV"] ||= 'test'
|
|
||||||
|
|
||||||
RSpec.configure do |config|
|
|
||||||
|
|
||||||
config.mock_framework = :mocha
|
|
||||||
config.color_enabled = true
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
//= require_tree ./discourse_task
|
|
|
@ -1,15 +0,0 @@
|
||||||
(function() {
|
|
||||||
|
|
||||||
Discourse.TopicController.reopen({
|
|
||||||
|
|
||||||
// Allow the user to complete the task
|
|
||||||
completeTask: function(e) {
|
|
||||||
this.get('content').toggleComplete();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}).call(this);
|
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
(function() {
|
|
||||||
|
|
||||||
Discourse.Topic.reopen({
|
|
||||||
|
|
||||||
// Allow the user to complete the task
|
|
||||||
toggleComplete: function() {
|
|
||||||
this.toggleProperty('complete');
|
|
||||||
this.set('completed_at', moment().format("d Mon, yyyy"));
|
|
||||||
|
|
||||||
jQuery.ajax(this.get('url') + "/complete", {
|
|
||||||
type: 'PUT',
|
|
||||||
data: {
|
|
||||||
complete: this.get('complete') ? 'true' : 'false'
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
}).call(this);
|
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<h3>{{i18n task.title}}</h3>
|
|
||||||
<p>{{{i18n task.description}}}</p>
|
|
||||||
|
|
||||||
{{#if controller.content.complete}}
|
|
||||||
<p><i class='fa fa-check'></i> {{i18n task.complete completed_at="controller.content.completed_at"}}</p>
|
|
||||||
|
|
||||||
{{#if controller.content.can_complete_task}}
|
|
||||||
<button class='btn' {{action completeTask target="controller"}}>{{i18n task.reverse}}</button>
|
|
||||||
{{/if}}
|
|
||||||
{{else}}
|
|
||||||
{{#if controller.content.can_complete_task}}
|
|
||||||
<button class='btn' {{action completeTask target="controller"}}><i class='fa fa-cog'></i> {{i18n task.complete_action}}</button>
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
|
|
|
@ -1,40 +0,0 @@
|
||||||
(function() {
|
|
||||||
|
|
||||||
Discourse.TopicFooterButtonsView.prototype.on("additionalButtons", function(childViews) {
|
|
||||||
var topic = this.get('topic');
|
|
||||||
if (topic.get('archetype') == 'task' && topic.get('can_complete_task')) {
|
|
||||||
|
|
||||||
// If we can complete the task:
|
|
||||||
childViews.addObject(Discourse.ButtonView.createWithMixins({
|
|
||||||
|
|
||||||
completeBinding: 'controller.content.complete',
|
|
||||||
|
|
||||||
completeChanged: function () {
|
|
||||||
this.rerender();
|
|
||||||
}.observes('complete'),
|
|
||||||
|
|
||||||
renderIcon: function (buffer) {
|
|
||||||
if (!this.get('complete')) {
|
|
||||||
buffer.push("<i class='fa-cog'></i>")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
text: function () {
|
|
||||||
if (this.get('complete')) {
|
|
||||||
return I18n.t("task.reverse");
|
|
||||||
} else {
|
|
||||||
return I18n.t("task.complete_action");
|
|
||||||
}
|
|
||||||
}.property('complete'),
|
|
||||||
|
|
||||||
click: function(e) {
|
|
||||||
this.get('controller').completeTask();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}).call(this);
|
|
||||||
|
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
(function() {
|
|
||||||
|
|
||||||
Discourse.TopicStatusView.prototype.on("addCustomIcon", function(buffer) {
|
|
||||||
|
|
||||||
// Add icon for closed tasks
|
|
||||||
var topic = this.get('topic');
|
|
||||||
if (topic.get('archetype') === 'task') {
|
|
||||||
var icon = 'cog';
|
|
||||||
if (topic.get('complete')) icon = 'ok';
|
|
||||||
this.renderIcon(buffer, icon, 'task');
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
Discourse.TopicStatusView.reopen({
|
|
||||||
taskComplete: function() {
|
|
||||||
this.rerender();
|
|
||||||
}.observes('topic.complete')
|
|
||||||
})
|
|
||||||
|
|
||||||
}).call(this);
|
|
|
@ -1,14 +0,0 @@
|
||||||
(function() {
|
|
||||||
|
|
||||||
Discourse.TopicSummaryView.prototype.on("appendSummaryInformation", function(childViews) {
|
|
||||||
// Add the poll information
|
|
||||||
if (this.get('topic.archetype') === 'task') {
|
|
||||||
childViews.pushObject(Discourse.View.create({
|
|
||||||
tagName: 'section',
|
|
||||||
classNames: ['information'],
|
|
||||||
templateName: 'discourse_task/templates/about_task'
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}).call(this);
|
|
|
@ -1,15 +0,0 @@
|
||||||
.complete-topic
|
|
||||||
background-color: #eee
|
|
||||||
padding: 5px
|
|
||||||
margin-bottom: 5px
|
|
||||||
font-size: 13px
|
|
||||||
clear: both
|
|
||||||
height: 30px
|
|
||||||
border-radius: 5px
|
|
||||||
|
|
||||||
p
|
|
||||||
float: left
|
|
||||||
padding: 5px 0 0 3px
|
|
||||||
|
|
||||||
button
|
|
||||||
float: right
|
|
Loading…
Reference in New Issue