Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Vibol Hou
2016-09-29 02:12:05 -07:00
56 changed files with 1584 additions and 377 deletions

View File

@@ -1,6 +1,6 @@
import computed from 'ember-addons/ember-computed-decorators';
import StringBuffer from 'discourse/mixins/string-buffer';
import { iconHTML } from 'discourse/helpers/fa-icon';
import { iconHTML } from 'discourse-common/helpers/fa-icon';
export default Ember.Component.extend(StringBuffer, {
classes: ["text-muted", "text-danger", "text-successful"],

View File

@@ -2,7 +2,7 @@
var Discourse = require('discourse').default;
function deprecate(module, methods) {
const result = {};
var result = {};
methods.forEach(function(m) {
result[m] = function() {

View File

@@ -1,4 +1,5 @@
import StringBuffer from 'discourse/mixins/string-buffer';
import computed from 'ember-addons/ember-computed-decorators';
export function showEntrance(e) {
let target = $(e.target);
@@ -29,9 +30,9 @@ export default Ember.Component.extend(StringBuffer, {
}
},
unboundClassNames: function() {
@computed('topic', 'lastVisitedTopic')
unboundClassNames(topic, lastVisitedTopic) {
let classes = [];
const topic = this.get('topic');
if (topic.get('category')) {
classes.push("category-" + topic.get('category.fullSlug'));
@@ -47,12 +48,12 @@ export default Ember.Component.extend(StringBuffer, {
}
});
if (topic === this.get('lastVisitedTopic')) {
if (topic === lastVisitedTopic) {
classes.push('last-visit');
}
return classes.join(' ');
}.property(),
},
titleColSpan: function() {
return (!this.get('hideCategory') &&

View File

@@ -1,4 +1,4 @@
import {default as computed, observes} from 'ember-addons/ember-computed-decorators';
import { default as computed, observes, on } from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({
tagName: 'table',
@@ -31,12 +31,6 @@ export default Ember.Component.extend({
return this.get('order') === "op_likes";
}.property('order'),
@observes('category')
categoryChanged: function(){
this.set('prevTopic', null);
},
@computed('topics.@each', 'order', 'ascending')
lastVisitedTopic(topics, order, ascending) {
if (!this.get('highlightLastVisited')) { return; }
@@ -84,14 +78,26 @@ export default Ember.Component.extend({
return;
}
prevTopic.set('isLastVisited', true);
this.set('prevTopic', prevTopic);
return prevTopic;
},
@observes('category')
@on('willDestroyElement')
_cleanLastVisitedTopic() {
const prevTopic = this.get('prevTopic');
if (prevTopic) {
prevTopic.set('isLastVisited', false);
this.set('prevTopic', null);
}
},
click(e) {
var self = this;
var on = function(sel, callback){
var onClick = function(sel, callback){
var target = $(e.target).closest(sel);
if(target.length === 1){
@@ -99,12 +105,12 @@ export default Ember.Component.extend({
}
};
on('button.bulk-select', function(){
onClick('button.bulk-select', function(){
this.sendAction('toggleBulkSelect');
this.rerender();
});
on('th.sortable', function(e2){
onClick('th.sortable', function(e2){
this.sendAction('changeSort', e2.data('sort-order'));
this.rerender();
});

View File

@@ -171,7 +171,25 @@ const groups = [
"vulcan",
"wind_blowing_face",
"writing_hand",
"zipper_mouth"
"zipper_mouth",
"female_couple_with_heart",
"male_couple_with_heart",
"female_couplekiss",
"male_couplekiss",
"family_man_woman_girl",
"family_man_woman_girl_boy",
"family_man_woman_boys",
"family_man_woman_girls",
"family_women_boy",
"family_women_girl",
"family_women_girl_boy",
"family_women_boys",
"family_women_girls",
"family_men_boy",
"family_men_girl",
"family_men_girl_boy",
"family_men_boys",
"family_men_girls"
]
},
{
@@ -913,6 +931,7 @@ const groups = [
"eight",
"nine",
"keycap_ten",
"keycap_star",
"1234",
"hash",
"abc",
@@ -1102,6 +1121,7 @@ const groups = [
"wastebasket",
"wheel_of_dharma",
"yin_yang",
"left_speech_bubble"
]
}
];

View File

@@ -5,6 +5,13 @@ import { defaultHomepage } from 'discourse/lib/utilities';
const rewrites = [];
const TOPIC_REGEXP = /\/t\/([^\/]+)\/(\d+)\/?(\d+)?/;
// We can add links here that have server side responses but not client side.
const SERVER_SIDE_ONLY = [
/^\/posts\/\d+\/raw/,
/\.rss$/,
/\.json/,
];
let _jumpScheduled = false;
export function jumpToElement(elementId) {
if (_jumpScheduled || Ember.isEmpty(elementId)) { return; }
@@ -79,7 +86,7 @@ const DiscourseURL = Ember.Object.extend({
// Always use replaceState in the next runloop to prevent weird routes changing
// while URLs are loading. For example, while a topic loads it sets `currentPost`
// which triggers a replaceState even though the topic hasn't fully loaded yet!
Em.run.next(function() {
Ember.run.next(() => {
const location = DiscourseURL.get('router.location');
if (location && location.replaceURL) {
location.replaceURL(path);
@@ -114,6 +121,15 @@ const DiscourseURL = Ember.Object.extend({
return;
}
const serverSide = SERVER_SIDE_ONLY.some(r => {
if (path.match(r)) {
document.location = path;
return true;
}
});
if (serverSide) { return; }
// Protocol relative URLs
if (path.indexOf('//') === 0) {
document.location = path;
@@ -151,6 +167,7 @@ const DiscourseURL = Ember.Object.extend({
rewrites.forEach(rw => path = path.replace(rw.regexp, rw.replacement));
if (this.navigatedToPost(oldPath, path, opts)) { return; }
// Schedule a DOM cleanup event
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
@@ -256,7 +273,7 @@ const DiscourseURL = Ember.Object.extend({
@param {String} oldPath the previous path we were on
@param {String} path the path we're navigating to
**/
navigatedToHome: function(oldPath, path) {
navigatedToHome(oldPath, path) {
const homepage = defaultHomepage();
if (window.history &&
@@ -271,7 +288,7 @@ const DiscourseURL = Ember.Object.extend({
},
// This has been extracted so it can be tested.
origin: function() {
origin() {
return window.location.origin + (Discourse.BaseUri === "/" ? '' : Discourse.BaseUri);
},

View File

@@ -17,9 +17,11 @@
<tr>
{{category-link topic.category}}
{{#if topic.tags}}
{{#each topic.visibleListTags as |tag|}}
{{discourse-tag tag}}
{{/each}}
<div class="discourse-tags">
{{#each topic.visibleListTags as |tag|}}
{{discourse-tag tag}}
{{/each}}
</div>
{{/if}}
</tr>
</td>

View File

@@ -28,5 +28,15 @@
expandAllPinned=expandAllPinned
lastVisitedTopic=lastVisitedTopic
selected=selected}}
{{#if topic.isLastVisited}}
<tr class='topic-list-item-separator'>
<td colspan="6">
<span>
{{i18n 'topics.new_messages_marker'}}
</span>
</td>
</tr>
{{/if}}
{{/each}}
</tbody>

View File

@@ -14,9 +14,12 @@
{{#if hasTopics}}
{{topic-list
highlightLastVisited=true
showPosters=true
currentUser=currentUser
hideCategory=model.hideCategory
order=order
ascending=ascending
topics=model.topics
expandGloballyPinned=expandGloballyPinned
expandAllPinned=expandAllPinned

View File

@@ -23,8 +23,6 @@ html.anon .topic-list a.title:visited:not(.badge-notification) {color: dark-ligh
width: 100%;
border-collapse: collapse;
> tbody > tr {
&.has-excerpt .star {
vertical-align: top;
@@ -33,16 +31,29 @@ html.anon .topic-list a.title:visited:not(.badge-notification) {color: dark-ligh
border-bottom: 1px solid dark-light-diff($primary, $secondary, 90%, -75%);
&.last-visit {
border-bottom: none;
}
.topic-list-separator {
text-align: center;
}
}
.topic-list-item-separator {
border: none;
td {
border-bottom: 1px solid scale-color($danger, $lightness: 60%);
+ tr::after {
content: attr(data-last-visit-text);
color: scale-color($danger, $lightness: 50%);
position: absolute;
left: 50%;
margin-top: -10px;
padding: 0 10px;
background: $secondary;
}
line-height: 0.1em;
padding: 0px;
text-align: center;
}
td span {
background-color: $secondary;
color: scale-color($danger, $lightness: 60%);
padding: 0px 8px;
font-size: 0.929em;
}
}
@@ -73,6 +84,7 @@ html.anon .topic-list a.title:visited:not(.badge-notification) {color: dark-ligh
font-size: 1.143em;
a.title {
padding: 15px 0;
word-break: break-word;
}
}

View File

@@ -110,6 +110,10 @@ $tag-color: scale-color($primary, $lightness: 40%);
}
}
.categories-list .topic-list-latest .discourse-tags {
display: inline-block;
}
.mobile-view .topic-list-item .discourse-tags {
display: inline-block;
font-size: 0.9em;

View File

@@ -4,27 +4,30 @@ class ExtraLocalesController < ApplicationController
skip_before_filter :check_xhr, :preload_json
def show
locale_str = I18n.locale.to_s
translations = JsLocaleHelper.translations_for(locale_str)
bundle = params[:bundle]
raise Discourse::InvalidAccess.new unless bundle =~ /^[a-z]+$/
for_key = translations[locale_str]["#{bundle}_js"]
locale_str = I18n.locale.to_s
translations = JsLocaleHelper.translations_for(locale_str)
for_key = translations[locale_str]["#{bundle}_js"]
if for_key.present?
js = <<-JS
if plugin_for_key = JsLocaleHelper.plugin_translations(locale_str)["#{bundle}_js"]
for_key.deep_merge!(plugin_for_key)
end
js =
if for_key.present?
<<~JS
(function() {
if (window.I18n) {
window.I18n.extras = window.I18n.extras || [];
window.I18n.extras.push(#{for_key.to_json});
}
})();
JS
else
js = ""
end
JS
else
""
end
render text: js, content_type: "application/javascript"
end

View File

@@ -5,7 +5,7 @@ require_dependency 'distributed_cache'
class SiteCustomization < ActiveRecord::Base
ENABLED_KEY = '7e202ef2-56d7-47d5-98d8-a9c8d15e57dd'
COMPILER_VERSION = 1
COMPILER_VERSION = 2
@cache = DistributedCache.new('site_customization')

View File

@@ -23,7 +23,7 @@
</span>
<span itemprop='name'>
<%= user.username %>
<% if user.name.present? %>
<% if user.name.present? && SiteSetting.enable_names %>
- <%= user.name %>
<% end %>
</span>
@@ -44,7 +44,7 @@
</span>
<span itemprop='name'>
<%= user.username %>
<% if user.name.present? %>
<% if user.name.present? && SiteSetting.enable_names %>
- <%= user.name %>
<% end %>
</span>