FEATURE: Rename discourse-cronos to discourse-local-dates

This commit is contained in:
Sam 2018-05-04 16:11:33 +10:00
parent ee426623e4
commit c81854ad14
99 changed files with 104 additions and 574 deletions

View File

@ -39,7 +39,7 @@ class Plugin::Metadata
"discourse-voting",
"docker_manager",
"discourse-signatures",
"discourse-cronos",
"discourse-local-dates",
"discourse-crowd",
"discourse-footnote",
"discourse-gradle-issue",

View File

@ -1,75 +0,0 @@
(function($) {
$.fn.cronos = function(repeat) {
function _formatTimezone(timezone) {
return timezone.replace("_", " ").split("/");
}
function processElement($element, options) {
repeat = repeat || true;
if (this.timeout) {
clearTimeout(this.timeout);
}
var relativeTime = moment.utc(options.date + " " + options.time, "YYYY-MM-DD HH:mm");
if (options.recurring && relativeTime < moment().utc()) {
var parts = options.recurring.split(".");
var count = parseInt(parts[0], 10);
var type = parts[1];
var diff = moment().diff(relativeTime, type);
var add = Math.ceil(diff + count);
relativeTime = relativeTime.add(add, type);
}
var previews = options.timezones.split("|").map(function(timezone) {
var dateTime = relativeTime.tz(timezone).format(options.format);
var timezoneParts = _formatTimezone(timezone);
if (dateTime.match(/TZ/)) {
return dateTime.replace("TZ", timezoneParts.join(": "));
} else {
var output = timezoneParts[0];
if (timezoneParts[1]) {
output += " (" + timezoneParts[1] + ")";
}
output += " " + dateTime;
return output;
}
});
relativeTime = relativeTime.tz(moment.tz.guess()).format(options.format);
var html = "<span>";
html += "<i class='fa fa-globe d-icon d-icon-globe'></i>";
html += relativeTime.replace("TZ", _formatTimezone(moment.tz.guess()).join(": "));
html += "</span>";
$element
.html(html)
.attr("title", previews.join("\n"))
.attr("onclick", "alert('" + previews.join("\\n") + "');return false;")
.addClass("cooked");
if (repeat) {
this.timeout = setTimeout(function() {
processElement($element, options);
}, 10000);
}
}
return this.each(function() {
var $this = $(this);
var options = {};
options.format = $this.attr("data-format");
options.date = $this.attr("data-date");
options.time = $this.attr("data-time");
options.recurring = $this.attr("data-recurring");
options.timezones = $this.attr("data-timezones") || "Etc/UTC";
processElement($this, options);
});
};
})(jQuery);

View File

