diff --git a/INSTALL.md b/INSTALL.md index df555ae..d5b04a2 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -186,8 +186,8 @@ Apache instalation # apt-get install apache2 -Apache configuration --------------------- +Configuration - noosfero at / +----------------------------- First you have to enable the following some apache modules: @@ -257,6 +257,62 @@ Now restart your apache server (as root): # invoke-rc.d apache2 restart +Configuration - noosfero at a /subdirectory +------------------------------------------- + +This section describes how to configure noosfero at a subdirectory, what is +specially useful when you want Noosfero to share a domain name with other +applications. For example you can host noosfero at yourdomain.com/social, a +webmail application at yourdomain.com/webmail, and have a static HTML website +at yourdomain.com/. + +**NOTE:** Some plugins might not work well with this setting. Before deploying +this setting, make sure you test that everything you need works properly with +it. + +The configuration is similar to the main configuration instructions, except for +the following points. In the description below, replace '/subdirectory' with +the actual subdirectory you want. + +1) add a `prefix: /subdirectory` line to your thin configuration file (thin.yml). + +1.1) remember to restart the noosfero application server whenever you make +changes to that configuration file. + + # service noosfero restart + +2) add a line saying `export RAILS_RELATIVE_URL_ROOT=/subdirectory` to +/etc/default/noosfero (you can create it with just this line if it does not +exist already). + +3) You should add the following apache configuration to an existing virtual +host (plus the `` section as displayed above): + +``` +Alias /subdirectory /path/to/noosfero/public + + Options FollowSymLinks + AllowOverride None + Order Allow,Deny + Allow from all + + Include /path/to/noosfero/etc/noosfero/apache/cache.conf + + RewriteEngine On + RewriteBase /subdirectory + # Rewrite index to check for static index.html + RewriteRule ^$ index.html [QSA] + # Rewrite to check for Rails cached page + RewriteRule ^([^.]+)$ $1.html [QSA] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^(.*)$ http://localhost:3000%{REQUEST_URI} [P,QSA,L] + +``` + +3.1) remember to reload the apache server whenever any apache configuration +file changes. + + # sudo service apache2 reload Enabling exception notifications ================================ diff --git a/app/models/environment.rb b/app/models/environment.rb index 5653263..2d4a304 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -660,6 +660,7 @@ class Environment < ActiveRecord::Base url = 'http://' 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('') url end diff --git a/app/models/link_list_block.rb b/app/models/link_list_block.rb index 8d03838..4068a68 100644 --- a/app/models/link_list_block.rb +++ b/app/models/link_list_block.rb @@ -78,8 +78,13 @@ class LinkListBlock < Block address end if add !~ /^[a-z]+:\/\// && add !~ /^\// - 'http://' + add + '//' + add else + if root = Noosfero.root + if !add.starts_with?(root) + add = root + add + end + end add end end @@ -96,4 +101,5 @@ class LinkListBlock < Block sanitizer = HTML::WhiteListSanitizer.new sanitizer.sanitize(text) end + end diff --git a/app/views/layouts/application-ng.html.erb b/app/views/layouts/application-ng.html.erb index 2bad06a..346210a 100644 --- a/app/views/layouts/application-ng.html.erb +++ b/app/views/layouts/application-ng.html.erb @@ -19,6 +19,9 @@ + + + <% if @page %> <% @page.body_images_paths.each do |img| %> diff --git a/lib/noosfero.rb b/lib/noosfero.rb index d4f14c1..47af972 100644 --- a/lib/noosfero.rb +++ b/lib/noosfero.rb @@ -3,6 +3,10 @@ require 'fast_gettext' module Noosfero + def self.root(default = nil) + ENV.fetch('RAILS_RELATIVE_URL_ROOT', default) + end + def self.pattern_for_controllers_in_directory(dir) disjunction = controllers_in_directory(dir).join('|') pattern = disjunction.blank? ? '' : ('(' + disjunction + ')') diff --git a/public/designs/icons/tango/style.css b/public/designs/icons/tango/style.css index fa15e5f..cfd7956 100644 --- a/public/designs/icons/tango/style.css +++ b/public/designs/icons/tango/style.css @@ -106,7 +106,7 @@ .icon-activate-user { background-image: url(Tango/16x16/emblems/emblem-system.png) } .icon-deactivate-user { background-image: url(Tango/16x16/emblems/emblem-unreadable.png) } .icon-set-admin-role { background-image: url(mod/16x16/apps/user.png) } -.icon-reset-admin-role { background-image: url(/images/icons-app/person-icon.png) } +.icon-reset-admin-role { background-image: url(../../../images/icons-app/person-icon.png) } .icon-clock { background-image: url(Tango/16x16/actions/appointment.png) } /******************LARGE ICONS********************/ diff --git a/public/designs/templates/leftbar/stylesheets/style.css b/public/designs/templates/leftbar/stylesheets/style.css index de29438..6a5a17a 100644 --- a/public/designs/templates/leftbar/stylesheets/style.css +++ b/public/designs/templates/leftbar/stylesheets/style.css @@ -41,7 +41,7 @@ } .profile-activity-article-forum .profile-activity-lead { - background: url(/images/forum-activity-bg-onecol.png); + background: url(../../../../images/forum-activity-bg-onecol.png); width: 489px; } diff --git a/public/designs/templates/rightbar/stylesheets/style.css b/public/designs/templates/rightbar/stylesheets/style.css index 362d077..a872f8a 100644 --- a/public/designs/templates/rightbar/stylesheets/style.css +++ b/public/designs/templates/rightbar/stylesheets/style.css @@ -41,7 +41,7 @@ } .profile-activity-article-forum .profile-activity-lead { - background: url(/images/forum-activity-bg-onecol.png); + background: url(../../../..//images/forum-activity-bg-onecol.png); width: 489px; } diff --git a/public/designs/themes/base/style.css b/public/designs/themes/base/style.css index 38019d3..62b0966 100644 --- a/public/designs/themes/base/style.css +++ b/public/designs/themes/base/style.css @@ -257,7 +257,7 @@ body, th, td, input { } #navigation .menu-submenu-trigger { - background: #eee url(/images/down-arrow.png) center center no-repeat; + background: #eee url(../../../images/down-arrow.png) center center no-repeat; border: 0px; height: 8px; width: 124px; @@ -1220,28 +1220,28 @@ hr.pre-posts, hr.sep-posts { } .comment-from-owner .comment-wrapper-1 { - background: #fbf7b5 url(/images/comment-owner-bg-N.png) repeat-x; + background: #fbf7b5 url(../../../images/comment-owner-bg-N.png) repeat-x; } .comment-from-owner .comment-wrapper-2 { - background: url(/images/comment-owner-bg-S.png) 0% 100% repeat-x; + background: url(../../../images/comment-owner-bg-S.png) 0% 100% repeat-x; } .comment-from-owner .comment-wrapper-3 { - background: url(/images/comment-owner-bg-L.png) 100% 0% repeat-y; + background: url(../../../images/comment-owner-bg-L.png) 100% 0% repeat-y; } .comment-from-owner .comment-wrapper-4 { - background: url(/images/comment-owner-bg-O.png) 0% 0% repeat-y; + background: url(../../../images/comment-owner-bg-O.png) 0% 0% repeat-y; } .comment-from-owner .comment-wrapper-5 { - background: url(/images/comment-owner-bg-SL.png) 100% 100% no-repeat; + background: url(../../../images/comment-owner-bg-SL.png) 100% 100% no-repeat; } .comment-from-owner .comment-wrapper-6 { - background: url(/images/comment-owner-bg-SO.png) 0% 100% no-repeat; + background: url(../../../images/comment-owner-bg-SO.png) 0% 100% no-repeat; } .comment-from-owner .comment-wrapper-7 { - background: url(/images/comment-owner-bg-NL.png) 100% 0% no-repeat; + background: url(../../../images/comment-owner-bg-NL.png) 100% 0% no-repeat; } .comment-from-owner .comment-wrapper-8 { - background: url(/images/comment-owner-bg-NO.png) 0% 0% no-repeat; + background: url(../../../images/comment-owner-bg-NO.png) 0% 0% no-repeat; } .comment-created-at { diff --git a/public/javascripts/application.js b/public/javascripts/application.js index e33a894..f5bc054 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -5,6 +5,14 @@ function noosfero_init() { // focus_first_field(); it is moving the page view when de form is down. } +var __noosfero_root = null; +function noosfero_root() { + if (__noosfero_root == null) { + __noosfero_root = jQuery('meta[property="noosfero:root"]').attr("content") || ''; + } + return __noosfero_root; +} + /* If applicable, find the first field in which the user can type and move the * keyboard focus to it. * @@ -167,7 +175,7 @@ function loading_done(element_id) { jQuery(element_id).removeClass('small-loading-dark'); } function open_loading(message) { - jQuery('body').prepend("