Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Noticed that issues with ids less than 3 digits won't be searchable, …

…so have

changed the default message to 0-pad the issue id up-to a minimum of 3 characters

Also refactored some of the code for tidyness etc.
  • Loading branch information...
commit 1c23e37ec5826d5feb697ed7bdfe9e72cb0ceca9 1 parent c47cf56
@ciaranj authored
View
26 app/models/laconica_status.rb
@@ -0,0 +1,26 @@
+class LaconicaStatus
+ def self.send_update(msg)
+ url = "#{self.api_address}/statuses/update.xml?status=" + CGI::escape(msg)
+ post_to_server(url)
+ end
+
+ def self.search(query)
+ url = "#{self.api_address}/search.json?q=" + CGI::escape(query)
+ post_to_server(url)
+ end
+
+private
+ def self.api_address()
+ server_url= Setting.plugin_laconica_plugin[:server_url]
+ server_url= server_url + "/api" unless server_url=~/twitter/
+ return server_url
+ end
+
+ def self.post_to_server(url)
+ client = HTTPClient.new
+ client.debug_dev = STDOUT if $DEBUG
+ client.set_auth(url, Setting.plugin_laconica_plugin[:server_username], Setting.plugin_laconica_plugin[:server_password])
+ resp = client.post(url)
+ return resp
+ end
+end
View
1  init.rb
@@ -3,6 +3,7 @@
RAILS_DEFAULT_LOGGER.info 'Starting laconi.ca plugin for RedMine'
require_dependency 'laconica_issue_change_listener'
+require_dependency 'laconica_issue_show_hooks'
Redmine::Plugin.register :laconica_plugin do
name 'laconi.ca plugin'
View
3  lang/en.yml
@@ -2,4 +2,5 @@ laconica_label_server_settings: Laconi.ca server configuration settings
laconica_text_settings: Configure the settings for your laconi.ca server here
laconica_label_server_url: laconi.ca host
laconica_label_server_username: Username
-laconica_label_server_password: Password
+laconica_label_server_password: Password
+laconica_issue_updates: Updates about this issue
View
18 lib/laconica_issue_change_listener.rb
@@ -3,15 +3,13 @@
class LaconicaIssueChangeListener < Redmine::Hook::Listener
def controller_issues_edit_after_save(context={})
- status_msg="@#{User.current.login} just updated issue ##{context[:issue].id}"
-
- server_url= Setting.plugin_laconica_plugin[:server_url]
- server_url= server_url + "/api" unless server_url=~/twitter/
- url = "#{server_url}/statuses/update.xml?status=" + CGI::escape(status_msg)
-
- client = HTTPClient.new
- client.debug_dev = STDOUT if $DEBUG
- client.set_auth(url, Setting.plugin_laconica_plugin[:server_username], Setting.plugin_laconica_plugin[:server_password])
- resp = client.post(url)
+ if context[:issue]
+ id= context[:issue].id
+ paddingLength= 3 - (id.to_s.length)
+ if paddingLength > 0
+ paddingLength.times { id= "0" + id.to_s }
+ end
+ LaconicaStatus.send_update("@#{User.current.login} just updated issue ##{id}")
+ end
end
end
View
44 lib/laconica_issue_show_hooks.rb
@@ -0,0 +1,44 @@
+class LaconicaIssueShowHooks < Redmine::Hook::ViewListener
+ def view_issues_show_description_bottom(context = {})
+
+ if context[:issue]
+ @issue = context[:issue]
+ html=""
+ html+= '<hr />'
+ html+= '<div class="contextual">'
+# html+= '<a class="icon icon-comment" href="#">Quote</a>'
+ html+= '</div>'
+
+ html+="<p><strong>#{l(:laconica_issue_updates)}</strong></p>"
+ html+='<div class="wiki">'
+ html+='<p>asdasd</p>'
+ html+='</div>'
+
+
+
+
+# html = '<div class="box" id="statuses">'
+# html += '<h3 class="icon22 icon22-users">Developer Status</h3>'
+
+# Status.recent_updates_for(@project, 5).each do |status|
+# html += <<EOHTML
+# <div>
+# <dl>
+# <dt class="status_user">#{ avatar(status.user) }#{h status.user.name}</dt>
+# <dd class="status_message">
+# <span class="time">#{format_time(status.created_at, true)}:</span>
+# <p>#{format_status_message(status)}</p>
+# </dd>
+# </dl>
+# </div>
+# <div style="clear:both;"></div>
+# EOHTML
+# end
+# html += link_to("View all statuses", :controller => 'statuses', :action => 'index', :id => @project)
+# html += '</div>'
+
+ return html
+ end
+ end
+
+end
View
1  locales/en.yml
@@ -4,3 +4,4 @@ en:
laconica_label_server_url: The url to reach the laconi.ca instance
laconica_label_server_username: Username
laconica_label_server_password: Password
+ laconica_issue_updates: Updates about this issue
Please sign in to comment.
Something went wrong with that request. Please try again.