Skip to content
Browse files

Initial Commit

  • Loading branch information...
0 parents commit a6429b3a3e63476dba2a04c7d65d42fa4e0ba34c Brandon Farmer committed Dec 8, 2011
3 README.rdoc
@@ -0,0 +1,3 @@
+= todo_list
+
+Description goes here
54 app/controllers/tasks_controller.rb
@@ -0,0 +1,54 @@
+class TasksController < ApplicationController
+ unloadable
+
+ accept_key_auth :feed
+
+ before_filter :require_logged, :except => [:feed]
+ before_filter :require_key, :only => [:feed]
+
+ def index
+ @tasks = User.current.tasks
+ end
+
+ def create
+ task = User.current.tasks.build(:body => params[:task_body])
+ if task.save
+ flash[:notice] = "Task saved!"
+ else
+ flash[:error] = "Task could not be saved"
+ end
+ redirect_to(:action => :index)
+ end
+
+ def destroy
+ task = User.current.tasks.find(params[:id])
+ task.destroy
+ flash[:notice] = "Task removed!"
+ redirect_to(:action => :index)
+ end
+
+ def feed
+ response.headers["Content-Type"] = "application/xml; charset=utf-8"
+ @tasks = @current_user.tasks
+ render :layout => false
+ end
+
+ private
+
+ def require_logged
+ @current_user = User.current
+ unless @current_user.logged?
+ redirect_to root_path
+ end
+ end
+
+ def require_key
+ @key = params[:key]
+ @current_user = User.find_by_rss_key(@key) if @key
+ unless @current_user
+ render :inline => 'Invalid Key'
+ return false
+ end
+ end
+
+end
2 app/helpers/tasks_helper.rb
@@ -0,0 +1,2 @@
+module TasksHelper
+end
8 app/models/task.rb
@@ -0,0 +1,8 @@
+class Task < ActiveRecord::Base
+ unloadable
+
+ def to_s
+ self.body
+ end
+
+end
18 app/views/tasks/feed.html.builder
@@ -0,0 +1,18 @@
+xml.instruct! :xml, :version => "1.0"
+xml.rss :version => "2.0" do
+ xml.channel do
+ xml.title "Your Tasks"
+ xml.description "Lots of Tasks"
+ xml.link url_for(:action => :index, :only_path => false)
+
+ for task in @tasks
+ xml.item do
+ xml.title "Mark Task As Complete"
+ xml.description task.body
+ xml.pubDate task.created_at.to_s(:rfc822)
+ xml.link url_for(:action => :destroy, :id => task.id, :only_path => false)
+ xml.guid task.id
+ end
+ end
+ end
+end
21 app/views/tasks/index.html.erb
@@ -0,0 +1,21 @@
+<%= stylesheet_link_tag("tasklist.css", :plugin => "redmine_todo_list") %>
+
+<h2>
+ Tasks List
+</h2>
+<p><%= link_to("Show Feed", {:action => :feed, :key => User.current.rss_key}, :class => "atom", :target => "_blank" )%></p>
+<div class="task_form">
+ <% form_tag(:action => :create) do %>
+ <%= text_field_tag("task_body", "", :style => "width: 500px;") %>
+ <%= submit_tag("Save Task") %>
+ <% end %>
+</div>
+
+<div class="task_list">
+ <% @tasks.each do |task| %>
+ <p class="task_content">
+ <%= link_to("Mark Done", {:action => :destroy, :id => task.id}, :class => "task_done_link")%> |
+ <%= task %>
+ </p>
+ <% end %>
+</div>
BIN assets/images/done.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 assets/stylesheets/tasklist.css
@@ -0,0 +1,13 @@
+div.task_form {
+
+}
+
+div.task_list {
+
+}
+
+div.task_list p.task_content {
+ font-size: 12pt;
+ font-weight: bold;
+ color: #666;
+}
3 config/locales/en.yml
@@ -0,0 +1,3 @@
+# English strings go here for Rails i18n
+en:
+ my_label: "My label"
13 db/migrate/20111209015056_create_tasks.rb
@@ -0,0 +1,13 @@
+class CreateTasks < ActiveRecord::Migration
+ def self.up
+ create_table :tasks do |t|
+ t.column :user_id, :integer
+ t.column :body, :string
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :tasks
+ end
+end
20 init.rb
@@ -0,0 +1,20 @@
+require 'redmine'
+
+require 'dispatcher'
+require 'user_tasks_patch'
+require 'principal_patch'
+
+Dispatcher.to_prepare do
+ Principal.send(:include, PrincipalPatch) unless Principal.included_modules.include? PrincipalPatch
+ User.send(:include, UserTasksPatch) unless User.included_modules.include? UserTasksPatch
+end
+
+Redmine::Plugin.register :redmine_user_status do
+ name 'Redmine Task List plugin'
+ author 'Brandon Farmer and Josh Thomas'
+ description 'Allows you to maintain a personal todo list'
+ version '0.0.1'
+
+ menu :top_menu, :todo_list, {:controller => 'tasks', :action => 'index'}, :caption => 'Todo List', :if => Proc.new { User.current.logged? }
+
+end
2 lang/en.yml
@@ -0,0 +1,2 @@
+# English strings go here
+my_label: "My label"
9 lib/principal_patch.rb
@@ -0,0 +1,9 @@
+require_dependency 'principal'
+
+module PrincipalPatch
+ def self.included(base)
+ base.class_eval do
+ unloadable
+ end
+ end
+end
10 lib/user_tasks_patch.rb
@@ -0,0 +1,10 @@
+require 'user'
+
+module UserTasksPatch
+ def self.included(base)
+ base.class_eval do
+ unloadable
+ has_many :tasks
+ end
+ end
+end
9 test/fixtures/tasks.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+one:
+ id: 1
+ user_id: 1
+ body: MyString
+two:
+ id: 2
+ user_id: 1
+ body: MyString
8 test/functional/tasks_controller_test.rb
@@ -0,0 +1,8 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TasksControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
5 test/test_helper.rb
@@ -0,0 +1,5 @@
+# Load the normal Rails helper
+require File.expand_path(File.dirname(__FILE__) + '/../../../../test/test_helper')
+
+# Ensure that we are using the temporary fixture path
+Engines::Testing.set_fixture_path
10 test/unit/task_test.rb
@@ -0,0 +1,10 @@
+require File.dirname(__FILE__) + '/../test_helper'
+
+class TaskTest < ActiveSupport::TestCase
+ fixtures :tasks
+
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end

0 comments on commit a6429b3

Please sign in to comment.
Something went wrong with that request. Please try again.