@ -1,116 +0,0 @@
import computed from "ember-addons/ember-computed-decorators";
import { observes } from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({
timeFormat: "HH:mm",
dateFormat: "YYYY-MM-DD",
dateTimeFormat: "YYYY-MM-DD HH:mm",
config: null,
date: null,
time: null,
format: null,
formats: null,
recurring: null,
advancedMode: false,
init() {
this._super();
this.set("date", moment().format(this.dateFormat));
this.set("time", moment().format(this.timeFormat));
this.set("format", `LLL`);
this.set("timezones", (this.siteSettings.discourse_cronos_default_timezones || "").split("|").filter(f => f));
this.set("formats", (this.siteSettings.discourse_cronos_default_formats || "").split("|"));
},
didInsertElement() {
this._super();
this._setConfig();
},
@computed
currentUserTimezone() {
return moment.tz.guess();
},
@computed
recurringOptions() {
return [
{ name: "Every day", id: "1.days" },
{ name: "Every week", id: "1.weeks" },
{ name: "Every two weeks", id: "2.weeks" },
{ name: "Every month", id: "1.months" },
{ name: "Every two months", id: "2.months" },
{ name: "Every three months", id: "3.months" },
{ name: "Every six months", id: "6.months" },
{ name: "Every year", id: "1.years" },
];
},
@computed()
allTimezones() {
return _.map(moment.tz.names(), (z) => z);
},
@observes("date", "time", "recurring", "format", "timezones")
_setConfig() {
const date = this.get("date");
const time = this.get("time");
const recurring = this.get("recurring");
const format = this.get("format");
const timezones = this.get("timezones");
const dateTime = moment(`${date} ${time}`, this.dateTimeFormat).utc();
this.set("config", {
date: dateTime.format(this.dateFormat),
time: dateTime.format(this.timeFormat),
dateTime,
recurring,
format,
timezones,
});
},
getTextConfig(config) {
let text = `[date=${config.date} `;
if (config.recurring) text += `recurring=${config.recurring} `;
text += `time=${config.time} `;
text += `format=${config.format} `;
text += `timezones="${config.timezones.join("|")}"`;
text += `]`;
return text;
},
@computed("config.dateTime")
validDate(dateTime) {
if (!dateTime) return false;
return dateTime.isValid();
},
actions: {
advancedMode() {
this.toggleProperty("advancedMode");
},
save() {
this._closeModal();
const textConfig = this.getTextConfig(this.get("config"));
this.get("toolbarEvent").addText(textConfig);
},
fillFormat(format) {
this.set("format", format);
},
cancel() {
this._closeModal();
}
},
_closeModal() {
const composer = Discourse.__container__.lookup("controller:composer");
composer.send("closeModal");
}
});

View File

