noosfero | 3 new commits pushed to repository

Antonio Terceiro gitlab at gitlab.com
Wed Jan 28 11:12:29 BRST 2015


Antonio Terceiro pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>

Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/4119cb4530d778f3dd8eafd8e832e87735d4e265">4119cb45</a> by Antonio Terceiro
Improve sample pound.cfg

Rails needs that header to know that the whole system is actually being
accessed via HTTPS

- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/d9c3be28655e69d77a0f9aeba6a3a50da24eea4f">d9c3be28</a> by Antonio Terceiro
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.

- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/0645fc42e2c7d10286c9216486c4aeb7ba4e41b5">0645fc42</a> by Antonio Terceiro
Merge branch 'https' (transparent https support)

- - - - -


Changes:

=====================================
app/helpers/application_helper.rb
=====================================
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -862,8 +862,9 @@ module ApplicationHelper
   end
 
   def base_url
-    environment.top_url
+    environment.top_url(request.scheme)
   end
+  alias :top_url :base_url
 
   def helper_for_article(article)
     article_helper = ActionView::Base.new

=====================================
app/helpers/tinymce_helper.rb
=====================================
--- a/app/helpers/tinymce_helper.rb
+++ b/app/helpers/tinymce_helper.rb
@@ -11,7 +11,7 @@ module TinymceHelper
   end
 
   def tinymce_init_js options = {}
-    options.merge! :document_base_url => environment.top_url,
+    options.merge! :document_base_url => top_url,
       :content_css => "/stylesheets/tinymce.css,#{macro_css_files}",
       :plugins => %w[compat3x advlist autolink lists link image charmap print preview hr anchor pagebreak
         searchreplace wordcount visualblocks visualchars code fullscreen

=====================================
app/models/environment.rb
=====================================
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -657,8 +657,8 @@ class Environment < ActiveRecord::Base
     { :controller => 'admin_panel', :action => 'index' }
   end
 
-  def top_url
-    url = 'http://'
+  def top_url(scheme = 'http')
+    url = scheme + '://'
     url << (Noosfero.url_options.key?(:host) ? Noosfero.url_options[:host] : default_hostname)
     url << ':' << Noosfero.url_options[:port].to_s if Noosfero.url_options.key?(:port)
     url << Noosfero.root('')

=====================================
app/views/enterprise_registration/basic_information.html.erb
=====================================
--- a/app/views/enterprise_registration/basic_information.html.erb
+++ b/app/views/enterprise_registration/basic_information.html.erb
@@ -20,7 +20,7 @@
 
   <%= labelled_form_for :create_enterprise do |f| %>
     <%= required f.text_field 'name', :onchange => "updateUrlField(this, 'create_enterprise_identifier')", :size => 40 %>
-    <%= required labelled_form_field(_('Address'), content_tag('code', environment.top_url + "/" + text_field(:create_enterprise, 'identifier', :size => 26))) %>
+    <%= required labelled_form_field(_('Address'), content_tag('code', top_url + "/" + text_field(:create_enterprise, 'identifier', :size => 26))) %>
     <%= render :partial => 'shared/organization_custom_fields', :locals => { :f => f, :object_name => :create_enterprise, :profile => @create_enterprise } %>
     <%= required labelled_form_field(_('Region'), f.select('region_id', @regions)) if @validation == :region %>
 

=====================================
app/views/layouts/application-ng.html.erb
=====================================
--- a/app/views/layouts/application-ng.html.erb
+++ b/app/views/layouts/application-ng.html.erb
@@ -14,7 +14,7 @@
 
     <!-- Open Graph -->
     <meta property="og:type" content="<%= @page ? 'article' : 'website' %>">
-    <meta property="og:url" content="<%= @page ? url_for(@page.url) : @environment.top_url %>">
+    <meta property="og:url" content="<%= @page ? url_for(@page.url) : top_url %>">
     <meta property="og:title" content="<%= h page_title %>">
     <meta property="og:site_name" content="<%= profile ? profile.name : @environment.name %>">
     <meta property="og:description" content="<%= meta_description_tag(@page) %>">

=====================================
app/views/layouts/application.html.erb
=====================================
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -68,7 +68,7 @@
 
         <div id="navigation_bar">
           <%= link_to "<span>"+ @environment.name() +"</span>",
-                      @environment.top_url,
+                        top_url,
                         :id=>"menu_link_to_envhome",
                         :title=>@environment.name  %>
           <% unless environment.enabled?(:disable_categories) %>

=====================================
etc/pound.cfg
=====================================
--- a/etc/pound.cfg
+++ b/etc/pound.cfg
@@ -23,6 +23,7 @@ End
 
 ListenHTTPS
   Address    0.0.0.0
+  AddHeader  "X-Forwarded-Proto: https"
   Port       443
   Cert       "/etc/noosfero/ssl/noosfero.pem"
   Ciphers    "ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM"

=====================================
plugins/bsc/views/shared/_fields.html.erb
=====================================
--- a/plugins/bsc/views/shared/_fields.html.erb
+++ b/plugins/bsc/views/shared/_fields.html.erb
@@ -31,7 +31,7 @@
   <%= hidden_field_tag 'old_bsc_identifier', profile.identifier %>
   <div id="bsc-formitem">
     <%=   content_tag('code',
-            environment.top_url + '/ ' +
+            top_url + '/ ' +
             text_field(:profile_data, :identifier, :onchange => "warn_value_change()", :size => 25)
           ) +
           content_tag('div',

=====================================
public/designs/themes/noosfero/site_title.html.erb
=====================================
--- a/public/designs/themes/noosfero/site_title.html.erb
+++ b/public/designs/themes/noosfero/site_title.html.erb
@@ -1 +1 @@
-<%= link_to(image_tag("/designs/themes/noosfero/images/logo-noosfero.png"), environment.top_url) %>
+<%= link_to(image_tag("/designs/themes/noosfero/images/logo-noosfero.png"), top_url) %>

=====================================
public/designs/themes/profile-base/site_title.html.erb
=====================================
--- a/public/designs/themes/profile-base/site_title.html.erb
+++ b/public/designs/themes/profile-base/site_title.html.erb
@@ -1,5 +1,5 @@
 <% if File.exists?(File.join(Rails.root, 'public', "/designs/themes/#{environment.theme}/images/thin-logo.png")) %>
-  <%= link_to(image_tag("/designs/themes/#{environment.theme}/images/thin-logo.png"), environment.top_url) %>
+  <%= link_to(image_tag("/designs/themes/#{environment.theme}/images/thin-logo.png"), top_url) %>
 <% else %>
-  <%= link_to(image_tag("/designs/themes/noosfero/images/thin-logo.png"), environment.top_url) %>
+  <%= link_to(image_tag("/designs/themes/noosfero/images/thin-logo.png"), top_url) %>
 <% end %>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150128/e2f51da5/attachment-0001.html>


More information about the Noosfero-dev mailing list