2 # vendor/plugins/redmine_snipt/init.rb
7 Redmine::Plugin.register :redmine_snipt do
8 name 'Redmine Snipt embed plugin'
9 author 'Emergya ConsultorÃa'
10 description 'Plugin that let the user embed into a wiki page a snippet' +
14 Redmine::WikiFormatting::Macros.register do
15 desc "Embed snippet from Snipt.net. Use:\n\n !{{snipt(id)}}\n\n" +
16 "Example: \n\n !{{snipt(21884)}}\n\n"
17 macro :snipt do |obj, args|
19 result = Net::HTTP.get("snipt.net", "/api/snipts/#{args[0]}.json")
20 snipt = ActiveSupport::JSON.decode result
21 snipt_url = "http://snipt.net/#{snipt['user']}/#{snipt['slug']}"
23 out << content_tag('span', link_to(h(snipt['description']), snipt_url), :class => 'url')
24 out << content_tag('code', snipt['formatted_code'])
25 content_tag('dl', out)