@ -1,77 +0,0 @@
{{#d-modal-body
title="discourse_cronos.create.modal_title"
class="discourse-cronos-create-modal"
style="overflow: auto"}}
<div class="form">
<div class="control-group">
<div class="controls date-time">
{{date-picker-future class="date" value=date defaultDate="DD-MM-YYYY"}}
{{input type="time" value=time class="time"}}
<span>{{currentUserTimezone}}</span>
</div>
</div>
<h3>{{i18n "discourse_cronos.create.form.recurring_title"}}</h3>
<div class="control-group">
{{#if advancedMode}}
<label>{{{i18n "discourse_cronos.create.form.recurring_description"}}}</label>
{{/if}}
<div class="controls">
{{combo-box content=recurringOptions value=recurring none="discourse_cronos.create.form.recurring_none"}}
</div>
</div>
{{d-button
class="advanced-mode-btn"
action=(action "advancedMode")
icon="cog"
label="discourse_cronos.create.form.advanced_mode"}}
{{#if advancedMode}}
<div class="advanced-options">
<div class="control-group">
<label>
{{i18n "discourse_cronos.create.form.format_description"}}
(<a target="_blank" rel="noopener" href="https://momentjs.com/docs/#/parsing/string-format/">?</a>)
</label>
<div class="controls">
{{text-field value=format}}
</div>
</div>
<div class="control-group">
<ul class="formats">
{{#each formats as |format|}}
<li class="format">
<a href {{action "fillFormat" format}}>{{format}}</a>
</li>
{{/each}}
</ul>
</div>
<h3>{{i18n "discourse_cronos.create.form.timezones_title"}}</h3>
<div class="control-group">
<label>{{i18n "discourse_cronos.create.form.timezones_description"}}</label>
<div class="controls">
{{multi-select allowAny=false maximum=5 content=allTimezones values=timezones}}
</div>
</div>
</div>
{{/if}}
</div>
{{/d-modal-body}}
<div class="modal-footer discourse-cronos-create-modal-footer">
{{#if validDate}}
{{d-button class="btn"
action="save"
label="discourse_cronos.create.form.insert"}}
{{else}}
<span class="validation-error">{{i18n "discourse_cronos.create.form.invalid_date"}}</span>
{{/if}}
<a href {{action "cancel"}}>
{{i18n 'cancel'}}
</a>
</div>

View File

@ -1 +0,0 @@
{{discourse-cronos-create-form config=config toolbarEvent=toolbarEvent}}

View File

@ -1,37 +0,0 @@
import { withPluginApi } from "discourse/lib/plugin-api";
import showModal from "discourse/lib/show-modal";
function initializeDiscourseCronos(api) {
api.decorateCooked($elem => {
$(".discourse-cronos", $elem).cronos();
});
api.addToolbarPopupMenuOptionsCallback(() => {
return {
action: "insertDiscourseCronos",
icon: "globe",
label: "discourse_cronos.title"
};
});
api.modifyClass('controller:composer', {
actions: {
insertDiscourseCronos() {
showModal("discourse-cronos-create-modal").setProperties({
toolbarEvent: this.get("toolbarEvent")
});
}
}
});
}
export default {
name: "discourse-cronos",
initialize(container) {
const siteSettings = container.lookup("site-settings:main");
if (siteSettings.discourse_cronos_enabled) {
withPluginApi("0.8.8", initializeDiscourseCronos);
}
}
};

View File

@ -1,73 +0,0 @@
import { parseBBCodeTag } from 'pretty-text/engines/discourse-markdown/bbcode-block';
function addcronos(buffer, matches, state) {
let token;
let config = {
date: null,
time: null,
format: "YYYY-MM-DD HH:mm",
timezones: ""
};
let parsed = parseBBCodeTag("[date date" + matches[1] + "]", 0, matches[1].length + 11);
config.date = parsed.attrs.date;
config.time = parsed.attrs.time;
config.format = parsed.attrs.format || config.format;
config.timezones = parsed.attrs.timezones || config.timezones;
token = new state.Token('a_open', 'a', 1);
token.attrs = [
['class', 'discourse-cronos'],
['data-date', config.date],
['data-time', config.time],
['data-recurring', config.recurring],
['data-format', config.format],
['data-timezones', config.timezones],
];
buffer.push(token);
const previews = config.timezones.split("|").filter(t => t).map(timezone => {
const dateTime = moment
.utc(`${config.date} ${config.time}`, "YYYY-MM-DD HH:mm")
.tz(timezone)
.format(config.format);
const formattedTimezone = timezone.replace("/", ": ").replace("_", " ");
if (dateTime.match(/TZ/)) {
return dateTime.replace("TZ", formattedTimezone);
} else {
return `${dateTime} (${formattedTimezone})`;
}
});
token = new state.Token('text', '', 0);
token.content = previews.join(", ");
buffer.push(token);
token = new state.Token('a_close', 'a', -1);
buffer.push(token);
}
export function setup(helper) {
helper.whiteList([
'a.discourse-cronos',
'a[data-*]',
'a[title]'
]);
helper.registerOptions((opts, siteSettings) => {
opts.features['discourse-cronos'] = !!siteSettings.discourse_cronos_enabled;
});
helper.registerPlugin(md => {
const rule = {
matcher: /\[date(.*?)\]/,
onMatch: addcronos
};
md.core.textPostProcess.ruler.push('discourse-cronos', rule);
});
}

View File

@ -1,83 +0,0 @@
.discourse-cronos {
display: inline-block;
vertical-align: top;
&.cooked {
color: $primary;
font-weight: bold;
cursor: pointer;
.d-icon-globe {
margin-right: .25em;
color: $primary-medium;
&:hover {
color: $primary-high;
}
}
&:hover .d-icon-globe {
color: $primary-high;
}
}
+ .discourse-cronos {
margin-left: .5em;
}
}
.discourse-cronos-create-modal-footer {
display: flex;
align-items: center;
justify-content: space-between;
.validation-error {
color: $danger;
}
&:before, &:after {
content: none;
}
}
.discourse-cronos-create-modal {
min-height: 300px;
display: flex;
flex-direction: row;
.form {
flex: 1;
.controls {
&.date-time {
display: flex;
justify-content: flex-start;
align-items: center;
margin-bottom: 1em;
.date {
margin: 0 0.5em 0 0;
}
.date-picker {
padding-top: 5px;
bottom: 5px;
margin: 0;
}
.time {
margin: 0 0.5em 0 0;
max-width: 100px;
}
}
}
.advanced-mode-btn {
margin-top: 2em;
margin-bottom: 1em;
}
}
.select-kit.multi-select {
width: 90%;
}
}

View File

@ -1,12 +0,0 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
de:
site_settings:
discourse_cronos_enabled: "Aktiviert das discourse-cronos Plugin. Wenn du diese Einstellung änderst, musst du alle Beiträge mit \"rake posts:rebake\" neu generieren."
discourse_cronos_default_formats: "Häufig verwendete Datums- und Zeitformate, siehe: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_cronos_default_timezones: "Standard-Liste von Zeitzonen, muss eine gültige <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> sein"

View File

@ -1,5 +0,0 @@
en:
site_settings:
discourse_cronos_enabled: "Enable the discourse-cronos plugin. If you change this, you must rebake all posts with: \"rake posts:rebake\"."
discourse_cronos_default_formats: "Frequently used date time formats, see: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_cronos_default_timezones: "Default list of timezones, must be a valid <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a>"

View File

@ -1,12 +0,0 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
es:
site_settings:
discourse_cronos_enabled: "Activar el plugin discourse-cronos. Si cambias esto, debes hacer rebake de todos los posts con \"rake posts:rebake\"."
discourse_cronos_default_formats: "Formatos de fecha utilizados frecuentemente, ver: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_cronos_default_timezones: "Lista de zonas horarias por defecto, deben ser <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> válidas"

View File

@ -1,12 +0,0 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
fr:
site_settings:
discourse_cronos_enabled: "Activer le plugin discourse-cronos. Si vous modifiez ceci, vous devez regénérer tous les messages avec : \"rake posts:rebake\"."
discourse_cronos_default_formats: "Formats de date fréquemment utilisés, voir : <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_cronos_default_timezones: "Liste de fuseaux horaires par défaut, doit être un fuseaux horaire valide <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>Wikipedia (anglais)</a>"

View File

@ -1,12 +0,0 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
he:
site_settings:
discourse_cronos_enabled: "הפעלת התוסף discourse-cronos. שינוי ההגדרה הזאת יאלץ אותך לאפות את כל הרשומות מחדש עם: „rake posts:rebake”."
discourse_cronos_default_formats: "תבניות זמן נפוצות, ניתן לעיין ב: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>תבנית מחרוזת momentjs</a>"
discourse_cronos_default_timezones: "רשימת בררת מחדל של אזורי זמן, חיי להיות <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> תקני"

View File

@ -1,12 +0,0 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
ru:
site_settings:
discourse_cronos_enabled: "Включить плагин discourse-cronos. Если вы измените это, вы должны rebake все посты: \"rake posts:rebake\"."
discourse_cronos_default_formats: "Часто используемые форматы даты и времени, см.: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>формат строки momentjs</a>"
discourse_cronos_default_timezones: "Список часовых поясов по умолчанию должен быть допустимым <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a>"

View File

@ -1,12 +0,0 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
ur:
site_settings:
discourse_cronos_enabled: "ڈِسکورس-کرَونَوس پلگ اِن فعال کریں۔ اگر آپ اس کو تبدیل کرتے ہیں تو، آپ کو تمام پوسٹس کو دوبارہ رِیبَیک کرنا ہوگا: \"rake posts:rebake\""
discourse_cronos_default_formats: "اکثر استعمال ہونے والے تاریخ ٹائم فارمیٹس، دیکھیے: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs سٹرِنگ فارمَیٹ</a>"
discourse_cronos_default_timezones: "ٹائم زَونَوں کی ڈِیفالٹ فہرست، ایک درست <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> ہونا لازمی ہے"

View File

@ -1,8 +0,0 @@
module ::DiscourseCronos
PLUGIN_NAME = "discourse-cronos"
class Engine < ::Rails::Engine
engine_name DiscourseCronos::PLUGIN_NAME
isolate_namespace DiscourseCronos
end
end

View File

@ -1,13 +0,0 @@
# name: discourse-cronos
# about: Display a date in your local timezone
# version: 0.1
# author: Joffrey Jaffeux
register_asset "javascripts/discourse-cronos.js"
register_asset "stylesheets/discourse-cronos.scss"
register_asset "moment.js", :vendored_core_pretty_text
register_asset "moment-timezone.js", :vendored_core_pretty_text
enabled_site_setting :discourse_cronos_enabled
load File.expand_path('../lib/discourse_cronos/engine.rb', __FILE__)

View File

@ -7,7 +7,7 @@
de:
js:
discourse_cronos:
discourse_local_dates:
title: Datum einfügen
create:
modal_title: Datum einfügen

View File

@ -1,6 +1,6 @@
en:
js:
discourse_cronos:
discourse_local_dates:
title: Insert date
create:
modal_title: Insert date

View File

@ -7,7 +7,7 @@
es:
js:
discourse_cronos:
discourse_local_dates:
title: Insertar fecha
create:
modal_title: Insertar fecha

View File

@ -7,7 +7,7 @@
fa_IR:
js:
discourse_cronos:
discourse_local_dates:
create:
form:
timezones_title: نمایش منطقه زمانی

View File

@ -7,7 +7,7 @@
fr:
js:
discourse_cronos:
discourse_local_dates:
title: Insérer date
create:
modal_title: Insérer date

View File

@ -7,7 +7,7 @@
he:
js:
discourse_cronos:
discourse_local_dates:
create:
form:
format_description: "תבנית להצגת תאריך המשתמש. יש להשתמש ב־„‎\\T\\Z” כדי להציג את אזור הזמן של המשתמש במילים (אסיה/ירושלים)"

View File

@ -7,7 +7,7 @@
ru:
js:
discourse_cronos:
discourse_local_dates:
title: Вставить дату
create:
modal_title: Вставить дату

View File

@ -7,7 +7,7 @@
ur:
js:
discourse_cronos:
discourse_local_dates:
create:
form:
format_description: "صارف کو تاریخ ظاہر کرنے کیلئے استعمال کیے جانے والا فارمیٹ۔ الفاظ (یورپ/پیرس) میں صارف ٹائم زَون کو ظاہر کرنے کیلئے \"\\T\\Z\" استعمال کریں"

View File

@ -7,7 +7,7 @@
zh_CN:
js:
discourse_cronos:
discourse_local_dates:
title: 插入日期
create:
modal_title: 插入日期

View File

@ -0,0 +1,12 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
de:
site_settings:
discourse_local_dates_enabled: "Aktiviert das discourse-cronos Plugin. Wenn du diese Einstellung änderst, musst du alle Beiträge mit \"rake posts:rebake\" neu generieren."
discourse_local_dates_default_formats: "Häufig verwendete Datums- und Zeitformate, siehe: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_local_dates_default_timezones: "Standard-Liste von Zeitzonen, muss eine gültige <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> sein"

View File

@ -0,0 +1,5 @@
en:
site_settings:
discourse_local_dates_enabled: "Enable the discourse-local-dates plugin. This will add support to local timezone aware dates in posts using the [date] element."
discourse_local_dates_default_formats: "Frequently used date time formats, see: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_local_dates_default_timezones: "Default list of timezones, must be a valid <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a>"

View File

@ -0,0 +1,12 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
es:
site_settings:
discourse_local_dates_enabled: "Activar el plugin discourse-cronos. Si cambias esto, debes hacer rebake de todos los posts con \"rake posts:rebake\"."
discourse_local_dates_default_formats: "Formatos de fecha utilizados frecuentemente, ver: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_local_dates_default_timezones: "Lista de zonas horarias por defecto, deben ser <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> válidas"

View File

@ -0,0 +1,12 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
fr:
site_settings:
discourse_local_dates_enabled: "Activer le plugin discourse-cronos. Si vous modifiez ceci, vous devez regénérer tous les messages avec : \"rake posts:rebake\"."
discourse_local_dates_default_formats: "Formats de date fréquemment utilisés, voir : <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs string format</a>"
discourse_local_dates_default_timezones: "Liste de fuseaux horaires par défaut, doit être un fuseaux horaire valide <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>Wikipedia (anglais)</a>"

View File

@ -0,0 +1,12 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
he:
site_settings:
discourse_local_dates_enabled: "הפעלת התוסף discourse-cronos. שינוי ההגדרה הזאת יאלץ אותך לאפות את כל הרשומות מחדש עם: „rake posts:rebake”."
discourse_local_dates_default_formats: "תבניות זמן נפוצות, ניתן לעיין ב: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>תבנית מחרוזת momentjs</a>"
discourse_local_dates_default_timezones: "רשימת בררת מחדל של אזורי זמן, חיי להיות <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> תקני"

View File

@ -0,0 +1,12 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
ru:
site_settings:
discourse_local_dates_enabled: "Включить плагин discourse-cronos. Если вы измените это, вы должны rebake все посты: \"rake posts:rebake\"."
discourse_local_dates_default_formats: "Часто используемые форматы даты и времени, см.: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>формат строки momentjs</a>"
discourse_local_dates_default_timezones: "Список часовых поясов по умолчанию должен быть допустимым <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a>"

View File

@ -0,0 +1,12 @@
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
#
# To work with us on translations, join this project:
# https://www.transifex.com/projects/p/discourse-org/
ur:
site_settings:
discourse_local_dates_enabled: "ڈِسکورس-کرَونَوس پلگ اِن فعال کریں۔ اگر آپ اس کو تبدیل کرتے ہیں تو، آپ کو تمام پوسٹس کو دوبارہ رِیبَیک کرنا ہوگا: \"rake posts:rebake\""
discourse_local_dates_default_formats: "اکثر استعمال ہونے والے تاریخ ٹائم فارمیٹس، دیکھیے: <a target='_blank' rel='noopener' href='https://momentjs.com/docs/#/parsing/string-format/'>momentjs سٹرِنگ فارمَیٹ</a>"
discourse_local_dates_default_timezones: "ٹائم زَونَوں کی ڈِیفالٹ فہرست، ایک درست <a target='_blank' rel='noopener' href='https://en.wikipedia.org/wiki/List_of_tz_database_time_zones'>TZ</a> ہونا لازمی ہے"

View File

@ -1,12 +1,12 @@
plugins:
discourse_cronos_enabled:
discourse_local_dates_enabled:
default: true
client: true
discourse_cronos_default_formats:
discourse_local_dates_default_formats:
default: "LLL|LTS|LL|LLLL"
client: true
type: list
discourse_cronos_default_timezones:
discourse_local_dates_default_timezones:
default: "Europe/Paris|America/Los_Angeles"
client: true
type: list

View File

@ -0,0 +1,13 @@
# name: discourse-local-dates
# about: Display a date in your local timezone
# version: 0.1
# author: Joffrey Jaffeux
register_asset "javascripts/discourse-local-dates.js"
register_asset "stylesheets/discourse-local-dates.scss"
register_asset "moment.js", :vendored_core_pretty_text
register_asset "moment-timezone.js", :vendored_core_pretty_text
enabled_site_setting :discourse_local_dates_enabled
load File.expand_path('../lib/discourse_local_dates/engine.rb', __FILE__)

View File

@ -7,7 +7,7 @@ describe PrettyText do
[date=2018-05-08 time=22:00 format=LLL timezones="Europe/Paris|America/Los_Angeles"]
MD
expect(cooked).to include('class="discourse-cronos"')
expect(cooked).to include('class="discourse-local-date"')
expect(cooked).to include('data-date="2018-05-08"')
expect(cooked).to include('data-format="LLL"')
expect(cooked).to include('data-timezones="Europe/Paris|America/Los_Angeles"')