mirror of
https://github.com/discourse/discourse.git
synced 2026-09-05 04:40:41 -05:00
Convert some application helpers to ES6 format.
This commit is contained in:
@@ -68,9 +68,9 @@
|
|||||||
<td>{{#link-to 'adminUser' this}}{{avatar this imageSize="small"}}{{/link-to}}</td>
|
<td>{{#link-to 'adminUser' this}}{{avatar this imageSize="small"}}{{/link-to}}</td>
|
||||||
<td>{{#link-to 'adminUser' this}}{{unbound username}}{{/link-to}}</td>
|
<td>{{#link-to 'adminUser' this}}{{unbound username}}{{/link-to}}</td>
|
||||||
{{#if active}}
|
{{#if active}}
|
||||||
<td>{{shorten email}}</td>
|
<td>{{shorten-text email}}</td>
|
||||||
{{else}}
|
{{else}}
|
||||||
<td title="{{i18n admin.users.not_verified}}">{{shorten email}}</td>
|
<td title="{{i18n admin.users.not_verified}}">{{shorten-text email}}</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<td>{{{unbound last_emailed_age}}}</td>
|
<td>{{{unbound last_emailed_age}}}</td>
|
||||||
<td>{{{unbound last_seen_age}}}</td>
|
<td>{{{unbound last_seen_age}}}</td>
|
||||||
|
|||||||
@@ -1,28 +1,5 @@
|
|||||||
var safe = Handlebars.SafeString;
|
var safe = Handlebars.SafeString;
|
||||||
|
|
||||||
/**
|
|
||||||
Truncates long strings
|
|
||||||
|
|
||||||
@method shorten
|
|
||||||
@for Handlebars
|
|
||||||
**/
|
|
||||||
Handlebars.registerHelper('shorten', function(property, options) {
|
|
||||||
return Ember.Handlebars.get(this, property, options).substring(0,35);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
Produces a link to a topic
|
|
||||||
|
|
||||||
@method topic-link
|
|
||||||
@for Handlebars
|
|
||||||
**/
|
|
||||||
Handlebars.registerHelper('topic-link', function(property, options) {
|
|
||||||
var topic = Ember.Handlebars.get(this, property, options),
|
|
||||||
title = topic.get('fancy_title');
|
|
||||||
return "<a href='" + topic.get('lastUnreadUrl') + "' class='title'>" + title + "</a>";
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Produces a link to a category given a category object and helper options
|
Produces a link to a category given a category object and helper options
|
||||||
|
|
||||||
@@ -91,25 +68,6 @@ Handlebars.registerHelper('titled-link-to', function(name, object) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
Shorten a URL for display by removing common components
|
|
||||||
|
|
||||||
@method shortenUrl
|
|
||||||
@for Handlebars
|
|
||||||
**/
|
|
||||||
Handlebars.registerHelper('shorten-url', function(property, options) {
|
|
||||||
var url, matches;
|
|
||||||
url = Ember.Handlebars.get(this, property, options);
|
|
||||||
// Remove trailing slash if it's a top level URL
|
|
||||||
matches = url.match(/\//g);
|
|
||||||
if (matches && matches.length === 3) {
|
|
||||||
url = url.replace(/\/$/, '');
|
|
||||||
}
|
|
||||||
url = url.replace(/^https?:\/\//, '');
|
|
||||||
url = url.replace(/^www\./, '');
|
|
||||||
return url.substring(0,80);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Bound avatar helper.
|
Bound avatar helper.
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export default Handlebars.registerHelper('shorten-text', function(property, options) {
|
||||||
|
return Ember.Handlebars.get(this, property, options).substring(0,35);
|
||||||
|
});
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
export default Handlebars.registerHelper('shorten-url', function(property, options) {
|
||||||
|
var url = Ember.Handlebars.get(this, property, options),
|
||||||
|
matches = url.match(/\//g);
|
||||||
|
|
||||||
|
if (matches && matches.length === 3) {
|
||||||
|
url = url.replace(/\/$/, '');
|
||||||
|
}
|
||||||
|
url = url.replace(/^https?:\/\//, '');
|
||||||
|
url = url.replace(/^www\./, '');
|
||||||
|
return url.substring(0, 80);
|
||||||
|
});
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
export default Handlebars.registerHelper('topic-link', function(property, options) {
|
||||||
|
var topic = Ember.Handlebars.get(this, property, options),
|
||||||
|
title = topic.get('fancy_title');
|
||||||
|
|
||||||
|
return new Handlebars.SafeString("<a href='" + topic.get('lastUnreadUrl') + "' class='title'>" + title + "</a>");
|
||||||
|
});
|
||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
<ul class='topics'>
|
<ul class='topics'>
|
||||||
{{#each similarTopics}}
|
{{#each similarTopics}}
|
||||||
<li>{{{topic-link this}}} <span class='posts-count'>({{{i18n topic.filters.n_posts count="posts_count"}}})</span></li>
|
<li>{{topic-link this}} <span class='posts-count'>({{{i18n topic.filters.n_posts count="posts_count"}}})</span></li>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
<td class='main-link clearfix' {{bind-attr colspan="titleColSpan"}}>
|
<td class='main-link clearfix' {{bind-attr colspan="titleColSpan"}}>
|
||||||
{{topic-status topic=this.model}}
|
{{topic-status topic=this.model}}
|
||||||
{{{topic-link this}}}
|
{{topic-link this}}
|
||||||
{{topic-post-badges unread=unread newPosts=displayNewPosts unseen=unseen url=lastUnreadUrl}}
|
{{topic-post-badges unread=unread newPosts=displayNewPosts unseen=unseen url=lastUnreadUrl}}
|
||||||
|
|
||||||
{{#if hasExcerpt}}
|
{{#if hasExcerpt}}
|
||||||
|
|||||||
+1
-2
@@ -6,8 +6,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<div class='main-link clearfix'>
|
<div class='main-link clearfix'>
|
||||||
{{topic-status topic=this}}
|
{{topic-status topic=this}}
|
||||||
{{{topic-link this}}}
|
{{topic-link this}}
|
||||||
|
|
||||||
{{topic-post-badges unread=unread
|
{{topic-post-badges unread=unread
|
||||||
newPosts=topic.new_posts
|
newPosts=topic.new_posts
|
||||||
unseen=topic.unseen
|
unseen=topic.unseen
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
<td class='main-link'>
|
<td class='main-link'>
|
||||||
<div class='topic-inset'>
|
<div class='topic-inset'>
|
||||||
{{topic-status topic=this}}
|
{{topic-status topic=this}}
|
||||||
{{{topic-link this}}}
|
{{topic-link this}}
|
||||||
|
|
||||||
{{topic-post-badges unread=unread newPosts=new_posts unseen=unseen url=lastUnreadUrl}}
|
{{topic-post-badges unread=unread newPosts=new_posts unseen=unseen url=lastUnreadUrl}}
|
||||||
{{#if hasExcerpt}}
|
{{#if hasExcerpt}}
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<div class='main-link clearfix'>
|
<div class='main-link clearfix'>
|
||||||
{{topic-status topic=this}}
|
{{topic-status topic=this}}
|
||||||
{{{topic-link this}}}
|
{{topic-link this}}
|
||||||
{{topic-post-badges unread=unread
|
{{topic-post-badges unread=unread
|
||||||
newPosts=displayNewPosts
|
newPosts=displayNewPosts
|
||||||
unseen=unseen
|
unseen=unseen
|
||||||
|
|||||||
Reference in New Issue
Block a user