Commit 1354f6b92f307e1e591bde6fa37d263a63bebb14

Authored by Victor Costa
2 parents ac69c489 7e1172c4

Merge branch 'master' into stable

config/application.rb
... ... @@ -118,7 +118,8 @@ module Noosfero
118 118 config.time_zone = File.read('/etc/timezone').split("\n").first
119 119 config.active_record.default_timezone = :local
120 120  
121   - config.i18n.load_path += Dir.glob "#{Rails.root}/{baseplugins,config/plugins/*}/locales/*.{rb,yml}"
  121 + config.paths['db/migrate'] += Dir.glob "#{Rails.root}/{baseplugins,config/plugins}/*/db/migrate"
  122 + config.i18n.load_path += Dir.glob "#{Rails.root}/{baseplugins,config/plugins}/*/locales/*.{rb,yml}"
122 123  
123 124 Noosfero::Plugin.setup(config)
124 125  
... ...
etc/noosfero/varnish-accept-language.vcl
... ... @@ -6,7 +6,14 @@ C{
6 6 /*
7 7 * Accept-language header normalization
8 8 *
9   - * Cosimo, 21/01/2010
  9 + * - Parses client Accept-Language HTTP header
  10 + * - Tries to find the best match with the supported languages
  11 + * - Writes the best match as req.http.X-Varnish-Accept-Language
  12 + *
  13 + * First version: Cosimo, 21/Jan/2010
  14 + * Last update: Cosimo, 03/Nov/2011
  15 + *
  16 + * http://github.com/cosimo/varnish-accept-language
10 17 *
11 18 */
12 19  
... ... @@ -16,11 +23,12 @@ C{
16 23 #include <string.h>
17 24  
18 25 #define DEFAULT_LANGUAGE "en"
19   -#define SUPPORTED_LANGUAGES ":de:fr:es:ru:pt:hy:en:"
  26 +#define SUPPORTED_LANGUAGES ":de:eo:es:fr:hy:it:pt:ru:"
20 27  
21 28 #define vcl_string char
22   -#define LANG_LIST_SIZE 16
23   -#define LANG_MAXLEN 16
  29 +#define LANG_LIST_SIZE 16
  30 +#define HDR_MAXLEN 256
  31 +#define LANG_MAXLEN 8
24 32 #define RETURN_LANG(x) { \
25 33 strncpy(lang, x, LANG_MAXLEN); \
26 34 return; \
... ... @@ -64,9 +72,8 @@ int is_supported(vcl_string *lang) {
64 72 strncat(match_str, lang, LANG_MAXLEN);
65 73 strncat(match_str, ":\0", 2);
66 74  
67   - if (strstr(supported_languages, match_str)) {
  75 + if (strstr(supported_languages, match_str))
68 76 is_supported = 1;
69   - }
70 77  
71 78 return is_supported;
72 79 }
... ... @@ -90,6 +97,7 @@ void select_language(const vcl_string *incoming_header, char *lang) {
90 97 vcl_string *lang_tok = NULL;
91 98 vcl_string root_lang[3];
92 99 vcl_string *header;
  100 + vcl_string header_copy[HDR_MAXLEN];
93 101 vcl_string *pos = NULL;
94 102 vcl_string *q_spec = NULL;
95 103 unsigned int curr_lang = 0, i = 0;
... ... @@ -106,7 +114,7 @@ void select_language(const vcl_string *incoming_header, char *lang) {
106 114 RETURN_DEFAULT_LANG;
107 115  
108 116 /* Tokenize Accept-Language */
109   - header = (vcl_string *) incoming_header;
  117 + header = strncpy(header_copy, incoming_header, sizeof(header_copy));
110 118  
111 119 while ((lang_tok = strtok_r(header, " ,", &pos))) {
112 120  
... ... @@ -137,7 +145,8 @@ void select_language(const vcl_string *incoming_header, char *lang) {
137 145 header = NULL;
138 146  
139 147 /* Break out if stored max no. of languages */
140   - if (curr_lang >= LANG_MAXLEN) break;
  148 + if (curr_lang >= LANG_LIST_SIZE)
  149 + break;
141 150 }
142 151  
143 152 /* Sort by priority */
... ... @@ -157,12 +166,11 @@ void vcl_rewrite_accept_language(const struct sess *sp) {
157 166 vcl_string *in_hdr;
158 167 vcl_string lang[LANG_MAXLEN];
159 168  
160   - memset(lang, 0, LANG_MAXLEN);
161   -
162 169 /* Get Accept-Language header from client */
163 170 in_hdr = VRT_GetHdr(sp, HDR_REQ, "\020Accept-Language:");
164 171  
165 172 /* Normalize and filter out by list of supported languages */
  173 + memset(lang, 0, sizeof(lang));
166 174 select_language(in_hdr, lang);
167 175  
168 176 /* By default, use a different header name: don't mess with backend logic */
... ... @@ -191,3 +199,4 @@ sub vcl_fetch {
191 199 set beresp.http.Vary = "X-Varnish-Accept-Language";
192 200 }
193 201 }
  202 +
... ...
lib/tasks/plugins.rake
... ... @@ -6,17 +6,6 @@ namespace :noosfero do
6 6  
7 7 plugin_migration_dirs = Dir.glob(Rails.root.join('{baseplugins,config/plugins}', '*', 'db', 'migrate'))
8 8  
9   - task :load_config do
10   - dirs = Dir.glob("{baseplugins,config/plugins}/*").uniq do |dir|
11   - File.basename(dir)
12   - end.map do |dir|
13   - File.join(dir, 'db/migrate')
14   - end
15   - dirs.each do |dir|
16   - ActiveRecord::Migrator.migrations_paths << dir
17   - end
18   - end
19   -
20 9 task :migrate do
21 10 plugin_migration_dirs.each do |path|
22 11 ActiveRecord::Migrator.migrate(path, ENV["VERSION"] ?
... ... @@ -26,5 +15,3 @@ namespace :noosfero do
26 15 end
27 16 end
28 17  
29   -task 'db:migrate' => 'noosfero:plugins:load_config'
30   -task 'db:schema:load' => 'noosfero:plugins:load_config'
... ...
lib/tasks/release.rake
... ... @@ -222,7 +222,7 @@ EOF
222 222 puts "I: please upload the package manually!"
223 223 end
224 224  
225   - rm_f "rm tmp/pending-release"
  225 + rm_f "tmp/pending-release"
226 226 end
227 227  
228 228 desc 'Build Debian packages'
... ...