Commit 407f3753be9a4e4dbc966d042f7a1fc713354a79
1 parent
979d6052
Exists in
master
and in
48 other branches
Added macro for profile variables
- This macro provides the use of {profile} variable in articles by adding the html class="macro" and data-macro="software_communities_plugin/allow_variables" attribute Signed-off-by: Pedro de Lyra <pedrodelyra@gmail.com> Signed-off-by: Rodrigo Souto <rodrigo@colivre.coop.br> Signed-off-by: Tallys Martins <tallysmartins@yahoo.com.br>
Showing
4 changed files
with
39 additions
and
0 deletions
Show diff stats
src/noosfero-spb/software_communities/lib/macros/allow_variables.rb
0 → 100644
... | ... | @@ -0,0 +1,15 @@ |
1 | +class SoftwareCommunitiesPlugin::AllowVariables < Noosfero::Plugin::Macro | |
2 | + def self.configuration | |
3 | + { :params => [], | |
4 | + :skip_dialog => true, | |
5 | + :title => _("Insert Profile"), | |
6 | + :generator => 'insertProfile();', | |
7 | + :js_files => 'allow_variables.js', | |
8 | + :icon_path => '/designs/icons/tango/Tango/16x16/actions/document-properties.png' | |
9 | + } | |
10 | + end | |
11 | + | |
12 | + def parse(params, inner_html, source) | |
13 | + source.profile.identifier | |
14 | + end | |
15 | +end | ... | ... |
src/noosfero-spb/software_communities/lib/software_communities_plugin.rb
src/noosfero-spb/software_communities/lib/tasks/templates.rake
... | ... | @@ -39,4 +39,23 @@ namespace :templates do |
39 | 39 | end |
40 | 40 | end |
41 | 41 | |
42 | + desc "Copy mail list article from template to all Communities" | |
43 | + task :copy_mail_article => :environment do | |
44 | + article = Profile['software'].articles.find_by_slug('registro-na-lista') | |
45 | + puts "Copying article #{article.title}: " | |
46 | + if article.present? | |
47 | + SoftwareInfo.find_each do |software| | |
48 | + community = software.community | |
49 | + a_copy = article.copy_without_save | |
50 | + a_copy.profile = software.community | |
51 | + a_copy.save if a_copy.profile.present? | |
52 | + box = community.boxes.detect {|x| x.blocks.find_by_title("Participe") } if community.present? | |
53 | + block = box.blocks.find_by_title("Participe") if box.present? | |
54 | + link = block.links.detect { |l| l["name"] == "Lista de E-mails" } if block.present? | |
55 | + link["address"] = "/{profile}/#{a_copy.path}" if link.present? | |
56 | + block.save if block.present? | |
57 | + print "." | |
58 | + end | |
59 | + end | |
60 | + end | |
42 | 61 | end | ... | ... |
src/noosfero-spb/software_communities/public/allow_variables.js
0 → 100644