Commit a4bff7fa3481b20343939ca889c35aaf98afd547

Authored by Leandro Santos
2 parents 43924df5 e6855182

Merge branches 'master' and 'rails3_AI3033-serpro_integration' into rails3_AI3033-serpro_integration

Showing 461 changed files with 8883 additions and 14879 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 461 files displayed.

.ackrc 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +--ignore-dir=log
  2 +--ignore-dir=tmp
  3 +--ignore-dir=pkg
... ...
AUTHORS
... ... @@ -6,6 +6,7 @@ noosfero, that's not a problem).
6 6 Developers
7 7 ==========
8 8  
  9 +Ábner Silva de Oliveira <abner.oliveira@serpro.gov.br>
9 10 Alan Freihof Tygel <alantygel@gmail.com>
10 11 alcampelo <alcampelo@alcampelo.(none)>
11 12 Alessandro Palmeira <alessandro.palmeira@gmail.com>
... ... @@ -43,6 +44,7 @@ Ana Losnak &lt;analosnak@gmail.com&gt;
43 44 Antonio Terceiro + Carlos Morais <terceiro@colivre.coop.br>
44 45 Antonio Terceiro + Paulo Meirelles <terceiro@colivre.coop.br>
45 46 Antonio Terceiro <terceiro@colivre.coop.br>
  47 +Arthur Del Esposte <arthurmde@gmail.com>
46 48 Arthur Del Esposte <arthurmde@yahoo.com.br>
47 49 Aurelio A. Heckert <aurelio@colivre.coop.br>
48 50 Braulio Bhavamitra <brauliobo@gmail.com>
... ... @@ -71,12 +73,14 @@ Caio Salgado + Renan Teruo &lt;caio.salgado@gmail.com&gt;
71 73 Caio Salgado + Renan Teruo + Jefferson Fernandes <jeffs.fernandes@gmail.com>
72 74 Caio Salgado + Renan Teruo <renanteruoc@gmail.com>
73 75 Caio SBA <caio@colivre.coop.br>
  76 +Caio Tiago Oliveira <caiotiago@colivre.coop.br>
74 77 Carlos Andre de Souza <carlos.andre.souza@msn.com>
75 78 Carlos Morais <carlos88morais@gmail.com>
76 79 Carlos Morais + Diego Araújo <diegoamc90@gmail.com>
77 80 Carlos Morais + Eduardo Morais <carlos88morais@gmail.com>
78 81 Carlos Morais + Paulo Meirelles <carlos88morais@gmail.com>
79 82 Carlos Morais + Pedro Leal <carlos88morais@gmail.com>
  83 +Daniela Feitosa <dani@dohko.(none)>
80 84 Daniel Alves + Diego Araújo <danpaulalves@gmail.com>
81 85 Daniel Alves + Diego Araújo <diegoamc90@gmail.com>
82 86 Daniel Alves + Diego Araújo + Guilherme Rojas <danpaulalves@gmail.com>
... ... @@ -117,6 +121,8 @@ Diego Martinez &lt;diegoamc90@gmail.com&gt;
117 121 Diego Martinez <diego@diego-K55A.(none)>
118 122 Diego + Renan <renanteruoc@gmail.com>
119 123 Eduardo Tourinho Edington <eduardo.edington@serpro.gov.br>
  124 +Evandro Jr <evandrojr@gmail.com>
  125 +Evandro Junior <evandrojr@gmail.com>
120 126 Fabio Teixeira <fabio1079@gmail.com>
121 127 Fernanda Lopes <nanda.listas+psl@gmail.com>
122 128 Francisco Marcelo A. Lima Júnior <francisco.lima-junior@serpro.gov.br>
... ... @@ -132,6 +138,7 @@ Italo Valcy &lt;italo@dcc.ufba.br&gt;
132 138 Jefferson Fernandes + Diego Araujo + Rafael Manzo <jeffs.fernandes@gmail.com>
133 139 Jefferson Fernandes + Joao M. M. da Silva <jeffs.fernandes@gmail.com>
134 140 Jefferson Fernandes + Joao M. M. Silva <jeffs.fernandes@gmail.com>
  141 +João da Silva + Eduardo Morais + Rafael Manzo <rr.manzo@gmail.com>
135 142 João da Silva <jaodsilv@linux.ime.usp.br>
136 143 João Marco Maciel da Silva + Rafael Manzo + Renan Teruo <jaodsilv@linux.ime.usp.br>
137 144 João M. M. da Silva + Alessandro Palmeira + Diego Araújo + Caio Salgado <jaodsilv@linux.ime.usp.br>
... ... @@ -163,9 +170,11 @@ João M. M. Silva + Renan Teruo &lt;jaodsilv@linux.ime.usp.br&gt;
163 170 Joenio Costa <joenio@colivre.coop.br>
164 171 Josef Spillner <josef.spillner@tu-dresden.de>
165 172 Junior Silva <junior@bajor.localhost.localdomain>
  173 +Junior Silva <junior@sedeantigo.colivre.coop.br>
166 174 Junior Silva <juniorsilva1001@gmail.com>
167 175 Junior Silva <juniorsilva7@juniorsilva-Aspire-5750Z.(none)>
168 176 Junior Silva <juniorsilva@colivre.coop.br>
  177 +juniorsilva <juniorsilva@QonoS.localhost.localdomain>
169 178 Keilla Menezes <keilla@colivre.coop.br>
170 179 Larissa Reis <larissa@colivre.coop.br>
171 180 Larissa Reis <reiss.larissa@gmail.com>
... ... @@ -176,7 +185,9 @@ Leandro Nunes dos Santos &lt;leandro.santos@serpro.gov.br&gt;
176 185 LinguÁgil 2010 <linguagil.bahia@gmail.com>
177 186 Lucas Melo <lucas@colivre.coop.br>
178 187 Lucas Melo <lucaspradomelo@gmail.com>
  188 +Luciano <lucianopcbr@gmail.com>
179 189 Luis David Aguilar Carlos <ludwig9003@gmail.com>
  190 +Luiz Fernando de Freitas Matos <luiz@luizff.matos@gmail.com>
180 191 Marcos Ramos <ms.ramos@outlook.com>
181 192 Martín Olivera <molivera@solar.org.ar>
182 193 Moises Machado <moises@colivre.coop.br>
... ...
Gemfile
... ... @@ -15,6 +15,8 @@ gem &#39;thin&#39;
15 15 gem 'hpricot'
16 16 gem 'nokogiri'
17 17 gem 'rake', :require => false
  18 +gem 'rest-client'
  19 +gem 'exception_notification'
18 20  
19 21 # FIXME list here all actual dependencies (i.e. the ones in debian/control),
20 22 # with their GEM names (not the Debian package names)
... ... @@ -30,7 +32,6 @@ group :test do
30 32 end
31 33  
32 34 group :cucumber do
33   - gem 'rake'
34 35 gem 'cucumber-rails', :require => false
35 36 gem 'capybara'
36 37 gem 'cucumber'
... ...
Gemfile.lock
... ... @@ -61,7 +61,10 @@ GEM
61 61 database_cleaner (1.2.0)
62 62 diff-lcs (1.1.3)
63 63 erubis (2.7.0)
64   - eventmachine (1.0.3)
  64 + eventmachine (0.12.10)
  65 + exception_notification (4.0.1)
  66 + actionmailer (>= 3.0.4)
  67 + activesupport (>= 3.0.4)
65 68 fast_gettext (0.6.8)
66 69 ffi (1.0.11)
67 70 gherkin (2.4.21)
... ... @@ -75,7 +78,7 @@ GEM
75 78 i18n (>= 0.4.0)
76 79 mime-types (~> 1.16)
77 80 treetop (~> 1.4.8)
78   - metaclass (0.0.4)
  81 + metaclass (0.0.1)
79 82 mime-types (1.19)
80 83 mocha (0.11.3)
81 84 metaclass (~> 0.0.1)
... ... @@ -111,6 +114,8 @@ GEM
111 114 thor (>= 0.14.6, < 2.0)
112 115 rake (0.9.2.2)
113 116 rdoc (3.9.4)
  117 + rest-client (1.6.7)
  118 + mime-types (>= 1.16)
114 119 rmagick (2.13.1)
115 120 rspec (2.10.0)
116 121 rspec-core (~> 2.10.0)
... ... @@ -165,6 +170,7 @@ DEPENDENCIES
165 170 daemons
166 171 dalli
167 172 database_cleaner
  173 + exception_notification
168 174 fast_gettext
169 175 hpricot
170 176 mocha
... ... @@ -175,6 +181,7 @@ DEPENDENCIES
175 181 rails
176 182 rails_autolink
177 183 rake
  184 + rest-client
178 185 rmagick
179 186 rspec
180 187 rspec-rails
... ...
INSTALL.chat.md
1   -XMPP/Chat Client Setup
2   -======================
  1 +XMPP/Chat Setup
  2 +===============
3 3  
4   -To configure XMPP/BOSH in Noosfero you need:
  4 +The samples of config file to configure a XMPP/BOSH server with ejabberd,
  5 +postgresql and apache2 can be found at util/chat directory.
5 6  
6   -* REST Client - http://github.com/archiloque/rest-client
7   -* SystemTimer - http://ph7spot.com/musings/system-timer
8   -* Pidgin data files - http://www.pidgin.im/
  7 +This setup supposes that you are using Noosfero installed via Debian package
  8 +in a production environment.
9 9  
10   -If you use Debian 6.0 (squeeze):
11   -
12   - # apt-get install librestclient-ruby pidgin-data ruby1.8-dev
13   - # gem install SystemTimer
14   -
15   -The samples of config file to configure a XMPP/BOSH server with ejabberd, postgresql and apache2 can be found at util/chat directory.
16   -
17   -XMPP/Chat Server Setup
18   -======================
  10 +Steps
  11 +=====
19 12  
20 13 This is a step-by-step guide to get a XMPP service working, in a Debian system.
21 14  
22 15 ## 1. Install the required packages
23 16  
24   - # apt-get install ejabberd odbc-postgresql
  17 + # apt-get install ejabberd odbc-postgresql librestclient-ruby pidgin-data ruby1.8-dev
  18 + # gem install SystemTimer
25 19  
26 20 ## 2. Ejabberd configuration
27 21  
28   -All the following changes must be done in config file: `/etc/ejabberd/ejabberd.cfg`
29   -
30   -### 2.1. Set the default admin user
31   -
32   - { acl, admin, { user, "john", "www.example.com" } }.
33   - { acl, admin, { user, "bart", "www.example.com" } }.
34   -
35   -### 2.2. Set the default host
36   -
37   - { hosts, [ "www.example.com" ] }.
38   -
39   -### 2.3. Http-Bind activation
40   -
41   - { 5280, ejabberd_http, [
42   - http_bind,
43   - web_admin
44   - ]
45   - }
46   -
47   - (...)
48   -
49   - { modules, [
50   - {mod_http_bind, []},
51   - ...
52   - ] }.
53   -
54   -Ejabberd creates semi-anonymous rooms by default, but Noosfero's Jabber client needs non-anonymous room, then we need to change default params of creation rooms in ejabberd to create non-anonymous rooms.
55   -
56   -In non-anonymous rooms the jabber service sends the new occupant's full JID to all occupants in the room [[1]].
  22 + # cp /usr/share/noosfero/util/chat/ejabberd.cfg /etc/ejabberd/
57 23  
58   -Add option "`{default_room_options, [{anonymous, false}]}`" to `/etc/ejabberd/ejabberd.cfg` in mod_muc session. See below:
  24 +Edit the /etc/ejabberd/ejabberd.cfg file and set your domain on the first 2 lines.
59 25  
60   - { mod_muc, [
61   - %%{host, "conference.@HOST@"},
62   - {access, muc},
63   - {access_create, muc},
64   - {access_persistent, muc},
65   - {access_admin, muc_admin},
66   - {max_users, 500},
67   - {default_room_options, [{anonymous, false}]}
68   - ]},
69   -
70   -[1]: http://xmpp.org/extensions/xep-0045.html#enter-nonanon
71   -
72   -
73   -### 2.4. Authentication method
74   -
75   -To use Postgresql through ODBC, the following modifications must be done:
76   -
77   - * Disable the default method:
78   - `{auth_method, internal}.`
79   -
80   - * Enable autheticantion through ODBC:
81   - `{auth_method, odbc}.`
  26 +## 3. Configuring Postgresql
82 27  
83   - * Set database server name
84   - `{odbc_server, "DSN=PostgreSQLEjabberdNoosfero"}.`
  28 +Give permission to noosfero user create new roles, login as
  29 +postgres user and execute:
85 30  
  31 + $ psql
  32 + postgres=# GRANT CREATE ON DATABASE noosfero TO noosfero;
86 33  
87   -### 2.5. Increase the shaper traffic limit
  34 +Change the postgresql authentication method to md5 instead of ident,
  35 +add the following line to the file /etc/postgresql/8.4/main/pg_hba.conf:
88 36  
89   - { shaper, normal, { maxrate, 10000000 } }.
  37 + # Noosfero user
  38 + local noosfero noosfero md5
90 39  
  40 +(add this line before the following line)
91 41  
92   -### 2.6. Disable unused modules
  42 + # "local" is for Unix domain socket connections only
  43 + local all all ident
93 44  
94   -Unused modules can be disabled, for example:
  45 +Restart postgresql server:
95 46  
96   - * s2s
97   - * web_admin
98   - * mod_pubsub
99   - * mod_irc
100   - * mod_offline
101   - * mod_admin_extra
102   - * mod_register
  47 + # service postgresql restart
103 48  
  49 +Login as noosfero user, and execute:
104 50  
105   -### 2.7. Enable ODBC modules
  51 + $ psql -U noosfero -W noosfero < /usr/share/noosfero/util/chat/postgresql/ejabberd.sql
106 52  
107   - * mod_privacy -> mod_privacy_odbc
108   - * mod_private -> mod_private_odbc
109   - * mod_roster -> mod_roster_odbc
  53 +(see database password in the /etc/noosfero/database.yml file)
110 54  
111   -## 3. Configuring Postgresql
  55 +This will create a new schema inside the noosfero database, called `ejabberd`.
112 56  
113   -Login as noosfero user, and execute:
  57 +Note that there should be at least one domain with `is_default = true` in
  58 +`domains` table, otherwise people won't be able to see their friends online.
114 59  
115   - $ psql noosfero < /path/to/noosfero/util/chat/postgresql/ejabberd.sql
  60 +## 4. ODBC configuration
116 61  
117   -Where `noosfero` may need to be replace by the name of the database used for Noosfero.
  62 +Create the following files:
