Merge branch 'next-minor' into develop

This commit is contained in:
Steffen van Bergerem 2016-09-28 22:00:10 +02:00
commit 3437c4d5cb
No known key found for this signature in database
GPG key ID: 315C9787D548DC6B
30 changed files with 185 additions and 229 deletions

View file

@ -21,6 +21,7 @@ Note: Although this is a minor release, the configuration file changed because t
* Use translation for NodeInfo services [#7102](https://github.com/diaspora/diaspora/pull/7102)
* Adopt new Mapbox tile URIs [#7066](https://github.com/diaspora/diaspora/pull/7066)
* Refactored post interactions on the single post view [#7089](https://github.com/diaspora/diaspora/pull/7089)
* Extract inline JavaScript [#7113](https://github.com/diaspora/diaspora/pull/7113)
## Bug fixes
* Post comments no longer get collapsed when interacting with a post [#7040](https://github.com/diaspora/diaspora/pull/7040)

View file

@ -4,6 +4,11 @@ app.pages.Settings = Backbone.View.extend({
$(".settings-visibility").tooltip({placement: "top"});
$(".profile-visibility-hint").tooltip({placement: "top"});
$("[name='profile[public_details]']").bootstrapSwitch();
new Diaspora.TagsAutocomplete("#profile_tag_string", {
preFill: gon.preloads.tagsArray
});
new Diaspora.ProfilePhotoUploader();
}
});
// @license-end

View file

@ -18,7 +18,6 @@ app.views.PublisherGettingStarted = Backbone.View.extend({
// initiate all the popover message boxes
show: function() {
app.publisher.open();
this._addPopover(this.firstMessage, {
trigger: "manual",
id: "first_message_explain",

View file

@ -91,6 +91,7 @@ app.views.Publisher = Backbone.View.extend({
this.initSubviews();
this.checkSubmitAvailability();
this.triggerGettingStarted();
return this;
},
@ -184,7 +185,10 @@ app.views.Publisher = Backbone.View.extend({
// show the "getting started" popups around the publisher
triggerGettingStarted: function() {
this.viewGettingStarted.show();
if (gon.preloads.getting_started) {
this.open();
this.viewGettingStarted.show();
}
},
createStatusMessage : function(evt) {

View file

@ -1,6 +1,5 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
//= require jquery.autoSuggest.custom
app.views.TagFollowingList = app.views.Base.extend({
templateName: "tag_following_list",
@ -30,29 +29,9 @@ app.views.TagFollowingList = app.views.Base.extend({
},
setupAutoSuggest : function() {
this.$("input").autoSuggest("/tags", {
selectedItemProp: "name",
selectedValuesProp: "name",
searchObjProps: "name",
asHtmlID: "tags",
neverSubmit: true,
retrieveLimit: 10,
selectionLimit: false,
minChars: 2,
keyDelay: 200,
startText: "",
emptyText: "no_results",
new Diaspora.TagsAutocomplete(this.$("input"), {
selectionAdded: _.bind(this.suggestSelection, this)
});
this.$("input").bind('keydown', function(evt){
if(evt.which === Keycodes.ENTER || evt.which === Keycodes.TAB || evt.which === Keycodes.SPACE) {
evt.preventDefault();
if( $('li.as-result-item.active').length === 0 ){
$('li.as-result-item').first().click();
}
}
});
},
presenter : function() {

View file

@ -30,4 +30,10 @@ var List = {
setTimeout( "List.runDelayedSearch('" + theSearch + "')", 10000);
}
};
$(document).ready(function() {
if (gon.preloads.background_query) {
List.startSearchDelay(gon.preloads.background_query);
}
});
// @license-end

View file

@ -0,0 +1,61 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
Diaspora.ProfilePhotoUploader = function() {
this.initialize();
};
Diaspora.ProfilePhotoUploader.prototype = {
constructor: Diaspora.ProfilePhotoUploader,
initialize: function() {
new qq.FileUploaderBasic({
element: document.getElementById("file-upload"),
params: {"photo": {"pending": true, "aspect_ids": "all", "set_profile_photo": true}},
allowedExtensions: ["jpg", "jpeg", "png"],
action: "/photos",
button: document.getElementById("file-upload"),
sizeLimit: 4194304,
onProgress: function(id, fileName, loaded, total) {
var progress = Math.round(loaded / total * 100);
$("#fileInfo").text(fileName + " " + progress + "%");
},
messages: {
typeError: Diaspora.I18n.t("photo_uploader.invalid_ext"),
sizeError: Diaspora.I18n.t("photo_uploader.size_error"),
emptyError: Diaspora.I18n.t("photo_uploader.empty")
},
onSubmit: function() {
$("#file-upload").addClass("loading");
$("#profile_photo_upload").find(".avatar").addClass("loading");
$("#file-upload-spinner").removeClass("hidden");
$("#fileInfo").show();
},
onComplete: function(_id, fileName, responseJSON) {
$("#file-upload-spinner").addClass("hidden");
$("#fileInfo").text(Diaspora.I18n.t("photo_uploader.completed", {"file": fileName}));
$("#file-upload").removeClass("loading");
/* flash message prompt */
var message = Diaspora.I18n.t("photo_uploader.looking_good");
if (app.flashMessages) { app.flashMessages.success(message); }
var id = responseJSON.data.photo.id;
var url = responseJSON.data.photo.unprocessed_image.url;
var oldPhoto = $("#photo_id");
if (oldPhoto.length === 0) {
$("#update_profile_form").prepend("<input type='hidden' value='" + id + "' id='photo_id' name='photo_id'/>");
} else {
oldPhoto.val(id);
}
$("#profile_photo_upload").find(".avatar").removeClass("loading");
$("#profile_photo_upload").find(".avatar").attr("src", url);
}
});
}
};
// @license-end

View file

@ -0,0 +1,41 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
Diaspora.TagsAutocomplete = function(element, opts) {
this.initialize(element, opts);
};
Diaspora.TagsAutocomplete.prototype = {
constructor: Diaspora.TagsAutocomplete,
initialize: function(element, opts) {
this.options = {
selectedItemProp: "name",
selectedValuesProp: "name",
searchObjProps: "name",
asHtmlID: "tags",
neverSubmit: true,
retrieveLimit: 10,
selectionLimit: false,
minChars: 2,
keyDelay: 200,
startText: "",
emptyText: Diaspora.I18n.t("no_results")
};
$.extend(this.options, opts);
this.autocompleteInput = $(element);
this.autocompleteInput.autoSuggest("/tags", this.options);
this.autocompleteInput.bind("keydown", this.keydown);
},
keydown: function(evt) {
if (evt.which === Keycodes.ENTER || evt.which === Keycodes.TAB || evt.which === Keycodes.SPACE) {
evt.preventDefault();
if ($("li.as-result-item.active").length === 0) {
$("li.as-result-item").first().click();
}
}
}
};
// @license-end

View file

@ -17,6 +17,7 @@
//= require jquery-ui/mouse
//= require jquery-ui/sortable
//= require keycodes
//= require jquery.autoSuggest.custom
//= require fileuploader-custom
//= require handlebars.runtime
//= require posix-bracket-expressions

View file

@ -0,0 +1,21 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
$(document).ready(function() {
function publisherContent(params) {
if (params.content) {
return params.content;
}
var content = params.title + " - " + params.url;
if (params.notes.length > 0) {
content += " - " + params.notes;
}
return content;
}
var content = publisherContent(gon.preloads.bookmarklet);
if (content.length > 0) {
$("#status_message_text").val(content);
}
});
// @license-end

View file

@ -16,9 +16,12 @@
//= require bootstrap
//= require diaspora
//= require helpers/i18n
//= require helpers/profile_photo_uploader
//= require helpers/tags_autocomplete
//= require widgets/timeago
//= require mobile/mobile_application
//= require mobile/mobile_file_uploader
//= require mobile/mobile_profile_edit
//= require mobile/profile_aspects
//= require mobile/tag_following
//= require mobile/publisher

View file

@ -0,0 +1,12 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3-or-Later
$(document).ready(function() {
if (Diaspora.Page === "ProfilesEdit") {
new Diaspora.TagsAutocomplete("#profile_tag_string", {preFill: gon.preloads.tagsArray});
new Diaspora.ProfilePhotoUploader();
} else if (Diaspora.Page === "UsersGettingStarted") {
new Diaspora.TagsAutocomplete("#follow_tags", {preFill: gon.preloads.tagsArray});
new Diaspora.ProfilePhotoUploader();
}
});
// @license-end

View file

@ -49,37 +49,16 @@ Diaspora.Pages.UsersGettingStarted = function() {
return confirmation;
});
/* ------ */
var autocompleteInput = $("#follow_tags");
var tagFollowings = new app.collections.TagFollowings();
autocompleteInput.autoSuggest("/tags", {
selectedItemProp: "name",
selectedValuesProp: "name",
searchObjProps: "name",
asHtmlID: "tags",
neverSubmit: true,
retrieveLimit: 10,
selectionLimit: false,
minChars: 2,
keyDelay: 200,
startText: "",
emptyText: "no_results",
new Diaspora.TagsAutocomplete("#follow_tags", {
preFill: gon.preloads.tagsArray,
selectionAdded: function(elem){tagFollowings.create({"name":$(elem[0]).text().substring(2)})},
selectionRemoved: function(elem){
tagFollowings.where({"name":$(elem[0]).text().substring(2)})[0].destroy();
elem.remove();
}
});
autocompleteInput.bind('keydown', function(evt){
if(evt.which === Keycodes.ENTER || evt.which === Keycodes.TAB || evt.which === Keycodes.SPACE) {
evt.preventDefault();
if( $('li.as-result-item.active').length === 0 ){
$('li.as-result-item').first().click();
}
}
});
new Diaspora.ProfilePhotoUploader();
});
};
// @license-end

View file

@ -39,13 +39,10 @@ class PeopleController < ApplicationController
end
format.any(:html, :mobile) do
#only do it if it is an email address
# only do it if it is a diaspora*-ID
if diaspora_id?(search_query)
@people = Person.where(diaspora_handle: search_query.downcase, closed_account: false)
if @people.empty?
Workers::FetchWebfinger.perform_async(search_query)
@background_query = search_query.downcase
end
background_search(search_query) if @people.empty?
end
@people = @people.paginate(:page => params[:page], :per_page => 15)
@hashes = hashes_for_people(@people, @aspects)
@ -167,6 +164,12 @@ class PeopleController < ApplicationController
raise Diaspora::AccountClosed if @person.closed_account?
end
def background_search(search_query)
Workers::FetchWebfinger.perform_async(search_query)
@background_query = search_query.downcase
gon.preloads[:background_query] = @background_query
end
def hashes_for_people(people, aspects)
people.map {|person|
{

View file

@ -23,12 +23,7 @@ class ProfilesController < ApplicationController
@aspect = :person_edit
@profile = @person.profile
@tags = @profile.tags
@tags_array = []
@tags.each do |obj|
@tags_array << { :name => ("#"+obj.name),
:value => ("#"+obj.name)}
end
gon.preloads[:tagsArray] = @profile.tags.map {|tag| {name: "##{tag.name}", value: "##{tag.name}"} }
end
def update

View file

@ -28,7 +28,8 @@ class StreamsController < ApplicationController
end
def multi
stream_responder(Stream::Multi)
gon.preloads[:getting_started] = current_user.getting_started
stream_responder(Stream::Multi)
end
def commented

View file

@ -87,6 +87,7 @@ class UsersController < ApplicationController
@person = @user.person
@profile = @user.profile
gon.preloads[:inviter] = PersonPresenter.new(current_user.invited_by.try(:person), current_user).as_json
gon.preloads[:tagsArray] = current_user.followed_tags.map {|tag| {name: "##{tag.name}", value: "##{tag.name}"} }
render "users/getting_started"
end

View file

@ -25,7 +25,7 @@ module InterimStreamHackinessHelper
if params[:prefill].present?
params[:prefill]
elsif defined?(@stream)
@stream.publisher.prefill
@stream.publisher.prefill
else
nil
end
@ -50,8 +50,4 @@ module InterimStreamHackinessHelper
def publisher_public
publisher_method(:public)
end
def publisher_explain
publisher_method(:explain)
end
end

View file

@ -16,20 +16,12 @@
.col-md-8
#people_stream.stream
- if @hashes.empty?
- if @background_query.present?
/ TODO this is gross, and should be extracted!
:javascript
$(document).ready( function() {
List.startSearchDelay('#{@background_query}')
} );
%p
%p
- if @background_query.present?
= t(".searching")
.loader
.spinner
- else
%p
- else
= t('.no_one_found')
- else
- for hash in @hashes

View file

@ -2,62 +2,6 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- content_for :head do
:javascript
function createUploader(){
var uploader = new qq.FileUploaderBasic({
element: document.getElementById('file-upload'),
params: {'photo' : {'pending' : true, 'aspect_ids' : "all", 'set_profile_photo': true}},
allowedExtensions: ['jpg', 'jpeg', 'png'],
action: "#{photos_path}",
button: document.getElementById('file-upload'),
sizeLimit: 4194304,
onProgress: function(id, fileName, loaded, total){
var progress = Math.round(loaded / total * 100 );
$('#fileInfo').text(fileName + ' ' + progress + '%');
},
messages: {
typeError: "#{t('photos.new_photo.invalid_ext')}",
sizeError: "#{t('photos.new_photo.size_error')}",
emptyError: "#{t('photos.new_photo.empty')}"
},
onSubmit: function(id, fileName){
$('#file-upload').addClass("loading");
$("#profile_photo_upload").find(".avatar").addClass('loading');
$("#file-upload-spinner").removeClass("hidden");
$("#fileInfo").show();
},
onComplete: function(id, fileName, responseJSON){
$("#file-upload-spinner").addClass("hidden");
$("#fileInfo").text(Diaspora.I18n.t("photo_uploader.completed", {"file": fileName}));
$('#file-upload').removeClass("loading");
/* flash message prompt */
var message = Diaspora.I18n.t("photo_uploader.looking_good");
if(app.flashMessages) { app.flashMessages.success(message); }
var id = responseJSON.data.photo.id;
var url = responseJSON.data.photo.unprocessed_image.url;
var oldPhoto = $('#photo_id');
if(oldPhoto.length == 0) {
$('#update_profile_form').prepend("<input type='hidden' value='" + id + "' id='photo_id' name='photo_id'/>");
} else {
oldPhoto.val(id);
}
$("#profile_photo_upload").find(".avatar").removeClass('loading');
$("#profile_photo_upload").find(".avatar").attr("src",url);
$(".avatar[data-person_id=#{current_user.person.id}]").attr("src",url);
}
});
}
window.onload = createUploader;
.profile-photo-upload#profile_photo_upload
= owner_image_tag(:thumb_large)
.small-horizontal-spacer

View file

@ -1,33 +1,3 @@
- content_for :head do
:javascript
$(document).ready(function () {
var data = $.parseJSON( '#{@tags_array.to_json.gsub("'", "\\\\'")}' ),
autocompleteInput = $("#profile_tag_string");
autocompleteInput.autoSuggest("#{tags_path}", {
selectedItemProp: "name",
selectedValuesProp: "name",
searchObjProps: "name",
asHtmlID: "tags",
neverSubmit: true,
retrieveLimit: 10,
minChars: 2,
keyDelay: 200,
startText: "",
emptyText: "#{t('no_results')}",
preFill: data
});
autocompleteInput.bind('keydown', function(evt){
if(evt.which === Keycodes.ENTER || evt.which === Keycodes.TAB || evt.which === Keycodes.SPACE) {
evt.preventDefault();
if( $('li.as-result-item.active').length == 0 ){
$('li.as-result-item').first().click();
}
}
});
});
%h3.inline
= t("profiles.edit.basic")
%span{ :title => t("profiles.edit.basic_hint") }

View file

@ -1,9 +1,3 @@
-if publisher_explain
:javascript
$(document).ready(function() {
if( app.publisher ) app.publisher.triggerGettingStarted();
});
.row.publisher#publisher{class: ((aspect == :profile || publisher_open) ? "mention_popup" : "closed")}
.content_creation
= form_for(StatusMessage.new) do |status|

View file

@ -4,18 +4,4 @@
= render :partial => 'publisher/publisher', :locals => { :aspect => :profile, :selected_aspects => @aspects, :aspect_ids => @aspect_ids }
:javascript
var contents = "#{escape_javascript params[:content]}";
if(!contents){
contents = "#{escape_javascript params[:title]} - #{escape_javascript params[:url]}";
var notes = "#{escape_javascript params[:notes]}";
if (notes.length > 0){
contents += " - " + notes;
}
}
$(document).ready(function() {
if (contents.length > 0) {
$("#status_message_text").val(contents);
}
});
= javascript_include_tag "mobile/bookmarklet"

View file

@ -2,36 +2,6 @@
-# licensed under the Affero General Public License version 3 or later. See
-# the COPYRIGHT file.
- content_for :head do
:javascript
$(document).ready(function () {
var data = $.parseJSON( '#{@tags_array.to_json.gsub("'", "\\\\'")}' ),
autocompleteInput = $("#follow_tags");
autocompleteInput.autoSuggest("#{tags_path}", {
selectedItemProp: "name",
selectedValuesProp: "name",
searchObjProps: "name",
asHtmlID: "tags",
neverSubmit: true,
retrieveLimit: 10,
minChars: 2,
keyDelay: 200,
startText: "",
emptyText: "#{t('no_results')}",
preFill: data
});
autocompleteInput.bind('keydown', function(evt){
if(evt.which === Keycodes.ENTER || evt.which === Keycodes.TAB || evt.which === Keycodes.SPACE) {
evt.preventDefault();
if( $('li.as-result-item.active').length == 0 ){
$('li.as-result-item').first().click();
}
}
});
});
:css
.media, .bd{ overflow: visible;}

View file

@ -65,28 +65,24 @@ module Diaspora
config.assets.initialize_on_precompile = false
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w{
aspect-contacts.js
config.assets.precompile += %w(
contact-list.js
ie.js
inbox.js
jquery2.js
jquery_ujs.js
jquery-textchange.js
main.js
jsxc.js
mobile/bookmarklet.js
mobile/mobile.js
people.js
publisher.js
templates.js
validation.js
error_pages.css
admin.css
rtl.css
color_themes/*/desktop.css
color_themes/*/mobile.css
}
)
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

View file

@ -901,10 +901,6 @@ en:
type_error: "Photo upload failed. Are you sure an image was added?"
destroy:
notice: "Photo deleted."
new_photo:
invalid_ext: "{file} has invalid extension. Only {extensions} are allowed."
size_error: "{file} is too large, maximum file size is {sizeLimit}."
empty: "{file} is empty, please select files again without it."
new_profile_photo:
upload: "Upload a new profile photo!"

View file

@ -1,12 +1,11 @@
class Publisher
attr_accessor :user, :open, :prefill, :public, :explain
attr_accessor :user, :open, :prefill, :public
def initialize(user, opts={})
self.user = user
self.open = opts[:open]
self.prefill = opts[:prefill]
self.public = opts[:public]
self.explain = opts[:explain]
end
def text

View file

@ -23,9 +23,10 @@ class Stream::Multi < Stream::Base
end
private
def publisher_opts
if welcome?
{open: true, prefill: publisher_prefill, public: true, explain: true}
{open: true, prefill: publisher_prefill, public: true}
else
super
end

View file

@ -23,7 +23,7 @@ describe Publisher do
end
end
["open", "public", "explain"].each do |property|
%w(open public).each do |property|
describe "##{property}" do
it 'defaults to closed' do
expect(@publisher.send("#{property}".to_sym)).to be_falsey

View file

@ -26,7 +26,7 @@ describe Stream::Multi do
prefill_text = "sup?"
allow(@stream).to receive(:welcome?).and_return(true)
allow(@stream).to receive(:publisher_prefill).and_return(prefill_text)
expect(@stream.send(:publisher_opts)).to eq(open: true, prefill: prefill_text, public: true, explain: true)
expect(@stream.send(:publisher_opts)).to eq(open: true, prefill: prefill_text, public: true)
end
it 'provides no opts if welcome? is not set' do