Permalink
Browse files

Moved to use features of Laconi.ca 0.8 that allow for more useful tag

searching.

Wasn't expecting this plugin to get referenced from the redmine blog
should probably make sure it works a little, it now works a little ;)

twitter support is currently broken, not sure how to make hashtags
like #1 or #2 work in twitter just yet...
  • Loading branch information...
1 parent ea7f1de commit ea424a54b656cbb764dd9ee1957840bfc4abce89 @ciaranj committed Jul 21, 2009
@@ -1,14 +0,0 @@
-module LaconicaHelper
- def self.id_of_issue(issue)
- if issue.nil?
- return nil
- else
- # id= issue.id
- # paddingLength= 3 - (id.to_s.length)
- # if paddingLength > 0
- # paddingLength.times { id= "0" + id.to_s }
- # end
- return issue.id.to_s
- end
- end
-end
@@ -1,23 +1,36 @@
class LaconicaStatus
def self.send_update(msg)
url = "#{self.api_address}/statuses/update.xml?status=" + CGI::escape(msg)
+ debugger
post_to_server(url)
end
- def self.search(query, options={})
- url = "#{self.api_address}/search.json?q=" + CGI::escape(query)
+ # def self.search(query, options={})
+ # url = "#{self.api_address}/search.json?q=" + CGI::escape(query)
+ #
+ # if is_twitter_api
+ # url=url.sub("twitter.com","search.twitter.com")
+ # end
+ #
+ # if options[:results_per_page]
+ # url= url +"&rpp=" + options[:results_per_page].to_s
+ # end
+ # response= post_to_server(url)
+ # return ActiveSupport::JSON::decode(response.body.content)
+ # end
+ def self.find_by_issue(issue, options={})
if is_twitter_api
- url=url.sub("twitter.com","search.twitter.com")
+ # Need to re-implement this.
+ else
+ url = "#{self.api_address}/laconica/tags/timeline/#{issue.id}.json"
+ if options[:results_per_page]
+ url= url +"?count=" + options[:results_per_page].to_s
+ end
+ response= post_to_server(url)
+ return ActiveSupport::JSON::decode(response.body.content)
end
-
- if options[:results_per_page]
- url= url +"&rpp=" + options[:results_per_page].to_s
- end
- response= post_to_server(url)
- return ActiveSupport::JSON::decode(response.body.content)
end
-
private
def self.api_address()
server_url= server_address
View
@@ -3,4 +3,5 @@ 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_issue_updates: Updates about this issue
+laconica_issue_updates: Issue Updates
+laconica_issue_published: Published
View
No changes.
@@ -4,8 +4,8 @@
class LaconicaIssueChangeListener < Redmine::Hook::Listener
def controller_issues_edit_after_save(context={})
if context[:issue]
- id= LaconicaHelper::id_of_issue(context[:issue])
- LaconicaStatus.send_update("@#{User.current.login} just updated issue #{id}")
+ id= context[:issue].id
+ LaconicaStatus.send_update("@#{User.current.login} just updated ##{id}")
end
end
end
@@ -1,4 +1,10 @@
class LaconicaIssueShowHooks < Redmine::Hook::ViewListener
+ include ActionView::Helpers::DateHelper
+
+ def view_layouts_base_html_head(context = {})
+ return stylesheet_link_tag("laconica.css", :plugin => "redmine_laconi.ca")
+ end
+
def view_issues_show_description_bottom(context = {})
if context[:issue]
@@ -11,16 +17,36 @@ def view_issues_show_description_bottom(context = {})
html+="<p><strong>#{l(:laconica_issue_updates)}</strong></p>"
- search_results= LaconicaStatus.search("issue "+ LaconicaHelper::id_of_issue(@issue), {:results_per_page=>5})
-
+ search_results= LaconicaStatus.find_by_issue(@issue, {:results_per_page=>5})
+ html+="<ul class='statuses'>"
unless search_results.nil?
- search_results["results"].each do |result|
- html+='<div class="wiki">'
- html+="<p><img src='" +result['profile_image_url']+"'/> #{result['text']}</p>"
- html+='</div>'
+ search_results.each do |result|
+ html+= issue_helper( result )
end
end
+ html+="</ul>"
return html
end
end
-end
+private
+ def issue_helper(issue)
+ user= issue['user']
+ html=""
+ html+=<<EOS
+<li class='status'>
+ <span class="entry-content" >
+ <img class='avatar' style='vertical-align:top;' width='36' height='36' alt='#{user['name']}' title= '#{user['name']}' src='#{user['profile_image_url']}'/>
+ <span class="entry-details">
+ <span class='status_text'>#{issue['text']}</span><br/>
+ <span class='status_time'>#{l(:laconica_issue_published)} <abbr class='published' title='#{issue['created_at']}'>#{our_time_ago_in_words(issue['created_at'])}</abbr> by #{issue['from_user']} </span>
+ </span>
+ </span>
+</li>
+EOS
+ return html
+ end
+
+ def our_time_ago_in_words(time)
+ return time_ago_in_words(time) + ' ago'
+ end
+end
View
@@ -4,4 +4,5 @@ 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
+ laconica_issue_updates: Issue Updates
+ laconica_issue_published: Published

0 comments on commit ea424a5

Please sign in to comment.