118 63  
119   -This will create a new schema inside the noosfero database, called `ejabberd`.
  64 + # cp /usr/share/noosfero/util/chat/odbc.ini /etc/
  65 + # cp /usr/share/noosfero/util/chat/odbcinst.ini /etc/
120 66  
121   -Note `noosfero` user should have permission to create Postgresql schemas. Also, there should be at least one domain with `is_default = true` in `domains` table, otherwise people won't be able to see their friends online.
  67 +Edit the odbc.ini file and set the password for the database user, see
  68 +the file /etc/noosfero/database.yml to get the password.
122 69  
123   -## 4. ODBC configuration
  70 +Adjust premissions:
124 71  
125   -The following files must be created:
126   -
127   -`/etc/odbc.ini`:
128   -
129   - [PostgreSQLEjabberdNoosfero]
130   - Description = PostgreSQL Noosfero ejabberd database
131   - Driver = PostgreSQL Unicode
132   - Trace = No
133   - TraceFile = /tmp/psqlodbc.log
134   - Database = noosfero
135   - Servername = localhost
136   - UserName = <DBUSER>
137   - Password = <DBPASS>
138   - Port =
139   - ReadOnly = No
140   - RowVersioning = No
141   - ShowSystemTables = No
142   - ShowOidColumn = No
143   - FakeOidIndex = No
144   - ConnSettings = SET search_path TO ejabberd
145   -
146   -`/etc/odbcinst.ini`:
147   -
148   - [PostgreSQL Unicode]
149   - Description = PostgreSQL ODBC driver (Unicode version)
150   - Driver = /usr/lib/odbc/psqlodbcw.so
151   - Setup = /usr/lib/odbc/libodbcpsqlS.so
152   - Debug = 0
153   - CommLog = 1
154   - UsageCount = 3
  72 + # chmod 640 /etc/odbc.ini
  73 + # chown ejabberd /etc/odbc.ini
155 74  
156 75 ## 4.1 testing all:
157 76  
... ... @@ -159,7 +78,6 @@ The following files must be created:
159 78  
160 79 If the configuration was done right, the message "Connected!" will be displayed.
161 80  
162   -
163 81 ## 5. Enabling kernel polling and SMP in `/etc/default/ejabberd`
164 82  
165 83 POLL=true
... ... @@ -205,32 +123,45 @@ Note: module proxy_http must be enabled:
205 123  
206 124 # a2enmod proxy_http
207 125  
208   -## 8. DNS configuration
  126 +Restart services:
209 127  
210   -For this point, we assume you are using BIND as your DNS server. You need to add the following entries to the DNS zone file corresponding to the domain of your noosfero site:
  128 + # service ejabberd restart
  129 + # service noosfero restart
  130 + # service apache2 restart
211 131  
212   - _xmpp-client._tcp SRV 5 100 5222 master
213   - conference CNAME master
214   - _xmpp-client._tcp.conference SRV 5 100 5222 master
  132 +## 8. Test Apache Configuration
215 133  
216   -If you are running a DNS server other than BIND, you will have to figure out how to create equivalente rules for your zone file. Patches to this documentation are welcome.
  134 +Open in your browser the address:
217 135  
218   -## 9. Testing this Setup
  136 + http://<yout domain>/http-bind
219 137  
220   -Adjust shell limits to proceed with some benchmarks and load tests:
  138 +You should see a page with a message like that:
221 139  
222   - # ulimit −s 256
223   - # ulimit −n 8192
224   - # echo 10 > /proc/sys/net/ipv4/tcp_syn_retries
  140 + ejabberd mod_http_bind
  141 + An implementation of XMPP over BOSH (XEP-0206)
  142 + This web page is only informative. To use HTTP-Bind you need a Jabber/XMPP
  143 + client that supports it.
225 144  
226   -To measure the bandwidth between server and client:
  145 +## 9. Test chat session
227 146  
228   - * at server side:
229   - `# iperf −s`
  147 +Open Noosfero console and execute:
230 148  
231   - * at client side:
232   - `# iperf −c server_ip`
  149 +>> environment = Environment.default
  150 +>> user = Person['guest']
  151 +>> password = user.user.crypted_password
  152 +>> login = user.jid
  153 +>> RubyBOSH.initialize_session(login, password, "http://#{environment.default_hostname}/http-bind", :wait => 30, :hold => 1, :window => 5
233 154  
234   -For heavy load tests, clone and use this software:
  155 +If you have luck, should see something like that:
235 156  
236   - $ git clone http://git.holoscopio.com/git/metal/tester.git
  157 +Ruby-BOSH - SEND
  158 +<body window="5" rid="60265" xmlns="http://jabber.org/protocol/httpbind" xmlns:xmpp="urn:xmpp:xbosh" to="vagrant-debian-squeeze.vagrantup.com" wait="30" xmpp:version="1.0" hold="1"/>
  159 +Ruby-BOSH - SEND
  160 +<body rid="60266" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"><auth mechanism="PLAIN" xmlns="urn:ietf:params:xml:ns:xmpp-sasl">Z3Vlc3RAdmFncmFudC1kZWJpYW4tc3F1ZWV6ZS52YWdyYW50dXAuY29tAGd1ZXN0ADEzZTFhYWVlYjRhYjZlMTA0MmRkNWI1YWY0MzM4MjA1OGJiOWZmNzk=</auth></body>
  161 +Ruby-BOSH - SEND
  162 +<body xmpp:restart="true" rid="60267" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"/>
  163 +Ruby-BOSH - SEND
  164 +<body rid="60268" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"><iq type="set" xmlns="jabber:client" id="bind_29330"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>bosh_9631</resource></bind></iq></body>
  165 +Ruby-BOSH - SEND
  166 +<body rid="60269" xmlns="http://jabber.org/protocol/httpbind" sid="24cdfc43646a2af1059a7060b677c2e11b26f34f" xmlns:xmpp="urn:xmpp:xbosh" xmpp:version="1.0"><iq type="set" xmlns="jabber:client" id="sess_21557"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq></body>
  167 +=> ["guest@vagrant-debian-squeeze.vagrantup.com", "24cdfc43646a2af1059a7060b677c2e11b26f34f", 60270]
... ...
INSTALL.https.md 0 → 100644
... ... @@ -0,0 +1,115 @@
  1 +Setup Noosfero to use HTTPS
  2 +===========================
  3 +
  4 +This document assumes that you have a fully and clean Noosfero
  5 +installation as explained at the `INSTALL.md` file.
  6 +
  7 +SSL certificate
  8 ++++++++++++++++
  9 +
  10 +You should get a valid SSL certificate, but if you want to test
  11 +your setup before, you could generate a self-signed certificate
  12 +as below:
  13 +
  14 + # mkdir /etc/noosfero/ssl
  15 + # cd /etc/noosfero/ssl
  16 + # openssl genrsa 1024 > noosfero.key
  17 + # openssl req -new -x509 -nodes -sha1 -days $[10*365] -key noosfero.key > noosfero.cert
  18 + # cat noosfero.key noosfero.cert > noosfero.pem
  19 +
  20 +There are two ways of using SSL with Noosfero: 1) If you are not using
  21 +Varnish; and 2) If you are using Varnish.
  22 +
  23 +1) If you are are not using Varnish
  24 ++++++++++++++++++++++++++++++++++++
  25 +
  26 +Simply do a redirect in apache to force all connections with SSL:
  27 +
  28 + <VirtualHost *:8080>
  29 + ServerName test.stoa.usp.br
  30 +
  31 + Redirect / https://example.com/
  32 + </VirtualHost>
  33 +
  34 +And set a vhost to receive then:
  35 +
  36 + <VirtualHost *:443>
  37 + ServerName example.com
  38 +
  39 + SSLEngine On
  40 + SSLCertificateFile /etc/ssl/certs/cert.pem
  41 + SSLCertificateKeyFile /etc/ssl/private/cert.key
  42 +
  43 + Include /etc/noosfero/apache/virtualhost.conf
  44 + </VirtualHost>
  45 +
  46 +Be aware that if you had configured varnish, the requests won't reach
  47 +it with this configuration.
  48 +
  49 +2) If you are using Varnish
  50 ++++++++++++++++++++++++++++
  51 +
  52 +Varnish isn't able to communicate with the SSL protocol, so we will
  53 +need some one who do this and Pound[1] can do the job. In order to
  54 +install it in Debian based systems:
  55 +
  56 + $ sudo apt-get install pound
  57 +
  58 +Set Varnish to listen in other port than 80:
  59 +
  60 +/etc/defaults/varnish
  61 +---------------------
  62 +
  63 + DAEMON_OPTS="-a localhost:6081 \
  64 + -T localhost:6082 \
  65 + -f /etc/varnish/default.vcl \
  66 + -S /etc/varnish/secret \
  67 + -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
  68 +
  69 +Configure Pound:
  70 +
  71 + # cp /usr/share/noosfero/etc/pound.cfg /etc/pound/
  72 +
  73 +Edit /etc/pound.cfg and set the IP and domain of your server.
  74 +
  75 +Configure Pound to start at system initialization:
  76 +
  77 +/etc/default/pound
  78 +------------------
  79 +
  80 + startup=1
  81 +
  82 +Set Apache to only listen to localhost:
  83 +
  84 +/etc/apache2/ports.conf
  85 +-----------------------
  86 +
  87 + Listen 127.0.0.1:8080
  88 +
  89 +Restart the services:
  90 +
  91 + $ sudo service apache2 restart
  92 + $ sudo service varnish restart
  93 +
  94 +Start pound:
  95 +
  96 + $ sudo service pound start
  97 +
  98 +[1] http://www.apsis.ch/pound
  99 +
  100 +Noosfero XMPP chat
  101 +++++++++++++++++++
  102 +
  103 +If you want to use chat over HTTPS, then you should add the domain
  104 +and IP of your server in the /etc/hosts file, example:
  105 +
  106 +/etc/hosts
  107 +----------
  108 +
  109 + 192.168.1.86 mydomain.example.com
  110 +
  111 +Also, it's recomended that you remove lines above from the file
  112 +`/etc/apache2/sites-enabled/noosfero`:
  113 +
  114 + RewriteEngine On
  115 + Include /usr/share/noosfero/util/chat/apache/xmpp.conf
