From cd1a5cd2a0dbf7056f777b12852b65ca7fd65e62 Mon Sep 17 00:00:00 2001 From: Fabio Teixeira Date: Thu, 23 Apr 2015 10:48:23 -0300 Subject: [PATCH] Allow noosfero template system to use javascript --- app/helpers/application_helper.rb | 18 ++++++++++++++++++ app/helpers/layout_helper.rb | 8 +++----- public/designs/templates/lefttopright/javascripts/template.js | 3 +++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 public/designs/templates/lefttopright/javascripts/template.js diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1283599..7820f5b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -707,6 +707,24 @@ module ApplicationHelper javascript_include_tag script if script end + def template_path + if profile.nil? + "/designs/templates/#{environment.layout_template}" + else + "/designs/templates/#{profile.layout_template}" + end + end + + def template_javascript_src + script = File.join template_path, '/javascripts/template.js' + script if File.exists? File.join(Rails.root, 'public', script) + end + + def templete_javascript_ng + script = template_javascript_src + javascript_include_tag script if script + end + def file_field_or_thumbnail(label, image, i) display_form_field label, ( render :partial => (image && image.valid? ? 'shared/show_thumbnail' : 'shared/change_image'), diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index e78aa11..1139aba 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -38,6 +38,8 @@ module LayoutHelper output += theme_javascript_ng.to_s output += javascript_tag 'render_all_jquery_ui_widgets()' + output += templete_javascript_ng.to_s + output end @@ -70,11 +72,7 @@ module LayoutHelper end def template_stylesheet_path - if profile.nil? - "/designs/templates/#{environment.layout_template}/stylesheets/style.css" - else - "/designs/templates/#{profile.layout_template}/stylesheets/style.css" - end + File.join template_path, "/stylesheets/style.css" end diff --git a/public/designs/templates/lefttopright/javascripts/template.js b/public/designs/templates/lefttopright/javascripts/template.js new file mode 100644 index 0000000..db2a098 --- /dev/null +++ b/public/designs/templates/lefttopright/javascripts/template.js @@ -0,0 +1,3 @@ +$(document).ready(function() { + alert("Yup, i'm here !"); +}); -- libgit2 0.21.2