Commit d9c3be28655e69d77a0f9aeba6a3a50da24eea4f
1 parent
4119cb45
Exists in
master
and in
29 other branches
Fix protocal in generated links
When acessing Noosfero through a properly configured HTTPS setup, all links will now be generated with https (or without an explicit protocol and will just work). Links generated outside of the scope of a request (models, mailers etc) will still use http://. That can be fixed by a localized change to Environment#top_url, but for now I expect everyone using HTTPS to have a proper HTTP -> HTTPS redirection mechanism.
Showing
9 changed files
with
12 additions
and
11 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -862,8 +862,9 @@ module ApplicationHelper |
862 | 862 | end |
863 | 863 | |
864 | 864 | def base_url |
865 | - environment.top_url | |
865 | + environment.top_url(request.scheme) | |
866 | 866 | end |
867 | + alias :top_url :base_url | |
867 | 868 | |
868 | 869 | def helper_for_article(article) |
869 | 870 | article_helper = ActionView::Base.new | ... | ... |
app/helpers/tinymce_helper.rb
... | ... | @@ -11,7 +11,7 @@ module TinymceHelper |
11 | 11 | end |
12 | 12 | |
13 | 13 | def tinymce_init_js options = {} |
14 | - options.merge! :document_base_url => environment.top_url, | |
14 | + options.merge! :document_base_url => top_url, | |
15 | 15 | :content_css => "/stylesheets/tinymce.css,#{macro_css_files}", |
16 | 16 | :plugins => %w[compat3x advlist autolink lists link image charmap print preview hr anchor pagebreak |
17 | 17 | searchreplace wordcount visualblocks visualchars code fullscreen | ... | ... |
app/models/environment.rb
... | ... | @@ -657,8 +657,8 @@ class Environment < ActiveRecord::Base |
657 | 657 | { :controller => 'admin_panel', :action => 'index' } |
658 | 658 | end |
659 | 659 | |
660 | - def top_url | |
661 | - url = 'http://' | |
660 | + def top_url(scheme = 'http') | |
661 | + url = scheme + '://' | |
662 | 662 | url << (Noosfero.url_options.key?(:host) ? Noosfero.url_options[:host] : default_hostname) |
663 | 663 | url << ':' << Noosfero.url_options[:port].to_s if Noosfero.url_options.key?(:port) |
664 | 664 | url << Noosfero.root('') | ... | ... |
app/views/enterprise_registration/basic_information.html.erb
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | |
21 | 21 | <%= labelled_form_for :create_enterprise do |f| %> |
22 | 22 | <%= required f.text_field 'name', :onchange => "updateUrlField(this, 'create_enterprise_identifier')", :size => 40 %> |
23 | - <%= required labelled_form_field(_('Address'), content_tag('code', environment.top_url + "/" + text_field(:create_enterprise, 'identifier', :size => 26))) %> | |
23 | + <%= required labelled_form_field(_('Address'), content_tag('code', top_url + "/" + text_field(:create_enterprise, 'identifier', :size => 26))) %> | |
24 | 24 | <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => :create_enterprise, :profile => @create_enterprise } %> |
25 | 25 | <%= required labelled_form_field(_('Region'), f.select('region_id', @regions)) if @validation == :region %> |
26 | 26 | ... | ... |
app/views/layouts/application-ng.html.erb
... | ... | @@ -14,7 +14,7 @@ |
14 | 14 | |
15 | 15 | <!-- Open Graph --> |
16 | 16 | <meta property="og:type" content="<%= @page ? 'article' : 'website' %>"> |
17 | - <meta property="og:url" content="<%= @page ? url_for(@page.url) : @environment.top_url %>"> | |
17 | + <meta property="og:url" content="<%= @page ? url_for(@page.url) : top_url %>"> | |
18 | 18 | <meta property="og:title" content="<%= h page_title %>"> |
19 | 19 | <meta property="og:site_name" content="<%= profile ? profile.name : @environment.name %>"> |
20 | 20 | <meta property="og:description" content="<%= meta_description_tag(@page) %>"> | ... | ... |
app/views/layouts/application.html.erb
... | ... | @@ -68,7 +68,7 @@ |
68 | 68 | |
69 | 69 | <div id="navigation_bar"> |
70 | 70 | <%= link_to "<span>"+ @environment.name() +"</span>", |
71 | - @environment.top_url, | |
71 | + top_url, | |
72 | 72 | :id=>"menu_link_to_envhome", |
73 | 73 | :title=>@environment.name %> |
74 | 74 | <% unless environment.enabled?(:disable_categories) %> | ... | ... |
plugins/bsc/views/shared/_fields.html.erb
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | <%= hidden_field_tag 'old_bsc_identifier', profile.identifier %> |
32 | 32 | <div id="bsc-formitem"> |
33 | 33 | <%= content_tag('code', |
34 | - environment.top_url + '/ ' + | |
34 | + top_url + '/ ' + | |
35 | 35 | text_field(:profile_data, :identifier, :onchange => "warn_value_change()", :size => 25) |
36 | 36 | ) + |
37 | 37 | content_tag('div', | ... | ... |
public/designs/themes/noosfero/site_title.html.erb
public/designs/themes/profile-base/site_title.html.erb
1 | 1 | <% if File.exists?(File.join(Rails.root, 'public', "/designs/themes/#{environment.theme}/images/thin-logo.png")) %> |
2 | - <%= link_to(image_tag("/designs/themes/#{environment.theme}/images/thin-logo.png"), environment.top_url) %> | |
2 | + <%= link_to(image_tag("/designs/themes/#{environment.theme}/images/thin-logo.png"), top_url) %> | |
3 | 3 | <% else %> |
4 | - <%= link_to(image_tag("/designs/themes/noosfero/images/thin-logo.png"), environment.top_url) %> | |
4 | + <%= link_to(image_tag("/designs/themes/noosfero/images/thin-logo.png"), top_url) %> | |
5 | 5 | <% end %> | ... | ... |