... ...
INSTALL.varnish.md
... ... @@ -24,10 +24,6 @@ Install the RPAF apache module (or skip this step if not using apache):
24 24  
25 25 3b) Edit `/etc/apache2/sites-enabled/*`, and change `<VirtualHost *:80>` to `<VirtualHost *:8080>`
26 26  
27   -3c) Restart apache
28   -
29   - # invoke-rc.d apache2 restart
30   -
31 27 4) Varnish configuration
32 28  
33 29 4a) Edit `/etc/default/varnish`
... ... @@ -44,10 +40,6 @@ On manual installations, change `/etc/noosfero/*` to `{Rails.root}/etc/noosfero/
44 40  
45 41 **NOTE**: it is very important that the `*.vcl` files are included in that order, i.e. *first* include `varnish-noosfero.vcl`, and *after* `noosfero-accept-language.cvl`.
46 42  
47   -4c) Restart Varnish
48   -
49   - # invoke-rc.d varnish restart
50   -
51 43 5) Enable varnish logging:
52 44  
53 45 5a) Edit `/etc/default/varnishncsa` and uncomment the line that contains:
... ... @@ -56,8 +48,10 @@ On manual installations, change `/etc/noosfero/*` to `{Rails.root}/etc/noosfero/
56 48  
57 49 The varnish log will be written to `/var/log/varnish/varnishncsa.log` in an apache-compatible format. You should change your statistics generation software (e.g. awstats) to use that instead of apache logs.
58 50  
59   -5b) Restart Varnish Logging service
  51 +Thanks to Cosimo Streppone for varnish-accept-language. See http://github.com/cosimo/varnish-accept-language for more information.
60 52  
61   - # invoke-rc.d varnishncsa restart
  53 +6) Restart services
62 54  
63   -Thanks to Cosimo Streppone for varnish-accept-language. See http://github.com/cosimo/varnish-accept-language for more information.
  55 + # service apache2 restart
  56 + # service varnish restart
  57 + # service varnishncsa restart
... ...
Rakefile
1 1 #!/usr/bin/env rake
  2 +
2 3 # Add your own tasks in files placed in lib/tasks ending in .rake,
3 4 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4 5  
... ...
app/controllers/my_profile/cms_controller.rb
... ... @@ -143,6 +143,7 @@ class CmsController &lt; MyProfileController
143 143 end
144 144  
145 145 @article.profile = profile
  146 + @article.author = user
146 147 @article.last_changed_by = user
147 148 @article.created_by = user
148 149  
... ... @@ -188,7 +189,18 @@ class CmsController &lt; MyProfileController
188 189 end
189 190 if request.post? && params[:uploaded_files]
190 191 params[:uploaded_files].each do |file|
191   - @uploaded_files << UploadedFile.create({:uploaded_data => file, :profile => profile, :parent => @parent, :last_changed_by => user}, :without_protection => true) unless file == ''
  192 + unless file == ''
  193 + @uploaded_files << UploadedFile.create(
  194 + {
  195 + :uploaded_data => file,
  196 + :profile => profile,
  197 + :parent => @parent,
  198 + :last_changed_by => user,
  199 + :author => user,
  200 + },
  201 + :without_protection => true
  202 + )
  203 + end
192 204 end
193 205 @errors = @uploaded_files.select { |f| f.errors.any? }
194 206 if @errors.any?
... ... @@ -232,7 +244,7 @@ class CmsController &lt; MyProfileController
232 244 @current_category = Category.find(params[:category_id])
233 245 @categories = @current_category.children
234 246 end
235   - render :template => 'shared/update_categories', :locals => { :category => @current_category }
  247 + render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'article' }
236 248 end
237 249  
238 250 def publish
... ... @@ -248,12 +260,15 @@ class CmsController &lt; MyProfileController
248 260 end.compact unless params[:marked_groups].nil?
249 261 if request.post?
250 262 @failed = {}
  263 + if @marked_groups.empty?
  264 + return session[:notice] = _("Select some group to publish your article")
  265 + end
251 266 @marked_groups.each do |item|
252 267 task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile)
253 268 begin
254 269 task.finish unless item[:group].moderated_articles?
255 270 rescue Exception => ex
256   - @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name]
  271 + @failed[ex.message] ? @failed[ex.message] << item[:group].name : @failed[ex.message] = [item[:group].name]
257 272 end
258 273 end
259 274 if @failed.blank?
... ...
app/controllers/my_profile/friends_controller.rb
... ... @@ -11,7 +11,7 @@ class FriendsController &lt; MyProfileController
11 11 def remove
12 12 @friend = profile.friends.find(params[:id])
13 13 if request.post? && params[:confirmation]
14   - profile.remove_friend(@friend)
  14 + Friendship.remove_friendship(profile, @friend)
15 15 redirect_to :action => 'index'
16 16 end
17 17 end
... ...
app/controllers/my_profile/memberships_controller.rb
... ... @@ -7,9 +7,9 @@ class MembershipsController &lt; MyProfileController
7 7 ra = profile.role_assignments.find_by_role_id(role.id)
8 8 ra.present? && ra.resource_type == 'Profile'
9 9 end
10   - @filter = params[:filter_type].blank? ? nil : params[:filter_type]
  10 + @filter = params[:filter_type].to_i
11 11 begin
12   - @memberships = @filter.nil? ? profile.memberships : profile.memberships_by_role(environment.roles.find(@filter))
  12 + @memberships = @filter.zero? ? profile.memberships : profile.memberships_by_role(environment.roles.find(@filter))
13 13 rescue ActiveRecord::RecordNotFound
14 14 @memberships = []
15 15 end
... ...
app/controllers/my_profile/profile_editor_controller.rb
... ... @@ -54,7 +54,7 @@ class ProfileEditorController &lt; MyProfileController
54 54 @current_category = Category.find(params[:category_id])
55 55 @categories = @current_category.children
56 56 end
57   - render :template => 'shared/update_categories', :locals => { :category => @current_category }
  57 + render :template => 'shared/update_categories', :locals => { :category => @current_category, :object_name => 'profile_data' }
58 58 end
59 59  
60 60 def header_footer
... ...
app/controllers/public/account_controller.rb
... ... @@ -2,7 +2,7 @@ class AccountController &lt; ApplicationController
2 2  
3 3 no_design_blocks
4 4  
5   - before_filter :login_required, :only => [:activation_question, :accept_terms, :activate_enterprise]
  5 + before_filter :login_required, :only => [:activation_question, :accept_terms, :activate_enterprise, :change_password]
6 6 before_filter :redirect_if_logged_in, :only => [:login, :signup]
7 7 before_filter :protect_from_bots, :only => :signup
8 8  
... ...
app/controllers/public/catalog_controller.rb
... ... @@ -11,7 +11,7 @@ class CatalogController &lt; PublicController
11 11 protected
12 12  
13 13 def check_enterprise_and_environment
14   - unless profile.kind_of?(Enterprise) && @profile.environment.enabled?('products_for_enterprises')
  14 + unless profile.enterprise? && @profile.environment.enabled?('products_for_enterprises')
15 15 redirect_to :controller => 'profile', :profile => profile.identifier, :action => 'index'
16 16 end
17 17 end
... ...
app/controllers/public/content_viewer_controller.rb
... ... @@ -8,49 +8,32 @@ class ContentViewerController &lt; ApplicationController
8 8 helper TagsHelper
9 9  
10 10 def view_page
11   - path = params[:page]
12   - path = path.join('/') if path.kind_of?(Array)
13   - path = "#{path}.#{params[:format]}" if params[:format]
  11 + path = get_path(params[:page], params[:format])
  12 +
14 13 @version = params[:version].to_i
15 14  
16 15 if path.blank?
17   - @page = profile.home_page
18   - if @page.nil?
19   - redirect_to :controller => 'profile', :action => 'index', :profile => profile.identifier
20   - return
21   - end
  16 + @page = profile.home_page
  17 + return if redirected_to_profile_index
22 18 else
23 19 @page = profile.articles.find_by_path(path)
24   - unless @page
25   - page_from_old_path = profile.articles.find_by_old_path(path)
26   - if page_from_old_path
27   - redirect_to profile.url.merge(:page => page_from_old_path.explode_path)
28   - return
29   - end
30   - end
  20 + return if redirected_page_from_old_path(path)
31 21 end
32 22  
33 23 return unless allow_access_to_page(path)
34 24  
35 25 if @version > 0
36 26 return render_access_denied unless @page.display_versions?
37   - @versioned_article = @page.versions.find_by_version(@version)
38   - if @versioned_article && @page.versions.latest.version != @versioned_article.version
39   - render :template => 'content_viewer/versioned_article.html.erb'
40   - return
41   - end
  27 + return if rendered_versioned_article
42 28 end
43 29  
44 30 redirect_to_translation and return if @page.profile.redirect_l10n
45 31  
46   - if request.post?
47   - if @page.forum? && @page.has_terms_of_use && params[:terms_accepted] == "true"
48   - @page.add_agreed_user(user)
49   - end
50   - elsif !@page.parent.nil? && @page.parent.forum?
51   - unless @page.parent.agrees_with_terms?(user)
52   - redirect_to @page.parent.url
53   - end
  32 + if request.post? && @page.forum?
  33 + process_forum_terms_of_use(user, params[:terms_accepted])
  34 + elsif is_a_forum_topic?(@page) && !@page.parent.agrees_with_terms?(user)
  35 + redirect_to @page.parent.url
  36 + return
54 37 end
55 38  
56 39 # At this point the page will be showed
... ... @@ -58,64 +41,22 @@ class ContentViewerController &lt; ApplicationController
58 41  
59 42 @page = FilePresenter.for @page
60 43  
61   - if @page.download? params[:view]
62   - headers['Content-Type'] = @page.mime_type
63   - headers.merge! @page.download_headers
64   - data = @page.data
65   -
66   - # TODO test the condition
67   - if data.nil?
68   - raise "No data for file"
69   - end
70   -
71   - render :text => data, :layout => false
72   - return
73   - end
  44 + return if rendered_file_download(params[:view])
74 45  
75 46 @form_div = params[:form]
76 47  
77 48 #FIXME see a better way to do this. It's not need to pass this variable anymore
78 49 @comment = Comment.new
79 50  
80   - if @page.has_posts?
81   - posts = if params[:year] and params[:month]
82   - filter_date = DateTime.parse("#{params[:year]}-#{params[:month]}-01")
83   - @page.posts.by_range(filter_date..filter_date.at_end_of_month)
84   - else
85   - @page.posts
86   - end
87   -
88   - #FIXME Need to run this before the pagination because this version of
89   - # will_paginate returns a will_paginate collection instead of a
90   - # relation.
91   - blog_with_translation = @page.blog? && @page.display_posts_in_current_language?
92   - posts = posts.native_translations if blog_with_translation
93   -
94   - @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))).to_a
95   -
96   - if blog_with_translation
97   - @posts.replace @posts.map{ |p| p.get_translation_to(FastGettext.locale) }.compact
98   - end
99   - end
  51 + process_page_posts(params)
100 52  
101 53 if @page.folder? && @page.gallery?
102   - @images = @page.images.select{ |a| a.display_to? user }
103   - @images = @images.paginate(:per_page => per_page, :page => params[:npage]) unless params[:slideshow]
  54 + @images = get_images(@page, params[:npage], params[:slideshow])
104 55 end
105 56  
106   - @unfollow_form = params[:unfollow] && params[:unfollow] == 'true'
107   - if params[:unfollow] && params[:unfollow] == 'commit' && request.post?
108   - @page.followers -= [params[:email]]
109   - if @page.save
110   - session[:notice] = _("Notification of new comments to '%s' was successfully canceled") % params[:email]
111   - end
112   - end
  57 + process_page_followers(params)
113 58  
114   - @comments = @page.comments.without_spam
115   - @comments = @plugins.filter(:unavailable_comments, @comments)
116   - @comments_count = @comments.count
117   - @comments = @comments.without_reply.paginate(:per_page => per_page, :page => params[:comment_page] )
118   - @comment_order = params[:comment_order].nil? ? 'oldest' : params[:comment_order]
  59 + process_comments(params)
119 60  
120 61 if request.xhr? and params[:comment_order]
121 62 if @comment_order == 'newest'
... ... @@ -133,7 +74,7 @@ class ContentViewerController &lt; ApplicationController
133 74 end
134 75  
135 76 def versions_diff
136   - path = params[:page].join('/')
  77 + path = params[:page]
137 78 @page = profile.articles.find_by_path(path)
138 79 @v1, @v2 = @page.versions.find_by_version(params[:v1]), @page.versions.find_by_version(params[:v2])
139 80 end
... ... @@ -203,4 +144,129 @@ class ContentViewerController &lt; ApplicationController
203 144 user_agent.match(/crawler/) ||
204 145 user_agent.match(/\(.*https?:\/\/.*\)/)
205 146 end
  147 +
  148 + def get_path(page, format = nil)
  149 + path = page
  150 + path = path.join('/') if path.kind_of?(Array)
  151 + path = "#{path}.#{format}" if format
  152 +
  153 + return path
  154 + end
  155 +
  156 + def redirected_to_profile_index
  157 + if @page.nil?
  158 + redirect_to :controller => 'profile', :action => 'index', :profile => profile.identifier
  159 + return true
  160 + end
  161 +
  162 + return false
  163 + end
  164 +
  165 + def redirected_page_from_old_path(path)
  166 + unless @page
  167 + page_from_old_path = profile.articles.find_by_old_path(path)
  168 + if page_from_old_path
  169 + redirect_to profile.url.merge(:page => page_from_old_path.explode_path)
  170 + return true
  171 + end
  172 + end
  173 +
  174 + return false
  175 + end
  176 +
  177 + def process_forum_terms_of_use(user, terms_accepted = nil)
  178 + if @page.forum? && @page.has_terms_of_use && terms_accepted == "true"
  179 + @page.add_agreed_user(user)
  180 + end
  181 + end
  182 +
  183 + def is_a_forum_topic? (page)
  184 + return (!@page.parent.nil? && @page.parent.forum?)
  185 + end
  186 +
  187 + def rendered_versioned_article
  188 + @versioned_article = @page.versions.find_by_version(@version)
  189 + if @versioned_article && @page.versions.latest.version != @versioned_article.version
  190 + render :template => 'content_viewer/versioned_article.html.erb'
  191 + return true
  192 + end
  193 +
  194 + return false
  195 + end
  196 +
  197 + def rendered_file_download(view = nil)
  198 + if @page.download? view
  199 + headers['Content-Type'] = @page.mime_type
  200 + headers.merge! @page.download_headers
  201 + data = @page.data
  202 +
  203 + # TODO test the condition
  204 + if data.nil?
  205 + raise "No data for file"
  206 + end
  207 +
  208 + render :text => data, :layout => false
  209 + return true
  210 + end
  211 +
  212 + return false
  213 + end
  214 +
  215 + def process_page_posts(params)
  216 + if @page.has_posts?
  217 + posts = get_posts(params[:year], params[:month])
  218 +
  219 + posts = posts.includes(:parent, {:profile => [:domains, :environment]}, :author)
  220 +
  221 + #FIXME Need to run this before the pagination because this version of
  222 + # will_paginate returns a will_paginate collection instead of a
  223 + # relation.
  224 + posts = posts.native_translations if blog_with_translation?(@page)
  225 +
  226 + @posts = posts.paginate({ :page => params[:npage], :per_page => @page.posts_per_page }.merge(Article.display_filter(user, profile))).to_a
  227 +
  228 + if blog_with_translation?(@page)
  229 + @posts.replace @posts.map{ |p| p.get_translation_to(FastGettext.locale) }.compact
  230 + end
  231 + end
  232 + end
  233 +
  234 + def get_posts(year = nil, month = nil)
  235 + if year && month
  236 + filter_date = DateTime.parse("#{year}-#{month}-01")
  237 + return @page.posts.by_range(filter_date..filter_date.at_end_of_month)
  238 + else
  239 + return @page.posts
  240 + end
  241 + end
  242 +
  243 + def blog_with_translation?(page)
  244 + return (page.blog? && page.display_posts_in_current_language?)
  245 + end
  246 +
  247 + def get_images(page, npage, slideshow)
  248 + images = page.images.select{ |a| a.display_to? user }
  249 + images = images.paginate(:per_page => per_page, :page => npage) unless slideshow
  250 +
  251 + return images
  252 + end
  253 +
  254 + def process_page_followers(params)
  255 + @unfollow_form = params[:unfollow] == 'true'
  256 + if params[:unfollow] == 'commit' && request.post?
  257 + @page.followers -= [params[:email]]
  258 + if @page.save
  259 + session[:notice] = _("Notification of new comments to '%s' was successfully canceled") % params[:email]
  260 + end
  261 + end
  262 + end
  263 +
  264 + def process_comments(params)
  265 + @comments = @page.comments.without_spam
  266 + @comments = @plugins.filter(:unavailable_comments, @comments)
  267 + @comments_count = @comments.count
  268 + @comments = @comments.without_reply.paginate(:per_page => per_page, :page => params[:comment_page] )
  269 + @comment_order = params[:comment_order].nil? ? 'oldest' : params[:comment_order]
  270 + end
  271 +
206 272 end
... ...
app/controllers/public/profile_controller.rb
... ... @@ -51,7 +51,7 @@ class ProfileController &lt; PublicController
51 51  
52 52 def communities
53 53 if is_cache_expired?(profile.communities_cache_key(params))
54   - @communities = profile.communities.includes(relations_to_include).paginate(:per_page => per_page, :page => params[:npage])
  54 + @communities = profile.communities.includes(relations_to_include).paginate(:per_page => per_page, :page => params[:npage], :total_entries => profile.communities.count)
55 55 end
56 56 end
57 57  
... ... @@ -202,7 +202,8 @@ class ProfileController &lt; PublicController
202 202 end
203 203  
204 204 def more_comments
205   - activity = ActionTracker::Record.find(:first, :conditions => {:id => params[:activity], :user_id => @profile})
  205 + profile_filter = @profile.person? ? {:user_id => @profile} : {:target_id => @profile}
  206 + activity = ActionTracker::Record.find(:first, :conditions => {:id => params[:activity]}.merge(profile_filter))
206 207 comments_count = activity.comments.count
207 208 comment_page = (params[:comment_page] || 1).to_i
208 209 comments_per_page = 5
... ...
app/helpers/application_helper.rb
... ... @@ -312,13 +312,13 @@ module ApplicationHelper
312 312 raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?'
313 313 end
314 314  
315   - def view_for_profile_actions(klass)
316   - raise ArgumentError, 'No profile actions view for this class.' if klass.nil?
317   -
318   - name = klass.name.underscore
319   - return "blocks/profile_info_actions/" + name + '.html.erb' if File.exists?(Rails.root.join('app', 'views', 'blocks', 'profile_info_actions', name + '.html.erb'))
320   -
321   - view_for_profile_actions(klass.superclass)
  315 + def render_profile_actions klass
  316 + name = klass.to_s.underscore
  317 + begin
  318 + render "blocks/profile_info_actions/#{name}"
  319 + rescue ActionView::MissingTemplate
  320 + render_profile_actions klass.superclass
  321 + end
322 322 end
323 323  
324 324 def user
... ... @@ -671,7 +671,7 @@ module ApplicationHelper
671 671  
672 672 def theme_javascript_ng
673 673 script = File.join(theme_path, 'theme.js')
674   - if File.exists?(Rails.root.join('public', script))
  674 + if File.exists?(File.join(Rails.root, 'public', script))
675 675 javascript_include_tag script
676 676 else
677 677 nil
... ... @@ -1002,17 +1002,26 @@ module ApplicationHelper
1002 1002 def display_category_menu(block, categories, root = true)
1003 1003 categories = categories.sort{|x,y| x.name <=> y.name}
1004 1004 return "" if categories.blank?
1005   - content_tag(:ul,
  1005 + content_tag(:ul) do
1006 1006 categories.map do |category|
1007 1007 category_path = category.kind_of?(ProductCategory) ? {:controller => 'search', :action => 'assets', :asset => 'products', :product_category => category.id} : { :controller => 'search', :action => 'category_index', :category_path => category.explode_path }
1008   - category.display_in_menu? ?
1009   - content_tag(:li,
1010   - ( !category.is_leaf_displayable_in_menu? ? content_tag(:a, collapsed_item_icon, :href => "#", :id => "block_#{block.id}_category_#{category.id}", :class => 'category-link-expand ' + (root ? 'category-root' : 'category-no-root'), :onclick => "expandCategory(#{block.id}, #{category.id}); return false", :style => 'display: none') : leaf_item_icon) +
1011   - link_to(content_tag(:span, category.name, :class => 'category-name'), category_path, :class => ("category-leaf" if category.is_leaf_displayable_in_menu?)) +
1012   - content_tag(:div, display_category_menu(block, category.children, false), :id => "block_#{block.id}_category_content_#{category.id}", :class => 'child-category')
1013   - ) : ''
1014   - end
1015   - ) +
  1008 + if category.display_in_menu?
  1009 + content_tag(:li) do
  1010 + if !category.is_leaf_displayable_in_menu?
  1011 + content_tag(:a, collapsed_item_icon, :href => "#", :id => "block_#{block.id}_category_#{category.id}", :class => "category-link-expand " + (root ? "category-root" : "category-no-root"), :onclick => "expandCategory(#{block.id}, #{category.id}); return false", :style => "display: none")
  1012 + else
  1013 + leaf_item_icon
  1014 + end +
  1015 + link_to(content_tag(:span, category.name, :class => "category-name"), category_path, :class => ("category-leaf" if category.is_leaf_displayable_in_menu?)) +
  1016 + content_tag(:div, :id => "block_#{block.id}_category_content_#{category.id}", :class => 'child-category') do
  1017 + display_category_menu(block, category.children, false)
  1018 + end
  1019 + end
  1020 + else
  1021 + ""
  1022 + end
  1023 + end.join.html_safe
  1024 + end +
1016 1025 content_tag(:p) +
1017 1026 (root ? javascript_tag("
1018 1027 jQuery('.child-category').hide();
... ... @@ -1086,7 +1095,7 @@ module ApplicationHelper
1086 1095 result
1087 1096 end
1088 1097  
1089   - def manage_link(list, kind)
  1098 + def manage_link(list, kind, title)
1090 1099 if list.present?
1091 1100 link_to_all = nil
1092 1101 if list.count > 5
... ... @@ -1099,19 +1108,23 @@ module ApplicationHelper
1099 1108 if link_to_all
1100 1109 link << link_to_all
1101 1110 end
1102   - render :partial => "shared/manage_link", :locals => {:link => link, :kind => kind.to_s}
  1111 + render :partial => "shared/manage_link", :locals => {:link => link, :kind => kind.to_s, :title => title}
1103 1112 end
1104 1113 end
1105 1114  
1106 1115 def manage_enterprises
1107   - return unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu)
1108   - manage_link(user.enterprises, :enterprises)
  1116 + return '' unless user && user.environment.enabled?(:display_my_enterprises_on_user_menu)
  1117 + manage_link(user.enterprises, :enterprises, _('My enterprises')).to_s
1109 1118 end
1110 1119  
1111 1120 def manage_communities
1112   - return unless user && user.environment.enabled?(:display_my_communities_on_user_menu)
  1121 + return '' unless user && user.environment.enabled?(:display_my_communities_on_user_menu)
1113 1122 administered_communities = user.communities.more_popular.select {|c| c.admins.include? user}
1114   - manage_link(administered_communities, :communities)
  1123 + manage_link(administered_communities, :communities, _('My communities')).to_s
  1124 + end
  1125 +
  1126 + def admin_link
  1127 + user.is_admin?(environment) ? link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', environment.admin_url, :title => _("Configure the environment"), :class => 'admin-link') : ''
1115 1128 end
1116 1129  
1117 1130 def usermenu_logged_in
... ... @@ -1123,9 +1136,9 @@ module ApplicationHelper
1123 1136  
1124 1137 (_("<span class='welcome'>Welcome,</span> %s") % link_to("<i style='background-image:url(#{user.profile_custom_icon(gravatar_default)})'></i><strong>#{user.identifier}</strong>", user.public_profile_url, :id => "homepage-link", :title => _('Go to your homepage'))) +
1125 1138 render_environment_features(:usermenu) +
1126   - link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', @environment.admin_url, :title => _("Configure the environment"), :class => 'admin-link') +
1127   - manage_enterprises.to_s +
1128   - manage_communities.to_s +
  1139 + admin_link +
  1140 + manage_enterprises +
  1141 + manage_communities +
1129 1142 link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', user.admin_url, :class => 'ctrl-panel', :title => _("Configure your personal account and content")) +
1130 1143 pending_tasks_count +
1131 1144 link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system"))
... ... @@ -1210,22 +1223,9 @@ module ApplicationHelper
1210 1223 end
1211 1224  
1212 1225 def add_zoom_to_images
1213   - stylesheet_link_tag('fancybox') +
1214   - javascript_include_tag('jquery.fancybox-1.3.4.pack') +
1215   - javascript_tag("jQuery(function($) {
1216   - $(window).load( function() {
1217   - $('#article .article-body img').each( function(index) {
1218   - var original = original_image_dimensions($(this).attr('src'));
1219   - if ($(this).width() < original['width'] || $(this).height() < original['height']) {
1220   - $(this).wrap('<div class=\"zoomable-image\" />');
1221   - $(this).parent('.zoomable-image').attr('style', $(this).attr('style'));
1222   - $(this).attr('style', '');
1223   - $(this).after(\'<a href=\"' + $(this).attr('src') + '\" class=\"zoomify-image\"><span class=\"zoomify-text\">%s</span></a>');
1224   - }
1225   - });
1226   - $('.zoomify-image').fancybox();
1227   - });
1228   - });" % _('Zoom in'))
  1226 + stylesheet_link_tag('jquery.fancybox') +
  1227 + javascript_include_tag('jquery.fancybox.pack') +
  1228 + javascript_tag("apply_zoom_to_images(#{_('Zoom in').to_json})")
1229 1229 end
1230 1230  
1231 1231 def render_dialog_error_messages(instance_name)
... ... @@ -1360,7 +1360,7 @@ module ApplicationHelper
1360 1360 @message = _("The content here is available to %s's friends only.") % profile.short_name
1361 1361 else
1362 1362 @action = :join
1363   - @message = _('The contents in this community is available to members only.')
  1363 + @message = _('The contents in this profile is available to members only.')
1364 1364 end
1365 1365 @no_design_blocks = true
1366 1366 end
... ...
app/helpers/block_helper.rb
... ... @@ -6,19 +6,20 @@ module BlockHelper
6 6 content_tag 'h3', content_tag('span', h(title)), :class => tag_class
7 7 end
8 8  
9   - def highlights_block_config_image_fields(block, image={})
  9 + def highlights_block_config_image_fields(block, image={}, row_number=nil)
10 10 "
11   - <tr class=\"image-data-line\">
  11 + <tr class=\"image-data-line\" data-row-number='#{row_number}'>
12 12 <td>
13 13 #{select_tag 'block[images][][image_id]', content_tag(:option) + option_groups_from_collection_for_select(block.folder_choices, :images, :name, :id, :name, image[:image_id].to_i).html_safe}
14 14 </td>
15 15 <td>#{text_field_tag 'block[images][][address]', image[:address], :class => 'highlight-address', :size => 20}</td>
16 16 <td>#{text_field_tag 'block[images][][position]', image[:position], :class => 'highlight-position', :size => 1}</td>
17   - </tr><tr class=\"image-title\">
  17 + </tr><tr class=\"image-title\" data-row-number='#{row_number}'>
18 18 <td colspan=\"3\"><label>#{
19 19 content_tag('span', _('Title')) +
20 20 text_field_tag('block[images][][title]', image[:title], :class => 'highlight-title', :size => 45)
21 21 }</label></td>
  22 + <td>#{link_to '', '#', :class=>'button icon-button icon-delete delete-highlight', :confirm=>_('Are you sure you want to remove this highlight')}</td>
22 23 </tr>
23 24 "
24 25 end
... ...
app/helpers/blog_helper.rb
... ... @@ -17,13 +17,13 @@ module BlogHelper
17 17 _('Configure blog')
18 18 end
19 19  
20   - def list_posts(articles, format = 'full')
  20 + def list_posts(articles, format = 'full', paginate = true)
21 21 pagination = will_paginate(articles, {
22 22 :param_name => 'npage',
23 23 :previous_label => _('&laquo; Newer posts'),
24 24 :next_label => _('Older posts &raquo;'),
25 25 :params => {:action=>"view_page", :page=>articles.first.parent.path.split('/'), :controller=>"content_viewer"}
26   - }) if articles.present?
  26 + }) if articles.present? && paginate
27 27 content = []
28 28 artic_len = articles.length
29 29 articles.each_with_index{ |art,i|
... ... @@ -45,9 +45,9 @@ module BlogHelper
45 45  
46 46 def display_post(article, format = 'full')
47 47 no_comments = (format == 'full') ? false : true
  48 + title = article_title(article, :no_comments => no_comments)
48 49 html = send("display_#{format}_format", FilePresenter.for(article)).html_safe
49   -
50   - article_title(article, :no_comments => no_comments) + html
  50 + title + html
51 51 end
52 52  
53 53 def display_full_format(article)
... ...
app/helpers/content_viewer_helper.rb
... ... @@ -10,7 +10,7 @@ module ContentViewerHelper
10 10 end
11 11  
12 12 def number_of_comments(article)
13   - display_number_of_comments(article.comments.without_spam.count)
  13 + display_number_of_comments(article.comments_count - article.spam_comments_count)
14 14 end
15 15  
16 16 def article_title(article, args = {})
... ... @@ -26,7 +26,7 @@ module ContentViewerHelper
26 26 end
27 27 title << content_tag('span',
28 28 content_tag('span', show_date(article.published_at), :class => 'date') +
29   - content_tag('span', _(", by %s") % link_to(article.author_name, article.author_url), :class => 'author') +
  29 + content_tag('span', _(", by %s") % (article.author ? link_to(article.author_name, article.author_url) : article.author_name), :class => 'author') +
30 30 content_tag('span', comments, :class => 'comments'),
31 31 :class => 'created-at'
32 32 )
... ...
app/helpers/folder_helper.rb
... ... @@ -5,15 +5,17 @@ module FolderHelper
5 5 include ShortFilename
6 6 include ArticleHelper
7 7  
8   - def list_articles(articles, recursive = false)
9   - if !articles.blank?
10   - articles = articles.paginate(
  8 + def list_contents(configure={})
  9 + configure[:recursive] ||= false
  10 + configure[:list_type] ||= :folder
  11 + if !configure[:contents].blank?
  12 + configure[:contents] = configure[:contents].paginate(
11 13 :order => "updated_at DESC",
12 14 :per_page => 10,
13 15 :page => params[:npage]
14 16 )
15 17  
16   - render :file => 'shared/articles_list', :locals => {:articles => articles, :recursive => recursive}
  18 + render :file => 'shared/content_list', :locals => configure
17 19 else
18 20 content_tag('em', _('(empty folder)'))
19 21 end
... ... @@ -23,21 +25,33 @@ module FolderHelper
23 25 articles.select {|article| article.display_to?(user)}
24 26 end
25 27  
26   - def display_article_in_listing(article, recursive = false, level = 0)
27   - article = FilePresenter.for article
28   - article_link = if article.image?
29   - link_to('&nbsp;' * (level * 4) + image_tag(icon_for_article(article)) + short_filename(article.name), article.url.merge(:view => true))
  28 + def display_content_in_listing(configure={})
  29 + recursive = configure[:recursive] || false
  30 + list_type = configure[:list_type] || :folder
  31 + level = configure[:level] || 0
  32 + content = FilePresenter.for configure[:content]
  33 + content_link = if content.image?
  34 + link_to('&nbsp;' * (level * 4) +
  35 + image_tag(icon_for_article(content)) + short_filename(content.name),
  36 + content.url.merge(:view => true)
  37 + )
30 38 else
31   - link_to('&nbsp;' * (level * 4) + short_filename(article.name), article.url.merge(:view => true), :class => icon_for_article(article))
  39 + link_to('&nbsp;' * (level * 4) +
  40 + short_filename(content.name),
  41 + content.url.merge(:view => true), :class => icon_for_article(content)
  42 + )
32 43 end
33 44 result = content_tag(
34 45 'tr',
35   - content_tag('td', article_link )+
36   - content_tag('td', show_date(article.updated_at), :class => 'last-update'),
37   - :class => 'sitemap-item'
  46 + content_tag('td', content_link ) +
  47 + content_tag('td', show_date(content.updated_at), :class => 'last-update'),
  48 + :class => "#{list_type}-item"
38 49 )
39 50 if recursive
40   - result + article.children.map {|item| display_article_in_listing(item, recursive, level + 1) }.join('')
  51 + result + content.children.map {|item|
  52 + display_content_in_listing :content=>item, :recursive=>recursive,
  53 + :list_type=>list_type, :level=>level+1
  54 + }.join("\n")
41 55 else
42 56 result
43 57 end
... ...
app/mailers/user_mailer.rb
... ... @@ -15,10 +15,12 @@ class UserMailer &lt; ActionMailer::Base
15 15 end
16 16  
17 17 def activation_code(user)
18   - @recipient = user.name,
  18 + @recipient = user.name
19 19 @activation_code = user.activation_code
20 20 @environment = user.environment.name
21 21 @url = user.environment.top_url
  22 + @redirection = (true if user.return_to)
  23 + @join = (user.community_to_join if user.community_to_join)
22 24  
23 25 mail(
24 26 from: "#{user.environment.name} <#{user.environment.contact_email}>",
... ...
app/models/article.rb
... ... @@ -2,7 +2,7 @@ require &#39;hpricot&#39;
2 2  
3 3 class Article < ActiveRecord::Base
4 4  
5   - attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, :allow_members_to_edit, :translation_of_id, :language, :license_id, :parent_id, :display_posts_in_current_language, :category_ids, :posts_per_page, :moderate_comments, :accept_comments, :feed, :published, :source, :highlighted, :notify_comments, :display_hits, :slug, :external_feed_builder, :display_versions
  5 + attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, :allow_members_to_edit, :translation_of_id, :language, :license_id, :parent_id, :display_posts_in_current_language, :category_ids, :posts_per_page, :moderate_comments, :accept_comments, :feed, :published, :source, :highlighted, :notify_comments, :display_hits, :slug, :external_feed_builder, :display_versions, :external_link, :image_builder
6 6  
7 7 acts_as_having_image
8 8  
... ... @@ -40,6 +40,12 @@ class Article &lt; ActiveRecord::Base
40 40 # xss_terminate plugin can't sanitize array fields
41 41 before_save :sanitize_tag_list
42 42  
  43 + before_create do |article|
  44 + if article.author
  45 + article.author_name = article.author.name
  46 + end
  47 + end
  48 +
43 49 belongs_to :profile
44 50 validates_presence_of :profile_id, :name
45 51 validates_presence_of :slug, :path, :if => lambda { |article| !article.name.blank? }
... ... @@ -48,6 +54,7 @@ class Article &lt; ActiveRecord::Base
48 54  
49 55 validates_uniqueness_of :slug, :scope => ['profile_id', 'parent_id'], :message => N_('The title (article name) is already being used by another article, please use another title.'), :if => lambda { |article| !article.slug.blank? }
50 56  
  57 + belongs_to :author, :class_name => 'Person'
51 58 belongs_to :last_changed_by, :class_name => 'Person', :foreign_key => 'last_changed_by_id'
52 59 belongs_to :created_by, :class_name => 'Person', :foreign_key => 'created_by_id'
53 60  
... ... @@ -456,10 +463,10 @@ class Article &lt; ActiveRecord::Base
456 463 ['TextArticle', 'TextileArticle', 'TinyMceArticle']
457 464 end
458 465  
459   - scope :published, :conditions => { :published => true }
460   - scope :folders, lambda {|profile|{:conditions => { :type => profile.folder_types} }}
461   - scope :no_folders, lambda {|profile|{:conditions => ['type NOT IN (?)', profile.folder_types]}}
462   - scope :galleries, :conditions => { :type => 'Gallery' }
  466 + scope :published, :conditions => ['articles.published = ?', true]
  467 + scope :folders, lambda {|profile|{:conditions => ['articles.type IN (?)', profile.folder_types] }}
  468 + scope :no_folders, lambda {|profile|{:conditions => ['articles.type NOT IN (?)', profile.folder_types]}}
  469 + scope :galleries, :conditions => [ "articles.type IN ('Gallery')" ]
463 470 scope :images, :conditions => { :is_image => true }
464 471 scope :text_articles, :conditions => [ 'articles.type IN (?)', text_article_types ]
465 472 scope :with_types, lambda { |types| { :conditions => [ 'articles.type IN (?)', types ] } }
... ... @@ -469,7 +476,7 @@ class Article &lt; ActiveRecord::Base
469 476 scope :more_recent, :order => "created_at DESC"
470 477  
471 478 def self.display_filter(user, profile)
472   - return {:conditions => ['published = ?', true]} if !user
  479 + return {:conditions => ['articles.published = ?', true]} if !user
473 480 {:conditions => [" articles.published = ? OR
474 481 articles.last_changed_by_id = ? OR
475 482 articles.profile_id = ? OR
... ... @@ -496,6 +503,7 @@ class Article &lt; ActiveRecord::Base
496 503 end
497 504  
498 505 def allow_post_content?(user = nil)
  506 + return true if allow_edit_topic?(user)
499 507 user && (user.has_permission?('post_content', profile) || allow_publish_content?(user) && (user == author))
500 508 end
501 509  
... ... @@ -515,9 +523,14 @@ class Article &lt; ActiveRecord::Base
515 523 end
516 524  
517 525 def allow_edit?(user)
  526 + return true if allow_edit_topic?(user)
518 527 allow_post_content?(user) || user && allow_members_to_edit && user.is_member_of?(profile)
519 528 end
520 529  
  530 + def allow_edit_topic?(user)
  531 + self.belongs_to_forum? && (user == author) && user.present? && user.is_member_of?(profile)
  532 + end
  533 +
521 534 def moderate_comments?
522 535 moderate_comments == true
523 536 end
... ... @@ -632,35 +645,36 @@ class Article &lt; ActiveRecord::Base
632 645 can_display_versions? && display_versions
633 646 end
634 647  
635   - def author(version_number = nil)
636   - if version_number
637   - version = self.versions.find_by_version(version_number)
638   - author_id = version.last_changed_by_id if version
639   - else
640   - author_id = self.created_by_id
641   - end
  648 + def get_version(version_number = nil)
  649 + version_number ? versions.find(:first, :order => 'version', :offset => version_number - 1) : versions.earliest
  650 + end
642 651  
643   - environment.people.find_by_id(author_id)
  652 + def author_by_version(version_number = nil)
  653 + version_number ? profile.environment.people.find_by_id(get_version(version_number).author_id) : author
644 654 end
645 655  
646 656 def author_name(version_number = nil)
647   - person = author(version_number)
648   - person ? person.name : (setting[:author_name] || _('Unknown'))
  657 + person = author_by_version(version_number)
  658 + if version_number
  659 + person ? person.name : _('Unknown')
  660 + else
  661 + person ? person.name : (setting[:author_name] || _('Unknown'))
  662 + end
649 663 end
650 664  
651 665 def author_url(version_number = nil)
652   - person = author(version_number)
  666 + person = author_by_version(version_number)
653 667 person ? person.url : nil
654 668 end
655 669  
656 670 def author_id(version_number = nil)
657   - person = author(version_number)
  671 + person = author_by_version(version_number)
658 672 person ? person.id : nil
659 673 end
660 674  
661 675 def version_license(version_number = nil)
662 676 return license if version_number.nil?
663   - profile.environment.licenses.find_by_id(versions.find_by_version(version_number).license_id)
  677 + profile.environment.licenses.find_by_id(get_version(version_number).license_id)
664 678 end
665 679  
666 680 alias :active_record_cache_key :cache_key
... ...
app/models/block.rb
... ... @@ -22,6 +22,10 @@ class Block &lt; ActiveRecord::Base
22 22 false
23 23 end
24 24  
  25 + def get_limit
  26 + [0,limit].max
  27 + end
  28 +
25 29 def embed_code
26 30 me = self
27 31 proc do
... ...
app/models/comment.rb
... ... @@ -109,14 +109,17 @@ class Comment &lt; ActiveRecord::Base
109 109 include Noosfero::Plugin::HotSpot
110 110  
111 111 include Spammable
  112 + include CacheCounterHelper
112 113  
113 114 def after_spam!
114 115 SpammerLogger.log(ip_address, self)
115 116 Delayed::Job.enqueue(CommentHandler.new(self.id, :marked_as_spam))
  117 + update_cache_counter(:spam_comments_count, source, 1) if source.kind_of?(Article)
116 118 end
117 119  
118 120 def after_ham!
119 121 Delayed::Job.enqueue(CommentHandler.new(self.id, :marked_as_ham))
  122 + update_cache_counter(:spam_comments_count, source, -1) if source.kind_of?(Article)
120 123 end
121 124  
122 125 def verify_and_notify
... ...
app/models/domain.rb
... ... @@ -2,7 +2,7 @@ require &#39;noosfero/multi_tenancy&#39;
2 2  
3 3 class Domain < ActiveRecord::Base
4 4  
5   - attr_accessible :name, :owner
  5 + attr_accessible :name, :owner, :is_default
6 6  
7 7 # relationships
8 8 ###############
... ...
app/models/enterprise.rb
... ... @@ -25,7 +25,10 @@ class Enterprise &lt; Organization
25 25 N_('Organization website'); N_('Historic and current context'); N_('Activities short description'); N_('City'); N_('State'); N_('Country'); N_('ZIP code')
26 26  
27 27 settings_items :organization_website, :historic_and_current_context, :activities_short_description
  28 +
28 29 settings_items :products_per_catalog_page, :type => :integer, :default => 6
  30 + alias_method :products_per_catalog_page_before_type_cast, :products_per_catalog_page
  31 + validates_numericality_of :products_per_catalog_page, :allow_nil => true, :greater_than => 0
29 32  
30 33 extend SetProfileRegionFromCityState::ClassMethods
31 34 set_profile_region_from_city_state
... ...
app/models/environment.rb
... ... @@ -286,7 +286,7 @@ class Environment &lt; ActiveRecord::Base
286 286 www.youtube.com
287 287 ] + ('a' .. 'z').map{|i| "#{i}.yimg.com"}
288 288  
289   - settings_items :enabled_plugins, :type => Array, :default => []
  289 + settings_items :enabled_plugins, :type => Array, :default => Noosfero::Plugin.available_plugin_names
290 290  
291 291 settings_items :search_hints, :type => Hash, :default => {}
292 292  
... ...
app/models/featured_products_block.rb
1 1 class FeaturedProductsBlock < Block
2 2  
  3 + attr_accessible :product_ids, :groups_of, :speed, :reflect
  4 +
3 5 settings_items :product_ids, :type => Array, :default => []
4 6 settings_items :groups_of, :type => :integer, :default => 3
5 7 settings_items :speed, :type => :integer, :default => 1000
... ...
app/models/forum.rb
... ... @@ -3,7 +3,7 @@ class Forum &lt; Folder
3 3 acts_as_having_posts :order => 'updated_at DESC'
4 4 include PostsLimit
5 5  
6   - attr_accessible :has_terms_of_use, :terms_of_use
  6 + attr_accessible :has_terms_of_use, :terms_of_use, :allows_members_to_create_topics
7 7  
8 8 settings_items :terms_of_use, :type => :string, :default => ""
9 9 settings_items :has_terms_of_use, :type => :boolean, :default => false
... ...
app/models/friendship.rb
... ... @@ -15,4 +15,9 @@ class Friendship &lt; ActiveRecord::Base
15 15 Friendship.update_cache_counter(:friends_count, friendship.person, -1)
16 16 Friendship.update_cache_counter(:friends_count, friendship.friend, -1)
17 17 end
  18 +
  19 + def self.remove_friendship(person1, person2)
  20 + person1.remove_friend(person2)
  21 + person2.remove_friend(person1)
  22 + end
18 23 end
... ...
app/models/highlights_block.rb
1 1 class HighlightsBlock < Block
2 2  
3   - attr_accessible :images
  3 + attr_accessible :images, :interval, :shuffle, :navigation
4 4  
5 5 settings_items :images, :type => Array, :default => []
6 6 settings_items :interval, :type => 'integer', :default => 4
... ...
app/models/image.rb
... ... @@ -25,4 +25,7 @@ class Image &lt; ActiveRecord::Base
25 25  
26 26 attr_accessible :uploaded_data
27 27  
  28 + def current_data
  29 + File.file?(full_filename) ? File.read(full_filename) : nil
  30 + end
28 31 end
... ...
app/models/input.rb
1 1 class Input < ActiveRecord::Base
2 2  
3   - attr_accessible :product, :product_category
  3 + attr_accessible :product, :product_category, :product_category_id, :amount_used, :unit_id, :price_per_unit, :relevant_to_price
4 4  
5 5 belongs_to :product
6 6 belongs_to :product_category
... ...
app/models/location_block.rb
1 1 class LocationBlock < Block
2 2  
  3 + attr_accessible :zoom, :map_type
  4 +
3 5 settings_items :zoom, :type => :integer, :default => 4
4 6 settings_items :map_type, :type => :string, :default => 'roadmap'
5 7  
... ...
app/models/person_notifier.rb
... ... @@ -82,7 +82,7 @@ class PersonNotifier
82 82 @url = @profile.environment.top_url
83 83 mail(
84 84 content_type: "text/html",
85   - from: "#{@profile.environment.name} <#{@profile.environment.contact_email}>",
  85 + from: "#{@profile.environment.name} <#{@profile.environment.noreply_email}>",
86 86 to: @profile.email,
87 87 subject: _("[%s] Network Activity") % [@profile.environment.name]
88 88 )
... ...
app/models/product.rb
... ... @@ -11,7 +11,7 @@ class Product &lt; ActiveRecord::Base
11 11  
12 12 SEARCH_DISPLAYS = %w[map full]
13 13  
14   - attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description, :available, :qualifiers
  14 + attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description, :available, :qualifiers, :unit_id, :discount, :inputs
15 15  
16 16 def self.default_search_display
17 17 'full'
... ...
app/models/product_categories_block.rb
... ... @@ -17,7 +17,7 @@ class ProductCategoriesBlock &lt; Block
17 17 profile = owner
18 18 proc do
19 19 if @categories.nil? or @categories.length == 0
20   - categories = ProductCategory.on_level().order(:name)
  20 + categories = ProductCategory.on_level(nil).order(:name)
21 21 if @categories and @categories.length == 0
22 22 notice = _('There are no sub-categories for %s') % @category.name
23 23 end
... ... @@ -33,7 +33,7 @@ class ProductCategoriesBlock &lt; Block
33 33 end
34 34 end
35 35  
36   - DISPLAY_OPTIONS['catalog_only'] = _('Only on the catalog')
  36 + DISPLAY_OPTIONS = DISPLAY_OPTIONS.merge('catalog_only' => _('Only on the catalog'))
37 37  
38 38 def display
39 39 settings[:display].nil? ? 'catalog_only' : super
... ...
app/models/products_block.rb
... ... @@ -49,17 +49,10 @@ class ProductsBlock &lt; Block
49 49  
50 50 def products(reload = false)
51 51 if product_ids.blank?
52   - products_list = owner.products(reload)
53   - result = []
54   - [4, products_list.size].min.times do
55   - p = products_list.sample
56   - result << p
57   - products_list -= [p]
58   - end
59   - result
  52 + owner.products.order('RANDOM()').limit([4,owner.products.count].min)
60 53 else
61   - product_ids.map {|item| owner.products.find(item) }
62   - end
  54 + owner.products.where(:id => product_ids)
  55 + end.compact
63 56 end
64 57  
65 58 end
... ...
app/models/profile.rb
... ... @@ -3,7 +3,7 @@
3 3 # which by default is the one returned by Environment:default.
4 4 class Profile < ActiveRecord::Base
5 5  
6   - attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time
  6 + attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time, :redirection_after_login
7 7  
8 8 # use for internationalizable human type names in search facets
9 9 # reimplement on subclasses
... ...
app/models/profile_list_block.rb
1 1 class ProfileListBlock < Block
2 2  
3   - attr_accessible :limit, :prioritize_profiles_with_image
  3 + attr_accessible :prioritize_profiles_with_image
4 4  
5 5 settings_items :limit, :type => :integer, :default => 6
6 6 settings_items :prioritize_profiles_with_image, :type => :boolean, :default => true
... ... @@ -18,13 +18,13 @@ class ProfileListBlock &lt; Block
18 18 result = nil
19 19 visible_profiles = profiles.visible.includes([:image,:domains,:preferred_domain,:environment])
20 20 if !prioritize_profiles_with_image
21   - result = visible_profiles.all(:limit => limit, :order => 'profiles.updated_at DESC').sort_by{ rand }
22   - elsif profiles.visible.with_image.count >= limit
23   - result = visible_profiles.with_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand }
  21 + result = visible_profiles.all(:limit => get_limit, :order => 'profiles.updated_at DESC').sort_by{ rand }
  22 + elsif profiles.visible.with_image.count >= get_limit
  23 + result = visible_profiles.with_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand }
24 24 else
25   - result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand }
  25 + result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => get_limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand }
26 26 end
27   - result.slice(0..limit-1)
  27 + result.slice(0..get_limit-1)
28 28 end
29 29  
30 30 def profile_count
... ...
app/models/recent_documents_block.rb
... ... @@ -33,7 +33,7 @@ class RecentDocumentsBlock &lt; Block
33 33 end
34 34  
35 35 def docs
36   - self.limit.nil? ? owner.recent_documents(nil, {}, false) : owner.recent_documents(self.limit, {}, false)
  36 + self.limit.nil? ? owner.recent_documents(nil, {}, false) : owner.recent_documents(self.get_limit, {}, false)
37 37 end
38 38  
39 39 def self.expire_on
... ...
app/models/rss_feed.rb
1 1 class RssFeed < Article
2 2  
3   - attr_accessible :limit, :enabled, :language, :include
  3 + attr_accessible :limit, :enabled, :language, :include, :feed_item_description
4 4  
5 5 def self.type_name
6 6 _('RssFeed')
... ...
app/models/slideshow_block.rb
... ... @@ -6,6 +6,8 @@ class SlideshowBlock &lt; Block
6 6 settings_items :navigation, :type => 'boolean', :default => false
7 7 settings_items :image_size, :type => 'string', :default => 'thumb'
8 8  
  9 + attr_accessible :gallery_id, :image_size, :interval, :shuffle, :navigation
  10 +
9 11 def self.description
10 12 _('Slideshow')
11 13 end
... ...
app/models/user.rb
... ... @@ -5,7 +5,7 @@ require &#39;user_activation_job&#39;
5 5 # Rails generator.
6 6 class User < ActiveRecord::Base
7 7  
8   - attr_accessible :login, :email, :password, :password_confirmation
  8 + attr_accessible :login, :email, :password, :password_confirmation, :activated_at
9 9  
10 10 N_('Password')
11 11 N_('Password confirmation')
... ... @@ -66,45 +66,6 @@ class User &lt; ActiveRecord::Base
66 66 # virtual attribute used to stash which community to join on signup or login
67 67 attr_accessor :community_to_join
68 68  
69   - class Mailer < ActionMailer::Base
70   - def activation_email_notify(user)
71   - user_email = "#{user.login}@#{user.email_domain}"
72   - recipients user_email
73   - from "#{user.environment.name} <#{user.environment.noreply_email}>"
74   - subject _("[%{environment}] Welcome to %{environment} mail!") % { :environment => user.environment.name }
75   - body :name => user.name,
76   - :email => user_email,
77   - :webmail => MailConf.webmail_url(user.login, user.email_domain),
78   - :environment => user.environment.name,
79   - :url => url_for(:host => user.environment.default_hostname, :controller => 'home')
80   - end
81   -
82   - def activation_code(user)
83   - recipients user.email
84   -
85   - from "#{user.environment.name} <#{user.environment.noreply_email}>"
86   - subject _("[%s] Activate your account") % [user.environment.name]
87   - body :recipient => user.name,
88   - :activation_code => user.activation_code,
89   - :environment => user.environment.name,
90   - :url => user.environment.top_url,
91   - :redirection => (true if user.return_to),
92   - :join => (user.community_to_join if user.community_to_join)
93   - end
94   -
95   - def signup_welcome_email(user)
96   - email_body = user.environment.signup_welcome_text_body.gsub('{user_name}', user.name)
97   - email_subject = user.environment.signup_welcome_text_subject
98   -
99   - content_type 'text/html'
100   - recipients user.email
101   -
102   - from "#{user.environment.name} <#{user.environment.noreply_email}>"
103   - subject email_subject.blank? ? _("Welcome to environment %s") % [user.environment.name] : email_subject
104   - body email_body
105   - end
106   - end
107   -
108 69 def signup!
109 70 User.transaction do
110 71 self.save!
... ...
app/presenters/image.rb
... ... @@ -11,4 +11,9 @@ class FilePresenter::Image &lt; FilePresenter
11 11 def short_description
12 12 _('Image (%s)') % content_type.split('/')[1].upcase
13 13 end
  14 +
  15 + #Overwriting method from FilePresenter to allow download of images
  16 + def download?(view = nil)
  17 + view.blank? || view == 'false'
  18 + end
14 19 end
... ...
app/views/account/_signup_form.html.erb
... ... @@ -136,8 +136,6 @@
136 136 <script type="text/javascript">
137 137 jQuery(function($) {
138 138  
139   - $('#signup-form #user_login').css('width', 335 - $('#signup-domain').outerWidth());
140   -
141 139 $('#signup-form input[type=text], #signup-form textarea').each(function() {
142 140 $(this).bind('blur', function() {
143 141 if ($(this).val() == '') {
... ...
app/views/blocks/my_network.html.erb
1 1 <%= block_title(title) %>
2 2  
3   -<%= render :file => 'blocks/my_network/' + owner.class.name.underscore, :locals => { :owner => owner } %>
  3 +<%= render_profile_actions owner.class %>
4 4  
5 5 <ul>
6 6 <li><%= link_to(_('Homepage'), owner.url, :class => 'url') %></li>
... ... @@ -11,5 +11,5 @@
11 11 </ul>
12 12  
13 13 <div class="my-network-actions">
14   - <%= render :file => 'blocks/profile_info_actions/' + owner.class.name.underscore %>
  14 + <%= render 'blocks/profile_info_actions/' + owner.class.name.underscore %>
15 15 </div>
... ...
app/views/blocks/profile_image.html.erb
... ... @@ -23,6 +23,6 @@
23 23 <% end %>
24 24  
25 25 <div class="profile-info-options">
26   - <%= render :file => view_for_profile_actions(block.owner.class) %>
  26 + <%= render_profile_actions block.owner.class %>
27 27 </div>
28 28 </div><!-- end class="vcard" -->
... ...
app/views/blocks/profile_info.html.erb
... ... @@ -40,7 +40,7 @@
40 40 <% end %>
41 41  
42 42 <div class="profile-info-options">
43   - <%= render :file => view_for_profile_actions(block.owner.class) %>
  43 + <%= render_profile_actions block.owner.class %>
44 44 </div>
45 45  
46 46 </div><!-- end class="vcard" -->
... ...
app/views/blocks/profile_info_actions/_community.html.erb 0 → 100644
... ... @@ -0,0 +1,20 @@
  1 +<ul>
  2 + <li>
  3 + <%= render "blocks/profile_info_actions/join_leave_community" %>
  4 + </li>
  5 + <% if logged_in? %>
  6 + <% if profile.enable_contact? %>
  7 + <li>
  8 + <%= link_to content_tag('span', _('Send an e-mail')),
  9 + { :profile => profile.identifier,
  10 + :controller => 'contact',
  11 + :action => 'new' },
  12 + {:class => 'button with-text icon-menu-mail', :title => _('Send an e-mail to the administrators')} %>
  13 + </li>
  14 + <% end %>
  15 +
  16 + <li><%= report_abuse(profile, :button) %></li>
  17 +
  18 + <%= render_environment_features(:profile_actions) %>
  19 + <% end %>
  20 +</ul>
... ...
app/views/blocks/profile_info_actions/_enterprise.html.erb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +<ul>
  2 + <%if logged_in? %>
  3 + <%if !user.favorite_enterprises.include?(profile) %>
  4 + <li><%= link_to content_tag('span', _('Add as favorite')), { :profile => user.identifier, :controller => 'favorite_enterprises', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add', :title => _('Add enterprise as favorite') %></li>
  5 + <% end %>
  6 + <% end %>
  7 + <% if profile.enable_contact? %>
  8 + <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, {:id => 'enterprise-contact-button', :class => 'button with-text icon-menu-mail'} %> </li>
  9 + <% end %>
  10 +
  11 + <li><%= report_abuse(profile, :button) %></li>
  12 +</ul>
... ...
app/views/blocks/profile_info_actions/_organization.html.erb 0 → 100644
app/views/blocks/profile_info_actions/_person.html.erb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<ul>
  2 + <%if logged_in? && (user != profile) %>
  3 +
  4 + <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %>
  5 + <li>
  6 + <%= button(:add, content_tag('span', _('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %>
  7 + </li>
  8 + <% end %>
  9 +
  10 + <% if user.is_a_friend?(profile) && profile.enable_contact? %>
  11 + <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, :class => 'button with-text icon-menu-mail' %> </li>
  12 + <% end %>
  13 +
  14 + <li><%= report_abuse(profile, :button) %></li>
  15 + <% end %>
  16 +</ul>
... ...
app/views/blocks/profile_info_actions/community.html.erb
... ... @@ -1,20 +0,0 @@
1   -<ul>
2   - <li>
3   - <%= render "blocks/profile_info_actions/join_leave_community" %>
4   - </li>
5   - <% if logged_in? %>
6   - <% if profile.enable_contact? %>
7   - <li>
8   - <%= link_to content_tag('span', _('Send an e-mail')),
9   - { :profile => profile.identifier,
10   - :controller => 'contact',
11   - :action => 'new' },
12   - {:class => 'button with-text icon-menu-mail', :title => _('Send an e-mail to the administrators')} %>
13   - </li>
14   - <% end %>
15   -
16   - <li><%= report_abuse(profile, :button) %></li>
17   -
18   - <%= render_environment_features(:profile_actions) %>
19   - <% end %>
20   -</ul>
app/views/blocks/profile_info_actions/enterprise.html.erb
... ... @@ -1,12 +0,0 @@
1   -<ul>
2   - <%if logged_in? %>
3   - <%if !user.favorite_enterprises.include?(profile) %>
4   - <li><%= link_to content_tag('span', _('Add as favorite')), { :profile => user.identifier, :controller => 'favorite_enterprises', :action => 'add', :id => profile.id }, :class => 'button with-text icon-add', :title => _('Add enterprise as favorite') %></li>
5   - <% end %>
6   - <% end %>
7   - <% if profile.enable_contact? %>
8   - <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, {:id => 'enterprise-contact-button', :class => 'button with-text icon-menu-mail'} %> </li>
9   - <% end %>
10   -
11   - <li><%= report_abuse(profile, :button) %></li>
12   -</ul>
app/views/blocks/profile_info_actions/organization.html.erb
app/views/blocks/profile_info_actions/person.html.erb
... ... @@ -1,16 +0,0 @@
1   -<ul>
2   - <%if logged_in? && (user != profile) %>
3   -
4   - <% if !user.already_request_friendship?(profile) and !user.is_a_friend?(profile) %>
5   - <li>
6   - <%= button(:add, content_tag('span', _('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %>
7   - </li>
8   - <% end %>
9   -
10   - <% if user.is_a_friend?(profile) && profile.enable_contact? %>
11   - <li> <%= link_to content_tag('span', _('Send an e-mail')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, :class => 'button with-text icon-menu-mail' %> </li>
12   - <% end %>
13   -
14   - <li><%= report_abuse(profile, :button) %></li>
15   - <% end %>
16   -</ul>
app/views/box_organizer/_highlights_block.html.erb
  1 +<%= javascript_include_tag "highlight_block" %>
  2 +
1 3 <strong><%= _('Highlights') %></strong>
2 4  
3 5 <table class="noborder"><tbody id="highlights-data-table">
4 6 <tr><th><%= _('Image') %></th><th><%= _('Address') %></th><th><%= _('Position') %></th></tr>
5   - <% for image in @block.images do %>
6   - <%= highlights_block_config_image_fields @block, image %>
  7 + <% @block.images.each_with_index do |image, index| %>
  8 + <%= highlights_block_config_image_fields @block, image, index %>
7 9 <% end %>
8 10 </tbody></table>
9 11  
10   -<%= link_to_function(_('New highlight'), nil, :class => 'button icon-add with-text') do |page|
11   - page.insert_html :bottom, 'highlights-data-table', highlights_block_config_image_fields(@block)
12   -end %>
  12 +<table class="hidden highlight-table-row">
  13 + <tbody>
  14 + <%= highlights_block_config_image_fields(@block) %>
  15 + </tbody>
  16 +</table>
  17 +
  18 +<%= link_to(_('New highlight'), '#', :class => 'button icon-add with-text new-highlight-button')%>
13 19  
14 20 <%= labelled_form_field _('Image transition:'), select('block', 'interval', [[_('No automatic transition'), 0]] + [1, 2, 3, 4, 5, 10, 20, 30, 60].map {|item| [n_('Every 1 second', 'Every %d seconds', item) % item, item]}) %>
15 21  
... ...
app/views/box_organizer/_link_list_block.html.erb
... ... @@ -10,40 +10,15 @@
10 10 </ul>
11 11 <ul id="dropable-link-list">
12 12 <% for link in @block.links do %>
13   - <li>
14   - <ul class="link-list-row">
15   - <li>
16   - <%= icon_selector(link['icon']) %>
17   - </li>
18   - <li>
19   - <%= text_field_tag 'block[links][][name]', link[:name], :class => 'link-name', :maxlength => 20 %>
20   - </li>
21   - <li>
22   - <%= text_field_tag 'block[links][][address]', link[:address], :class => 'link-address' %>
23   - </li>
24   - <li>
25   - <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %>
26   - </li>
27   - <li>
28   - <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row") %>
29   - </li>
30   - </ul>
31   - </li>
  13 + <%= render :partial => 'link_list_item', :locals => {:link => link} %>
32 14 <% end %>
33 15 </ul>
34 16 <input type="hidden" id="page_url" value="<%=url_for(:action=>'search_autocomplete')%>" />
  17 +
  18 + <div id="new-template">
  19 + <% template_link = {'icon' => 'ok'} %>
  20 + <%= render :partial => 'link_list_item', :locals => {:link => template_link} %>
  21 + </div>
35 22 </div>
36 23  
37   -<%= link_to_function(_('New link'), nil, :class => 'button icon-add with-text') do |page|
38   - page.insert_html :bottom, 'dropable-link-list', content_tag('li',
39   - content_tag('ul',
40   - content_tag('li', icon_selector('ok')) +
41   - content_tag('li', text_field_tag('block[links][][name]', '', :maxlength => 20)) +
42   - content_tag('li', text_field_tag('block[links][][address]', nil, :class => 'link-address')) +
43   - content_tag('li', select_tag('block[links][][target]',
44   - options_for_select(LinkListBlock::TARGET_OPTIONS, '_self'))) +
45   - content_tag('li', button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row")),
46   - :class=>"link-list-row new_link_row")
47   - ) +
48   - javascript_tag("new_link_action()")
49   -end %>
  24 +<%= link_to_function(_('New link'), 'add_new_link();', :class => 'button icon-add with-text') %>
... ...
app/views/box_organizer/_link_list_item.html.erb 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +<li>
  2 + <ul class="link-list-row">
  3 + <li>
  4 + <%= icon_selector(link['icon']) %>
  5 + </li>
  6 + <li>
  7 + <%= text_field_tag 'block[links][][name]', link[:name], :class => 'link-name', :maxlength => 20 %>
  8 + </li>
  9 + <li>
  10 + <%= text_field_tag 'block[links][][address]', link[:address], :class => 'link-address' %>
  11 + </li>
  12 + <li>
  13 + <%= select_tag('block[links][][target]', options_for_select(LinkListBlock::TARGET_OPTIONS, link[:target])) %>
  14 + </li>
  15 + <li>
  16 + <%= button_without_text(:delete, _('Delete'), "#" , :class=>"delete-link-list-row") %>
  17 + </li>
  18 + </ul>
  19 +</li>
... ...
app/views/cms/view.html.erb
... ... @@ -25,7 +25,9 @@
25 25 <div id='article-full-path'>
26 26 <strong><%= _('Current folder: ') %></strong>
27 27 <%= link_to profile.identifier, :action => 'index' %>
28   - <%= @article.hierarchy.map {|item| " / " + ((item == @article) ? item.name : link_to(item.slug, :id => item.id)) } %>
  28 + <% @article.hierarchy.each do |item| %>
  29 + <%= " / " + ((item == @article) ? item.name.html_safe : link_to(item.slug, :id => item.id).html_safe) %>
  30 + <% end %>
29 31 </div>
30 32 <% end %>
31 33  
... ...
app/views/comment/_comment_form.html.erb
... ... @@ -31,7 +31,7 @@ function check_captcha(button, confirm_action) {
31 31 return true;
32 32 <% else %>
33 33 jQuery('#recaptcha-container').show();
34   - jQuery.colorbox({ inline : true, href : '#recaptcha-container', maxWidth : '600px', maxHeight : '300px' });
  34 + jQuery.colorbox({ html: jQuery('#recaptcha-container').html(), maxWidth : '600px', maxHeight : '300px' });
35 35 jQuery('#confirm-captcha').unbind('click');
36 36 jQuery('#confirm-captcha').bind('click', function() {
37 37 jQuery.colorbox.close();
... ... @@ -46,14 +46,16 @@ function check_captcha(button, confirm_action) {
46 46 }
47 47 </script>
48 48  
49   -<% if @comment && @comment.errors.any? %>
  49 +<% @comment ||= Comment.new %>
  50 +
  51 +<% if @comment.errors.any? %>
50 52 <%= error_messages_for :comment %>
51 53 <% end %>
52 54  
53 55 <div class="post_comment_box <%= ((defined? show_form) && show_form) ? 'opened' : 'closed' %>">
54 56  
55 57 <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form') if display_link && @comment.reply_of_id.blank? %>
56   -<%= remote_form_for(:comment, comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %>
  58 +<%= remote_form_for(:comment, @comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? @comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %>
57 59  
58 60 <%= required_fields_message %>
59 61  
... ... @@ -79,7 +81,7 @@ function check_captcha(button, confirm_action) {
79 81 <%= hidden_field_tag(:view, params[:view])%>
80 82 <%= f.hidden_field(:reply_of_id) %>
81 83  
82   - <%= @plugins.dispatch(:comment_form_extra_contents, local_assigns).collect { |content| instance_exec(&content) }.join("") %>
  84 + <%= @plugins.dispatch(:comment_form_extra_contents, local_assigns.merge(:comment => @comment)).collect { |content| instance_exec(&content) }.join("") %>
83 85  
84 86 <% button_bar do %>
85 87 <%= submit_button('add', _('Post comment'), :onclick => "if(check_captcha(this)) { save_comment(this) } else { check_captcha(this, save_comment)};return false;") %>
... ...
app/views/comment/notifier/notification.html.erb
... ... @@ -1,19 +0,0 @@
1   -<%= _('Hi, %{recipient}!') % { :recipient => @recipient } %>
2   -
3   -<%= word_wrap(_('%{sender} (%{sender_link}) created a new comment on your article "%{article_title}".') % { :sender => @sender, :sender_link => url_for(@sender_link), :article_title => @article_title }) %>
4   -
5   -<%= word_wrap(_('Title: %s') % @comment_title) %>
6   -
7   -<%= _("Comment:") %>
8   --------------------------------------------------------------------------------
9   -<%= word_wrap(@comment_body) %>
10   --------------------------------------------------------------------------------
11   -
12   -<%= _('Access the address below to view this comment:') %>
13   -<%= url_for @comment_url %>
14   -
15   -<%= _("Greetings,") %>
16   -
17   ---
18   -<%= _('%s team.') % @environment %>
19   -<%= url_for @url %>
app/views/comment/notifier/notification.text.erb 0 → 100644
... ... @@ -0,0 +1,19 @@
  1 +<%= _('Hi, %{recipient}!') % { :recipient => @recipient } %>
  2 +
  3 +<%= word_wrap(_('%{sender} (%{sender_link}) created a new comment on your article "%{article_title}".') % { :sender => @sender, :sender_link => url_for(@sender_link), :article_title => @article_title }) %>
  4 +
  5 +<%= word_wrap(_('Title: %s') % @comment_title) %>
  6 +
  7 +<%= _("Comment:") %>
  8 +-------------------------------------------------------------------------------
  9 +<%= word_wrap(@comment_body) %>
  10 +-------------------------------------------------------------------------------
  11 +
  12 +<%= _('Access the address below to view this comment:') %>
  13 +<%= url_for @comment_url %>
  14 +
  15 +<%= _("Greetings,") %>
  16 +
  17 +--
  18 +<%= _('%s team.') % @environment %>
  19 +<%= url_for @url %>
... ...
app/views/content_viewer/article_versions.html.erb
1 1 <div class="article-versions">
2   - <%= button(:back, _('Go back to latest version'), {:action => 'view_page'}) %>
  2 + <%= button(:back, _('Go back to latest version'), @page.url) %>
3 3 </div>
4 4  
5 5 <%= article_title(@page, :no_link => true) %>
6 6  
7 7 <p><%= _('This is the list of all versions of this content. Select a version to see it and then revert to it.') %>.</p>
8 8  
9   -<%= form_tag({:controller => 'content_viewer', :action => 'versions_diff', :profile => profile.identifier, :page => @page.path.split('/')}, :method => 'get') do %>
  9 +<%= form_tag({:controller => 'content_viewer', :action => 'versions_diff', :profile => profile.identifier, :page => @page.path}, :method => 'get') do %>
10 10 <ul id="article-versions">
11 11 <% @versions.each do |v| %>
12 12 <li>
... ...
app/views/content_viewer/blog_page.html.erb
... ... @@ -9,13 +9,15 @@
9 9 </div>
10 10 <hr class="pre-posts"/>
11 11 <div class="blog-posts">
  12 + <% paginate = true %>
12 13 <%=
13 14 posts = @posts
14 15 format = blog.visualization_format
15 16 if inside_block
16 17 posts = blog.posts.paginate(:page=>1, :per_page=>inside_block.posts_per_page)
17 18 format = inside_block.visualization_format
  19 + paginate = false
18 20 end
19   - (blog.empty? ? content_tag('em', _('(no posts)')) : list_posts(posts, format))
  21 + (blog.empty? ? content_tag('em', _('(no posts)')) : list_posts(posts, format, paginate))
20 22 %>
21 23 </div>
... ...
app/views/content_viewer/folder.html.erb
... ... @@ -8,5 +8,5 @@
8 8 <% if folder.children.empty? %>
9 9 <em><%= _('(empty folder)') %></em>
10 10 <% else %>
11   - <%= list_articles(folder.children) %>
  11 + <%= list_contents(:contents=>folder.children) %>
12 12 <% end %>
... ...
app/views/content_viewer/versioned_article.html.erb
... ... @@ -23,7 +23,6 @@
23 23 <p id="no-current-version">
24 24 <%= _('This is not the latest version of this content.') %>
25 25 </p>
26   -</div>
27 26  
28 27 <% version_license = @page.version_license(@version) %>
29 28 <%# This seemingly doubled verification exists because the article-sub-header
... ...
app/views/content_viewer/view_page.html.erb
... ... @@ -40,8 +40,6 @@
40 40 </div>
41 41 <% end %>
42 42  
43   -<%= render :partial => 'shared/disabled_enterprise' %>
44   -
45 43 <% if NOOSFERO_CONF['addthis_enabled'] %>
46 44 <%= render :partial => 'addthis' %>
47 45 <% end %>
... ... @@ -80,20 +78,10 @@
80 78 </h3>
81 79 <% end %>
82 80  
83   - <% if @page.accept_comments? && @comments.count > 1 %>
84   - <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form', :id => 'top-post-comment-button', :onclick => "jQuery('#page-comment-form .display-comment-form').first().click();") %>
85   -
86   - <%= hidden_field_tag("page_url", url_for(:controller=>'content_viewer', :action=>'view_page', :profile=>profile.identifier)) %>
87   - <%= javascript_include_tag "comment_order.js" %>
88   - <div class="comment-order">
89   - <%= form_tag({:controller=>'content_viewer' , :action=>'view_page'}, {:method=>'get', :id=>"form_order"}) do %>
90   - <%= select_tag 'comment_order', options_for_select({_('Oldest first')=>'oldest', _('Newest first')=>'newest'}, @comment_order) %>
91   - <% end %>
92   - </div>
93   - <% end %>
  81 + <% if @comments.present? && @comments.count > 1 %>
  82 + <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form', :id => 'top-post-comment-button', :onclick => "jQuery('#page-comment-form .display-comment-form').first().click();") if @page.accept_comments? %>
94 83  
95   - <% if @page.accept_comments? and @comments.count > 1 %>
96   - <%= hidden_field_tag("page_url", url_for(:controller=>'content_viewer', :action=>'view_page', :profile=>profile.identifier)) %>
  84 + <%= hidden_field_tag("page_url", url_for(:controller=>'content_viewer', :action=>'view_page', :profile=>profile.identifier, :page => @page.explode_path)) %>
97 85 <%= javascript_include_tag "comment_order.js" %>
98 86 <div class="comment-order">
99 87 <%= form_tag({:controller=>'content_viewer' , :action=>'view_page'}, {:method=>'get', :id=>"form_order"}) do %>
... ... @@ -103,12 +91,14 @@
103 91 <% end %>
104 92  
105 93 <ul class="article-comments-list">
106   - <%= render :partial => 'comment/comment', :collection => @comments %>
107   - <%= pagination_links @comments, :param_name => 'comment_page' %>
  94 + <% if @comments.present? %>
  95 + <%= render :partial => 'comment/comment', :collection => @comments %>
  96 + <%= pagination_links @comments, :param_name => 'comment_page' %>
  97 + <% end %>
108 98 </ul>
109 99  
110 100 <% if @page.accept_comments? %>
111   - <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:comment => Comment.new, :url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div>
  101 + <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div>
112 102 <% end %>
113 103 </div><!-- end class="comments" -->
114 104  
... ...
app/views/invite/_dialog_wait_loading.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 jQuery(function($) {
3 3 $("#loading-dialog").dialog({
4 4 height: 160,
... ...
app/views/invite/select_friends.html.erb
... ... @@ -32,9 +32,7 @@
32 32  
33 33 <br/>
34 34  
35   - <%= link_to_function(_('Personalize invitation mail'), nil) do |page|
36   - page['invitation-mail_template'].show
37   - end %>
  35 + <%= link_to ('Personalize invitation mail'), nil, :onclick => "jQuery('#invitation-mail_template').show(); return false;" %>
38 36  
39 37 <div id='invitation-mail_template' style='display:none'>
40 38 <%= h _("Now enter an invitation message. You must keep the <url> code in your invitation text. When your friends receive the invitation e-mail, <url> will be replaced by a link that they need to click to activate their account. <user> and <friend> codes will be replaced by your name and friend name, but they are optional.") %>
... ...
app/views/manage_products/_add_input.html.erb
1 1 <div id='request_result_message' style='display: none'></div>
2 2  
3   -<%= form_for(@input,
  3 +<%= form_for(:input,
4 4 :url => {:action => 'add_input', :id => @product},
5 5 :html => {:method => 'post', :id => 'input-category-form'}
6 6 ) do |f| %>
... ...
app/views/manage_products/_categories_for_selection.html.erb
1 1 <%= select_for_categories(categories, level) %>
2 2  
3   -<% javascript_tag do %>
  3 +<%= javascript_tag do %>
4 4 jQuery('#categories_container_wrapper').scrollTo('100%', 1000)
5 5 $('selected_category_id').value = <%= @category && @category.id %>
6 6 $('hierarchy_navigation').update('<%= escape_javascript(hierarchy_category_navigation(@category, :make_links => true)) %>')
... ...
app/views/manage_products/_certifiers_for_selection.html.erb
1 1 <%= select_certifiers(@qualifier) + remove_qualifier_button %>
2   -<% javascript_tag do %>
  2 +<%= javascript_tag do %>
3 3 jQuery('#product-qualifiers-list *').removeClass('small-loading')
4 4 <% end %>
... ...
app/views/manage_products/_display_name.html.erb
... ... @@ -2,7 +2,7 @@
2 2 <h2><%= @product.name_with_unit %></h2>
3 3 <%= edit_product_link_to_remote(@product, 'name', _('Edit name and unit'), :title => _('Click here to edit the name of your product and the unit')) %>
4 4 </div>
5   -<% javascript_tag do %>
  5 +<%= javascript_tag do %>
6 6 $$('#display-product-category .hierarchy-category')[0].update('<%=
7 7 escape_javascript(hierarchy_category_navigation(
8 8 @product.product_category,
... ...
app/views/manage_products/_edit_input.html.erb
1   -<%= form_for(@input, :url => {:controller => 'manage_products', :action => 'edit_input', :id => @input},
  1 +<%= form_for(:input, :url => {:controller => 'manage_products', :action => 'edit_input', :id => @input},
2 2 :html => {:method => 'post', :id => "edit-input-#{ @input.id }-form"}) do |f| %>
3 3  
4 4 <%= hidden_field_tag 'input-bar-update-url', @input.product.price_composition_bar_display_url, :class => 'bar-update-url' %>
... ...
app/views/manage_products/_form.html.erb
1 1 <%= error_messages_for :product %> <br/>
2 2  
3   -<%= form_for :product, @product, :html => {:multipart => true }, :url => {:action => mode} do |f| %>
  3 +<%= form_for :product, :html => {:multipart => true }, :url => {:action => mode} do |f| %>
4 4 <%= required_fields_message %>
5 5  
6 6 <%= display_form_field( _('Name:'), f.text_field(:name) ) %>
... ...
app/views/manage_products/_price_composition_bar.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 var value = <%= @product.price_description_percentage %>;
3 3 var total_cost = <%= @product.total_production_cost %>;
4 4 var price = '<%= @product.formatted_value(:price) %>';
... ...
app/views/manage_products/new.html.erb
... ... @@ -25,6 +25,6 @@
25 25  
26 26 <% end %>
27 27  
28   -<% javascript_tag do %>
  28 +<%= javascript_tag do %>
29 29 toggleDisabled(<%= @category && @category.accept_products? ? 'true' : 'false' %>, $('save_and_continue'))
30 30 <% end %>
... ...
app/views/memberships/index.html.erb
... ... @@ -8,11 +8,12 @@
8 8 <%= button :back, _('Go back'), :controller => 'profile_editor' %>
9 9 <% end %>
10 10  
11   -<% type_collection = [[nil, _('All')]] %>
  11 +<% type_collection = [[0, _('All')]] %>
12 12 <% type_collection += @roles.sort_by {|role| role.id}.map{|r| ["#{r.id}", r.name]} %>
13 13  
  14 +<%= javascript_include_tag "memberships_filter.js" %>
14 15 <p>
15   - <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, :onchange => 'document.location.href = "?filter_type="+this.value')%>
  16 + <%= labelled_select(_('Filter')+': ', :filter_type, :first, :last, @filter, type_collection, :id => 'memberships_filter')%>
16 17 </p>
17 18  
18 19 <% if @memberships.empty? %>
... ...
app/views/pending_task_notifier/notification.html.erb
... ... @@ -1,25 +0,0 @@
1   -<%= _("Dear %s") % @person.name %>,
2   -
3   -<%= _("You have %d pending task(s).") % @tasks.size %>
4   -
5   -<%= @tasks.map{|i| " * #{i.description}"}.join("\n") %>
6   -
7   -<%= _("Click in address below to process task(s):") %>
8   -
9   -<%= @url_for_pending_tasks %>
10   -<% @organizations_with_pending_tasks.each do |organization| %>
11   -<% pending_tasks = @person.pending_tasks_for_organization(organization) %>
12   -<%= _("%s has %d pending task(s).") % [organization.name, pending_tasks.size] %>
13   -
14   -<%= pending_tasks.map{|i| " * #{i.information}"}.join("\n") %>
15   -
16   -<%= _("Click in address below to process task(s):") %>
17   -
18   -<%= url_for(:host => @default_hostname, :controller => 'tasks', :profile => organization.identifier) %>
19   -<% end %>
20   -
21   -<%= _('Greetings,') %>
22   -
23   ---
24   -<%= _('%s team.') % @environment %>
25   -<%= @url %>
app/views/pending_task_notifier/notification.text.erb 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +<%= _("Dear %s") % @person.name %>,
  2 +
  3 +<%= _("You have %d pending task(s).") % @tasks.size %>
  4 +
  5 +<%= @tasks.map{|i| " * #{i.description}"}.join("\n") %>
  6 +
  7 +<%= _("Click in address below to process task(s):") %>
  8 +
  9 +<%= @url_for_pending_tasks %>
  10 +<% @organizations_with_pending_tasks.each do |organization| %>
  11 +<% pending_tasks = @person.pending_tasks_for_organization(organization) %>
  12 +<%= _("%s has %d pending task(s).") % [organization.name, pending_tasks.size] %>
  13 +
  14 +<%= pending_tasks.map{|i| " * #{i.information}"}.join("\n") %>
  15 +
  16 +<%= _("Click in address below to process task(s):") %>
  17 +
  18 +<%= url_for(:host => @default_hostname, :controller => 'tasks', :profile => organization.identifier) %>
  19 +<% end %>
  20 +
  21 +<%= _('Greetings,') %>
  22 +
  23 +--
  24 +<%= _('%s team.') % @environment %>
  25 +<%= @url %>
... ...
app/views/profile/index.html.erb
1   -<%= render :partial => 'shared/disabled_enterprise' %>
2   -
3 1 <h1><%= h profile.name %></h1>
4 2  
5 3 <% if @action %>
... ... @@ -19,7 +17,7 @@
19 17 <table class='profile'>
20 18 <tr>
21 19 <td colspan='2'>
22   - <% plugins_tabs = @plugins.dispatch(:profile_tabs).map { |tab| {:title => tab[:title], :id => tab[:id], :content => instance_exec(&tab[:content]), :start => tab[:title]} }%>
  20 + <% plugins_tabs = @plugins.dispatch(:profile_tabs).map { |tab| {:title => tab[:title], :id => tab[:id], :content => instance_exec(&tab[:content]), :start => tab[:start]} }%>
23 21  
24 22 <% tabs = plugins_tabs.select { |tab| tab[:start] } %>
25 23  
... ...
app/views/profile/report_abuse.html.erb
1   -<%= form_for @abuse_report, :url => {:action => 'register_report'},
  1 +<%= form_for :abuse_report, :url => {:action => 'register_report'},
2 2 :html => {:onsubmit => "return send_request(this)", :id => 'report-abuse-form'} do |f| %>
3 3 <%= labelled_form_field('* ' + _('Report reasons'), f.text_area(:reason, :rows => 6, :cols => 60, :class => 'required')) %>
4 4 <%= hidden_field_tag(:content_type, params[:content_type]) %>
... ...
app/views/profile/sitemap.html.erb
1 1 <h1><%= _("%s: site map") % profile.name %></h1>
2 2  
3   -<%= list_articles(available_articles(@articles, user), false) %>
  3 +<%= list_contents :contents=>available_articles(@articles, user), :list_type=>:sitemap %>
... ...
app/views/profile_editor/index.html.erb
... ... @@ -24,7 +24,7 @@
24 24  
25 25 <%= control_panel_button(_('Edit Appearance'), 'design-editor', :controller => 'profile_themes', :action => 'index') %>
26 26  
27   - <%= control_panel_button(_('Edit Header and Footer'), 'header-and-footer', :controller => 'profile_editor', :action => 'header_footer') unless profile.enterprise? && environment.enabled?('disable_header_and_footer') && !user.is_admin?(environment) %>
  27 + <%= control_panel_button(_('Edit Header and Footer'), 'header-and-footer', :controller => 'profile_editor', :action => 'header_footer') if user.is_admin?(environment) || (!profile.enterprise? && !environment.enabled?('disable_header_and_footer')) %>
28 28  
29 29 <%= control_panel_button(_('Manage Content'), 'cms', :controller => 'cms') %>
30 30  
... ...
app/views/scrap/notifier/notification.html.erb
... ... @@ -1,16 +0,0 @@
1   -<%= _('Hi, %{recipient}!') % { :recipient => @recipient } %>
2   -
3   -<%= word_wrap(_('%{sender} (%{sender_link}) has left the following scrap for you:') % { :sender => @sender, :sender_link => url_for(@sender_link) }) %>
4   -
5   --------------------------------------------------------------------------------
6   -<%= word_wrap(@scrap_content) %>
7   --------------------------------------------------------------------------------
8   -
9   -<%= _('View this scrap on the wall') %>:
10   -<%= url_for @wall_url %>
11   -
12   -<%= _("Greetings,") %>
13   -
14   ---
15   -<%= _('%s team.') % @environment %>
16   -<%= url_for @url %>
app/views/scrap/notifier/notification.text.erb 0 → 100644
... ... @@ -0,0 +1,16 @@
  1 +<%= _('Hi, %{recipient}!') % { :recipient => @recipient } %>
  2 +
  3 +<%= word_wrap(_('%{sender} (%{sender_link}) has left the following scrap for you:') % { :sender => @sender, :sender_link => url_for(@sender_link) }) %>
  4 +
  5 +-------------------------------------------------------------------------------
  6 +<%= word_wrap(@scrap_content) %>
  7 +-------------------------------------------------------------------------------
  8 +
  9 +<%= _('View this scrap on the wall') %>:
  10 +<%= url_for @wall_url %>
  11 +
  12 +<%= _("Greetings,") %>
  13 +
  14 +--
  15 +<%= _('%s team.') % @environment %>
  16 +<%= url_for @url %>
... ...
app/views/search/_image.html.erb
... ... @@ -5,7 +5,7 @@
5 5 <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %>
6 6 <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %>
7 7 <% if image.width && image.height %>
8   - <% javascript_tag do %>
  8 + <%= javascript_tag do %>
9 9 image = jQuery('script').last().parent().find('.search-image-pic');
10 10 des_width = parseInt(image.css('width'));
11 11 des_height = parseInt(image.css('height'));
... ...
app/views/search/search_page.html.erb
... ... @@ -11,7 +11,7 @@
11 11 <div style="clear: both"></div>
12 12  
13 13 <% if @asset == :product %>
14   - <% javascript_tag do %>
  14 + <%= javascript_tag do %>
15 15 jQuery('.search-product-price-details').altBeautify();
16 16 <% end %>
17 17 <% end %>
... ...
app/views/shared/_dialog_error_messages.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 close_loading()
3 3 jQuery('#errorExplanation h2').hide()
4 4 jQuery('#errorExplanation p').hide()
... ...
app/views/shared/_disabled_enterprise.html.erb
... ... @@ -1,10 +0,0 @@
1   -<% if profile.enterprise? && !profile.enabled? && !profile.blocks.select {|b| b.class == DisabledEnterpriseMessageBlock}.any? %>
2   - <div id='profile-disabled'>
3   - <%= environment.message_for_disabled_enterprise %>
4   - <% if profile.blocked? && user && user.is_admin?(profile.environment) %>
5   - <div class='unlock-button'>
6   - <%= button :lock, _('Unblock'), {:controller => 'profile', :action => 'unblock'} %>
7   - </div>
8   - <% end %>
9   - </div>
10   -<% end %>
app/views/shared/_manage_link.html.erb
1 1 <div id=<%= "manage-#{kind}" %> class="manage-groups">
2   - <a href="#" id=<%= "manage-#{kind}-link" %> class="simplemenu-trigger" title="<%= _('Manage %s') % kind %>"><i class=<%= "icon-menu-#{kind.singularize}" %>></i><strong><%= ui_icon('ui-icon-triangle-1-s') + _('My %s') % kind %></strong></a>
  2 + <a href="#" id=<%= "manage-#{kind}-link" %> class="simplemenu-trigger" title="<%= _('Manage %s') % _(kind) %>"><i class=<%= "icon-menu-#{kind.singularize}" %>></i><strong><%= ui_icon('ui-icon-triangle-1-s') + title %></strong></a>
3 3 <ul class="simplemenu-submenu">
4 4 <% link.each do |link| %>
5 5 <li class="simplemenu-item"><%= link %></li>
... ...
app/views/shared/_numbers_only_javascript.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 jQuery(".numbers-only").keypress(function(event) {
3 3 var separator = "<%= environment.currency_separator %>"
4 4 return numbersonly(event, separator)
... ...
app/views/shared/_redirect_via_javascript.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 update_loading('<%= _('redirecting...') %>')
3 3 redirect_to('<%= url %>')
4 4 <% end %>
... ...
app/views/shared/articles_list.html.erb
... ... @@ -1,14 +0,0 @@
1   -<table>
2   -
3   - <tr>
4   - <th><%= _('Title') %></th>
5   - <th><%= _('Last update') %></th>
6   - </tr>
7   - <% articles.each do |article| %>
8   - <% if article.display_to?(user) %>
9   - <%= display_article_in_listing(article, recursive, 0) %>
10   - <% end %>
11   - <% end %>
12   -</table>
13   -
14   -<p><%= pagination_links(articles, {:param_name => 'npage', :page_links => true}) %></p>
app/views/shared/content_list.html.erb 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<table class="<%= list_type %>-content">
  2 + <tr>
  3 + <th><%= _('Title') %></th>
  4 + <th><%= _('Last update') %></th>
  5 + </tr>
  6 + <% contents.each do |content| %>
  7 + <% if content.display_to?(user) %>
  8 + <%= display_content_in_listing :content=>content, :list_type=>list_type, :recursive=>recursive %>
  9 + <% end %>
  10 + <% end %>
  11 +</table>
  12 +
  13 +<p><%= pagination_links contents, :param_name => 'npage', :page_links => true %></p>
... ...
app/views/shared/update_categories.js.erb
1 1 <%
2 2 content = render :partial => 'shared/select_categories',
3   - :locals => {:object_name => 'article', :multiple => true}, :layout => false
  3 + :locals => {:object_name => object_name, :multiple => true}, :layout => false
4 4 %>
5 5 jQuery('#select-categories').html('<%= j(content) %>');
... ...
app/views/task_mailer/invitation_notification.html.erb
... ... @@ -1 +0,0 @@
1   -<%= @message %>
2 0 \ No newline at end of file