Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'origin/next' into fixes-jc

  • Loading branch information...
commit 6b5135109dc325564c2241f9b6280b79825154a8 2 parents 8314eaf + d023b75
@kuadrosx kuadrosx authored
View
11 Gemfile.lock
@@ -18,7 +18,7 @@ GIT
GIT
remote: git://github.com/mongoid/mongoid.git
- revision: b760004d5bc473cba63dacaec5c1be49202f3e4f
+ revision: 3607496b0a98ac62edd27cfe63f4b054130deb72
specs:
mongoid (2.0.1)
activemodel (~> 3.0)
@@ -70,7 +70,7 @@ GEM
activesupport (= 3.0.6)
activesupport (3.0.6)
addressable (2.2.4)
- arel (2.0.9)
+ arel (2.0.10)
autotest (4.4.6)
ZenTest (>= 4.4.1)
bcrypt-ruby (2.1.4)
@@ -113,10 +113,9 @@ GEM
faraday (0.6.1)
addressable (~> 2.2.4)
multipart-post (~> 1.1.0)
- rack (< 2, >= 1.1.0)
- ffaker (1.5.0)
- ffi (1.0.7)
- rake (>= 0.8.7)
+ rack (>= 1.1.0, < 2)
+ ffaker (1.6.0)
+ ffi (1.0.8)
fssm (0.2.7)
gem_plugin (0.2.3)
goalie (0.0.4)
View
6 app/controllers/groups_controller.rb
@@ -74,8 +74,9 @@ def edit
# POST /groups.json
def create
@group = Group.new
+ @group.languages = params[:languages].split(',') if params[:languages]
@group.safe_update(%w[name legend description default_tags subdomain logo forum enable_latex
- custom_favicon language languages theme signup_type custom_css wysiwyg_editor], params[:group])
+ custom_favicon language theme signup_type custom_css wysiwyg_editor], params[:group])
@group.safe_update(%w[isolate domain private], params[:group]) if current_user.admin?
@@ -101,10 +102,11 @@ def create
# PUT /groups/1
# PUT /groups/1.json
def update
+ @group.languages = params[:languages].split(',') if params[:languages]
@group.safe_update(%w[name legend description default_tags subdomain logo logo_info forum enable_latex
custom_favicon language languages theme reputation_rewards reputation_constrains
has_adult_content registered_only signup_type custom_css wysiwyg_editor fb_button notification_opts], params[:group])
- @group.share.safe_update(%w[fb_app_id fb_secret_key fb_active starts_with ends_with enable_twitter twitter_user twitter_pattern], params[:group][:share])
+ @group.share.safe_update(%w[fb_app_id fb_secret_key fb_active starts_with ends_with enable_twitter twitter_user twitter_pattern], params[:group][:share]) if params[:group][:share]
@group.safe_update(%w[isolate domain private has_custom_analytics has_custom_html has_custom_js], params[:group]) #if current_user.admin?
@group.safe_update(%w[analytics_id analytics_vendor], params[:group]) if @group.has_custom_analytics
@group.custom_html.update_attributes(params[:group][:custom_html] || {}) if @group.has_custom_html
View
8 app/controllers/invitations_controller.rb
@@ -36,9 +36,17 @@ def accept
end
end
+ def resend
+ invitation = Invitation.find(params[:id])
+ Jobs::Mailer.async.on_new_invitation(invitation.id).commit!
+ flash[:notice] = t("flash_notice", :scope => "invitations.create")
+ redirect_to :back
+ end
+
def revoke
invitation = Invitation.find(params[:id])
current_user.revoke_invite(invitation)
+ flash[:notice] = t("flash_notice", :scope => "invitations.create")
redirect_to :back
end
end
View
24 app/controllers/middlewares/dynamic_domain.rb
@@ -1,24 +0,0 @@
-class DynamicDomain
- def initialize(app)
- @app = app
- end
-
- def call(env)
- host = env["HTTP_HOST"].split(':').first
- if custom_domain?(host)
- ActionMailer::Base.default_url_options[:host] = host
- else
- ActionMailer::Base.default_url_options[:host] = AppConfig.domain
- host = ".#{AppConfig.domain}"
- end
-
- env["rack.session.options"][:domain] = host
-
- @app.call(env)
- end
-
- def custom_domain?(host)
- host !~ Regexp.new("#{AppConfig.domain}$", Regexp::IGNORECASE)
- end
-end
-
View
8 app/controllers/users_controller.rb
@@ -69,12 +69,14 @@ def index
# render new.rhtml
def new
@user = User.new
+ @user.preferred_languages = current_languages.to_a
@user.timezone = AppConfig.default_timezone
end
def create
@user = User.new
- @user.safe_update(%w[login email name password_confirmation password preferred_languages website
+ @user.preferred_languages = params[:preferred_languages].split(',') if params[:languages]
+ @user.safe_update(%w[login email name password_confirmation password website
language timezone identity_url bio hide_country], params[:user])
if params[:user]["birthday(1i)"]
@user.birthday = build_date(params[:user], "birthday")
@@ -178,8 +180,8 @@ def update
@user.password_confirmation = params[:user][:password_confirmation]
end
- @user.safe_update(%w[login email name language timezone preferred_languages
- notification_opts bio hide_country website avatar use_gravatar], params[:user])
+ @user.preferred_languages = params[:preferred_languages].split(',') if params[:languages]
+ @user.safe_update(%w[login email name language timezone notification_opts bio hide_country website avatar use_gravatar], params[:user])
if params[:user]["birthday(1i)"]
@user.birthday = build_date(params[:user], "birthday")
View
19 app/helpers/application_helper.rb
@@ -1,5 +1,11 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
+ def known_languages(user, group)
+ return group.languages unless logged_in?
+ languages = user.preferred_languages & group.languages
+ (languages.empty?)? group.languages : languages
+ end
+
def multiauth_dropdown(title)
render 'shared/login_menu', :title => title
end
@@ -14,6 +20,19 @@ def with_facebook?
end
end
+ def language_json
+ languages = []
+ I18n.t('languages').keys.each do |k| languages << {:caption => I18n.t("languages.#{k}"),
+ :value=>I18n.t("languages.#{k}"), :code => k} end
+ languages.to_json
+ end
+
+ def preferred_languages_code(entity, language_method)
+ entity.send(language_method).map do |code|
+ I18n.t("languages.#{code}")+":#{code}"
+ end
+ end
+
def language_desc(langs)
(langs.kind_of?(Array) ? langs : [langs]).map do |lang|
I18n.t("languages.#{lang}", :default => lang).capitalize
View
19 app/models/user.rb
@@ -560,7 +560,7 @@ def linked_in_friends
## TODO: add google contacts
def suggestions(group, limit = 5)
- sample = (suggested_social_friends(limit) | suggested_tags_by_suggested_friends(group, limit) ).sample(limit)
+ sample = (suggested_social_friends(group, limit) | suggested_tags_by_suggested_friends(group, limit) ).sample(limit)
# if we find less suggestions than requested, complete with
# most popular users and tags
@@ -588,7 +588,7 @@ def suggested_tags(group, limit = 5)
#returns tags followed by self suggested friends that I may not follow
def suggested_tags_by_suggested_friends(group, limit = 5)
- friends = suggested_social_friends(limit)
+ friends = suggested_social_friends(group, limit)
unless friends.blank?
friends.
where("membership_list.#{group.id}.preferred_tags" => {"$ne" => [], "$ne" => nil},
@@ -599,10 +599,12 @@ def suggested_tags_by_suggested_friends(group, limit = 5)
friend_preferred_tags = []
(friend.membership_list[group.id].nil?)? friend_preferred_tags = [] :
friend_preferred_tags = friend.membership_list[group.id]["preferred_tags"]
- (friend_preferred_tags-self.preferred_tags_on(group)).each do |tag|
- friends_tags["#{tag}"] ||= { }
- friends_tags["#{tag}"]["followed_by"] ||= []
- friends_tags["#{tag}"]["followed_by"] << friend
+ if friend_preferred_tags
+ (friend_preferred_tags-self.preferred_tags_on(group)).each do |tag|
+ friends_tags["#{tag}"] ||= { }
+ friends_tags["#{tag}"]["followed_by"] ||= []
+ friends_tags["#{tag}"]["followed_by"] << friend
+ end
end
end
friends_tags.to_a.sample(limit)
@@ -612,7 +614,7 @@ def suggested_tags_by_suggested_friends(group, limit = 5)
# returns user's providers friends that have an account
# on shapado but that user is not following
- def suggested_social_friends(limit = 5)
+ def suggested_social_friends(group, limit = 5)
array_hash = []
social_connections.to_a.each do |provider|
unless external_friends_list.friends[provider].blank?
@@ -620,7 +622,8 @@ def suggested_social_friends(limit = 5)
end
end
(array_hash.blank?)? [] : User.any_of(array_hash).
- where({:_id => {:$not =>
+ where({"membership_list.#{group.id}" => {"$ne" => [], "$ne" => nil},
+ :_id => {:$not =>
{:$in => self.friend_list.following_ids}}}).
limit(limit)
end
View
5 app/views/admin/manage/properties/_invitations.html.haml
@@ -4,4 +4,7 @@
= invitation.email
= form_tag revoke_invitation_path(invitation), :class => "form", :multipart => true, :method => :post do
= hidden_field_tag :source, domain_url(:custom => @group.domain, :controller => "admin/manage", :action => "invitations", :tab => @active_subtab)
- = submit_tag 'revoke'
+ = submit_tag t('.revoke_button')
+ = form_tag resend_invitation_path(invitation), :class => "form", :multipart => true, :method => :post do
+ = hidden_field_tag :source, domain_url(:custom => @group.domain, :controller => "admin/manage", :action => "invitations", :tab => @active_subtab)
+ = submit_tag t('.resend_button')
View
11 app/views/groups/_form.html.haml
@@ -126,16 +126,7 @@
= form.select :language, AVAILABLE_LANGUAGES.collect {|lang| [ language_desc(lang), lang ] }, :selected => @group.language || 'en', :class => "select"
.field
= form.label :language, t(:languages, :scope => "activerecord.attributes.group"), :class => "label"
- = link_to t('users.form.show_more_lang'), nil, :class => 'show-more-lang'
-
- - [DEFAULT_USER_LANGUAGES, AVAILABLE_LANGUAGES-DEFAULT_USER_LANGUAGES].each_with_index do |langs, index|
- -jsclass = index == 1 ? 'jshide' : ''
- -langs.sort.each do |lang|
- #lang_opts
- .radio_option{:id=>language_desc(lang)}
- = check_box_tag "group[languages][]", lang, @group.languages.include?(lang), :class => "langbox checkbox #{jsclass}"
- %label.radio.langbox{:class=>jsclass}
- = language_desc(lang)
+ = text_field_tag :languages, preferred_languages_code(@group, 'languages').join(','), :class => "text_field autocomplete_for_tags", 'data-opts'=> "{\"allowNewTags\": false, \"source\":#{language_json}}"
-else
= form.hidden_field :language, :value => (AppConfig.default_language || 'en')
View
15 app/views/groups/_top_grouplist.html.haml
@@ -1,16 +1,15 @@
%li.group
%small
- // TODO I18n
- Active site:
- = link_to current_group.name
+ = t('.active_site')
+ = link_to current_group.name, domain_url(:custom => current_group.domain)
%ul
-if logged_in?
- -current_user.groups.only(:name).limit(10).all.each do |group|
+ -current_user.groups.only(:name, :domain).limit(10).all.each do |group|
%li
- = link_to group.name, group_path(group)
+ = link_to group.name, domain_url(:custom => group.domain)
-else
- -Group.where(:state => "active", :private => false).order_by([:activity_rate, :desc]).limit(10).all.each do |group|
+ -Group.only(:name, :domain).where(:state => "active", :private => false).order_by([:activity_rate, :desc]).limit(10).all.each do |group|
%li
- = link_to group.name, group_path(group)
+ = link_to group.name, domain_url(:custom => group.domain)
%li
- = link_to t(".request_group"), new_group_path
+ = link_to t("groups.new.title"), new_group_path
View
2  app/views/pages/_form.html.haml
@@ -30,7 +30,7 @@
.group
= f.label :language, t(:language, :scope => "activerecord.attributes.question"), :class => "label"
-lang = @page.new? ? current_user.main_language : @page.language
- = f.select :language, languages_options(current_user.preferred_languages)+[[t("languages.any"), ""]], {:selected => lang}, :class => "select"
+ = f.select :language, languages_options(current_user.preferred_languages)+[[t("preferred_languages.any"), ""]], {:selected => lang}, :class => "select"
.description
= t(".language_tip")
-else
View
2  app/views/questions/_form.html.haml
@@ -43,7 +43,7 @@
.field
= f.label :language, t(:language, :scope => "activerecord.attributes.question"), :class => "label"
- selected = @question.new? ? current_group.language : @question.language
- = f.select :language, languages_options(current_group.languages), {:selected => selected}, {:class => "select"}
+ = f.select :language, languages_options(known_languages(current_user, current_group)), {:selected => selected}, {:class => "select"}
%small
= t(".language_tip")
-else
View
10 app/views/users/_form.html.haml
@@ -74,14 +74,8 @@
-if AppConfig.enable_i18n
.field
= f.label :preferred_languages, t(:preferred_languages, :scope => "activerecord.attributes.user"), :class => "label"
- = link_to t('.show_more_lang'), nil, :class => 'show-more-lang'
- -AVAILABLE_LANGUAGES.sort.each do |lang|
- - (DEFAULT_USER_LANGUAGES.include? lang)? jsclass = '' : jsclass = 'jshide'
- #lang_opts
- .radio_option{:id=>language_desc(lang)}
- = check_box_tag "user[preferred_languages][]", lang, @user.preferred_languages.include?(lang), :class => "langbox checkbox #{jsclass}"
- %label.radio.langbox{:class=>jsclass}
- = language_desc(lang)
+ = text_field_tag :preferred_languages, preferred_languages_code(@user, 'preferred_languages').join(','), :class => "text_field autocomplete_for_tags", 'data-opts'=> "{\"allowNewTags\": false, \"source\":#{language_json}}"
+
-else
= hidden_field_tag "user[preferred_languages][]", (current_group.language || AppConfig.default_language)
View
2  config/deploy.rb
@@ -18,7 +18,7 @@
assets.compass
assets.package
- magent.restart
+ #magent.restart
bluepill.restart
end
end
View
22 config/initializers/patches.rb
@@ -14,3 +14,25 @@ def lock_with_hack
alias_method :lock_without_hack, :lock
alias_method :lock, :lock_with_hack
end
+
+# patch for Omniauth::Facebook to be able to use the group credentials
+OmniAuth.config.path_prefix = "/users/auth"
+module OmniAuth
+ module Strategies
+ class Facebook
+ def call!(env)
+ host = env["HTTP_HOST"].split(':').first
+
+ if (group = Group.where(:domain => host).only(:share).first) && group.share.fb_app_id.present? && group.share.fb_secret_key.present?
+ self.client_id = group.share.fb_app_id
+ self.client_secret = group.share.fb_secret_key
+
+ Rails.logger.info "Using custom keys for #{group.name} (app_id=#{self.client_id})"
+ end
+
+ super
+ end
+ end
+ end
+end
+
View
2  config/locales/global/en.yml
@@ -68,7 +68,7 @@ en:
feed: Feed
post_new_questions: Post new questions to
share_on_twitter: "Twitter, Facebook and more..."
- languages:
+ preferred_languages:
any: Any
user: My preferred languages
number:
View
2  config/locales/groups/en.yml
@@ -1,5 +1,7 @@
en:
groups:
+ top_grouplist:
+ active_site: "Active site:"
index:
title: Groups
description: This is the list of public groups that have been created. Use the search input below to filter groups. You can also %{link}.
View
7 config/locales/invitations/en.yml
@@ -1,7 +1,11 @@
en:
invitations:
+ resend:
+ flash_notice: "Your invitation has been resent successfully."
+ revoke:
+ flash_notice: "Your invitation has been revoked successfully."
create:
- flash_notice: Your invitations were sent successfully
+ flash_notice: "Your invitations were sent successfully."
accept:
welcome: Welcome
description: %{group} is an ever improving collection of questions and answers about any topic.
@@ -20,3 +24,4 @@ en:
follow_things: Follow Tags and People
follow_things_description: Questions related to these will appear on your feed.
done: 'Done!'
+
View
3  config/locales/manage/en.yml
@@ -41,6 +41,9 @@ en:
user_role: "Invite users as"
invite: Invite people
invitations: Sent invitations
+ invitations:
+ revoke_button: "Revoke"
+ resend_button: "Resend"
post_to_twitter:
post_to_twitter: Post activities to Twitter
send_questions_to_twitter: Send all questions to Twitter
View
4 config/locales/users/en.yml
@@ -43,9 +43,9 @@ en:
sort_by: 'Sort by:'
edit_profile: Edit profile
follow:
- flash_notice: "The user %{user} was added to your friends"
+ flash_notice: "You are now following %{user}."
unfollow:
- flash_notice: "The user %{user} was removed from your friends"
+ flash_notice: "You are not following %{user} anymore."
update_followed_tags:
followed:
flash_notice: "You are now following the tag %{tag}."
View
1  config/routes.rb
@@ -158,6 +158,7 @@
resources :invitations do
member do
post :revoke
+ post :resend
end
end
View
1  public/javascripts/application.js
@@ -228,7 +228,6 @@ function init_geolocal(){
}
function initFollowTags(){
- console.log('beep')
$(".follow-tag, .unfollow-tag").live("click", function(event) {
var link = $(this);
if(!link.hasClass('busy')){
View
32 public/javascripts/jqueryui.ricodigoComplete.js
@@ -1,12 +1,13 @@
(function($) {
- $.fn.ricodigoComplete = function(){
+ $.fn.ricodigoComplete = function(opts){
this.each(function(){
- function addTag(tag, input){
+ function addTag(tag, input, code){
+ if(code) {hiddenTag = code;} else {hiddenTag=tag;}
var tag = $.trim(tag.replace(',',''));
- if(!input.parent().find('.added-tag[data-caption='+tag+']').length){
+ if(!input.parent().find('.added-tag[data-caption="'+hiddenTag+'"]').length){
input.val('');
input.removeAttr('data-init')
- var tag = $('<ul style="margin-left:4px;margin-right:4px;margin-top:6px;" class="ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem"><li class="ui-menu-item" role="menuitem"><a class="ui-corner-all added-tag" tabindex="-1" id="ui-active-menuitem" data-caption="'+tag+'">'+tag+'&nbsp;<span style="font-weight:bold;cursor:pointer;" class="remove-tag">x</span></a></li></ul>');
+ var tag = $('<ul style="margin-left:4px;margin-right:4px;margin-top:6px;" class="ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem"><li class="ui-menu-item" role="menuitem"><a class="ui-corner-all added-tag" tabindex="-1" id="ui-active-menuitem" data-caption="'+hiddenTag+'">'+tag+'&nbsp;<span style="font-weight:bold;cursor:pointer;" class="remove-tag">x</span></a></li></ul>');
input.before(tag);
input.css({width: '30px'});
input.attr({placeholder: ''});
@@ -31,6 +32,9 @@
tagwrapper.css('min-height', '40px');
tagwrapper.css('margin-top', '0px');
+ dataOpts = tagInput.attr('data-opts');
+ if(dataOpts){opts = $.evalJSON(dataOpts)}else{opts={allowNewTags: true}};
+
tagInput.wrap(tagwrapper);
var tagwrapper = tagInput.parent('.tagwrapper');
tagwrapper.click(function (){tagwrapper.children('.autocomplete_for_tags').focus();});
@@ -57,7 +61,7 @@
tagLink.removeClass('ui-state-hover');
if($(this).width()>38 && !$(this).attr('data-init'))
$(this).width($(this).width()-7);
- } else if ((key == 9 || key == 32 || key == 188 || key == 13) && $.trim($(this).val().replace(',','')) != '') {
+ } else if (opts.allowNewTags && (key == 9 || key == 32 || key == 188 || key == 13) && $.trim($(this).val().replace(',','')) != '') {
tagLink.removeClass('ui-state-hover');
addTag($(this).val(), $(this));
$(this).focus();
@@ -73,19 +77,25 @@
if(tags!=''){
tags = tags.split(',')
$.each(tags,function(i, tag){
- addTag(tag, ac);
+ if(tag.indexOf(':')!=-1){
+ addTag(tag.split(':')[0], ac, tag.split(':')[1]);
+ } else {
+ addTag(tag, ac);
+ }
})
$(this).val('');
}
var cache = {},
lastXhr;
tagInput.autocomplete({
+ autoFocus: true,
select: function(event, ui) {
- addTag(ui.item.label, $(this))
+ addTag(ui.item.label, $(this), ui.item.code)
return false;
},
minLength: 1,
- source: function( request, response ) {
+ source: (opts.source)? opts.source : function( request, response ) {
+ //if(!opts.source){
var term = request.term;
if( $.trim(term.replace(',','')) == '' )
return;
@@ -99,10 +109,12 @@
if ( xhr === lastXhr ) {
response( data );
}
- });
+ });/*} else {
+ opts.source
+ }*/
}
}).data( "autocomplete" )._renderItem = function( ul, item ) {
- return $( "<li></li>" )
+ return $( '<li></li>' )
.data( "item.autocomplete", item )
.append( "<a>" + item.caption + "</a>" )
.appendTo( ul );
Please sign in to comment.
Something went wrong with that request. Please try again.