mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 00:50:28 +00:00
Add support for relative dates
Including: setting date on save tiddler and adding a date to HelloThere
This commit is contained in:
parent
5ad86388dc
commit
ecd933dd25
@ -127,7 +127,12 @@ exports.eventMap["tw-SaveTiddler"] = function(event) {
|
||||
var tiddler = this.wiki.getTiddler(event.tiddlerTitle);
|
||||
if(tiddler && $tw.utils.hop(tiddler.fields,"draft.title")) {
|
||||
// Save the draft tiddler as the real tiddler
|
||||
this.wiki.addTiddler(new $tw.Tiddler(tiddler,{title: tiddler.fields["draft.title"],"draft.title": undefined, "draft.of": undefined}));
|
||||
this.wiki.addTiddler(new $tw.Tiddler(tiddler,{
|
||||
title: tiddler.fields["draft.title"],
|
||||
modified: new Date(),
|
||||
"draft.title": undefined,
|
||||
"draft.of": undefined
|
||||
}));
|
||||
// Remove the draft tiddler
|
||||
this.wiki.deleteTiddler(event.tiddlerTitle);
|
||||
// Remove the original tiddler if we're renaming it
|
||||
|
27
core/modules/macros/view/viewers/relativedate.js
Normal file
27
core/modules/macros/view/viewers/relativedate.js
Normal file
@ -0,0 +1,27 @@
|
||||
/*\
|
||||
title: $:/core/modules/macros/view/viewers/relativedate.js
|
||||
type: application/javascript
|
||||
module-type: fieldviewer
|
||||
|
||||
A viewer for viewing tiddler fields as a relative date
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
function renderValue(tiddler,field,value,viewMacro) {
|
||||
if(value === undefined) {
|
||||
return $tw.Tree.Text("");
|
||||
} else {
|
||||
return $tw.Tree.Text(
|
||||
$tw.utils.getRelativeDate((new Date()) - value).description
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
exports["relativedate"] = renderValue;
|
||||
|
||||
})();
|
@ -7,7 +7,7 @@ modifier: JeremyRuston
|
||||
<<button close class:"btn-invisible pull-right"><[img[$:/core/images/close-button.svg]]>>
|
||||
</div>
|
||||
<div class="small">
|
||||
<<view modifier link>> <<view modified date>>
|
||||
<<view modifier link>> <<view modified relativedate>>
|
||||
</div>
|
||||
{{tw-tags-wrapper{
|
||||
((([is[current]tags[]]))($:/templates/TagTemplate))
|
||||
|
@ -2,6 +2,7 @@ title: HelloThere
|
||||
modifier: JeremyRuston
|
||||
tags: introduction greetings
|
||||
type: text/x-tiddlywiki
|
||||
modified: 201208121934
|
||||
|
||||
Welcome to TiddlyWiki5, a reboot of TiddlyWiki, the reusable non-linear personal web notebook [[first released in 2004|History]]. It is a complete interactive wiki in JavaScript that can be run from a single HTML file in the browser or as a powerful [[node.js application|node.js]].
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user