Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removing weird naming posts into issues
- Loading branch information
root
committed
Sep 9, 2012
1 parent
2044aeb
commit 285730c
Showing
5 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class LiSetupController < ApplicationController | ||
unloadable | ||
|
||
def index | ||
setup = LatestIssuesSetup.find_by_id(1) | ||
|
||
if setup == nil | ||
setup = LatestIssuesSetup.create(:max_count => LatestIssuesSetup::DEFAULT_COUNT, :side => LatestIssuesSetup::DEFAULT_SIDE) | ||
end | ||
@setup = setup | ||
end | ||
|
||
def change | ||
setup = LatestIssuesSetup.find_by_id(1) | ||
setup.max_count = params[:count] | ||
setup.side = params[:side] | ||
if setup.save | ||
flash[:notice] = 'Latest Issues setup saved.' | ||
end | ||
redirect_to "/latest-issues" #:action => 'index' | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class LatestIssuesSetup < ActiveRecord::Base | ||
unloadable | ||
|
||
attr_accessible :max_count, :side | ||
|
||
DEFAULT_SIDE = 'left' | ||
DEFAULT_COUNT = 5 | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h2>Latest Issues Configuration</h2> | ||
<%= form_tag("/latest-issues/change") do %> | ||
<dl> | ||
<label>Number of issues on page:</label> | ||
<input type="text" maxsize="2" name="count" value="<%= @setup.max_count %>"/> | ||
</dl><dl> | ||
<label>Which side do you want the plugin on?</label> | ||
<select name="side"> | ||
<option value="left" <% if @setup.side == 'left' %>selected<% end %>>left</option> | ||
<option value="right" <% if @setup.side == 'right' %>selected<% end %>>right</option> | ||
</select> | ||
</dl> | ||
<dl><input type="submit" value="Save"/></dl> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class CreateLatestIssuesSetups < ActiveRecord::Migration | ||
def change | ||
create_table :latest_issues_setups do |t| | ||
t.integer :max_count, :default => 5 | ||
t.string :side, :default => 'left' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module LatestIssues | ||
class ViewHookListener < Redmine::Hook::ViewListener | ||
|
||
def view_welcome_index_left(context={}) | ||
setup = load_setup() | ||
if setup[:side] == "left" | ||
load_issues(setup[:count]) | ||
end | ||
end | ||
|
||
def view_welcome_index_right(context={}) | ||
setup = load_setup() | ||
if setup[:side] == "right" | ||
load_issues(setup[:count]) | ||
end | ||
end | ||
|
||
def load_setup() | ||
require 'plugins/latest_issues/app/models/latest_issues_setup.rb' | ||
setup = LatestIssuesSetup.find_by_id(1) | ||
|
||
if setup == nil | ||
count = LatestIssuesSetup::DEFAULT_COUNT | ||
side = LatestIssuesSetup::DEFAULT_SIDE | ||
else | ||
count = setup.max_count | ||
side = setup.side | ||
end | ||
|
||
{:count => count, :side => side} | ||
end | ||
|
||
def load_issues(count) | ||
html = '<div class="box" id="statuses">' | ||
html += '<h3 class="icon22 icon22-users">Latest Issues</h3><ul>' | ||
issues = Issue.find(:all, :limit => count, :order => "created_on DESC") | ||
issues.each do |issue| | ||
html += <<EOHTML | ||
<li> | ||
#{link_to h(truncate(issue.subject, :length => 60)), :controller => 'issues', :action => 'show', :id => issue } (#{ format_time(issue.created_on)}) #{ issue.assigned_to ? 'assigned to ' + link_to_user(issue.assigned_to) : " not assigned" } | ||
</li> | ||
EOHTML | ||
end | ||
html += '</ul></div>' | ||
return html | ||
end | ||
end | ||
end | ||
|