aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis <spalax@gresille.org>2014-06-13 10:59:41 +0200
committerLouis <spalax@gresille.org>2014-06-13 10:59:41 +0200
commit3d3dd282cf262a8e9819a245b64779fe1a724252 (patch)
treebfbc3fc0b21d3dd8aa5d5251b61731db3c54f733
parent4e617031534767f54903fd09851a99e61326e6bd (diff)
downloadikiwiki-3d3dd282cf262a8e9819a245b64779fe1a724252.tar
ikiwiki-3d3dd282cf262a8e9819a245b64779fe1a724252.tar.gz
New plugin: datetime_cmp
-rw-r--r--doc/plugins/contrib/created_in_future.mdwn10
-rw-r--r--doc/plugins/contrib/datetime_cmp.mdwn85
2 files changed, 94 insertions, 1 deletions
diff --git a/doc/plugins/contrib/created_in_future.mdwn b/doc/plugins/contrib/created_in_future.mdwn
index ce920d913..09d2d52fc 100644
--- a/doc/plugins/contrib/created_in_future.mdwn
+++ b/doc/plugins/contrib/created_in_future.mdwn
@@ -1,7 +1,14 @@
-[[!template id=plugin name=created_in_future author="[[Louis|spalax]]"]]
+[[!template id=plugin name="created_in_future (deprecated)" author="[[Louis|spalax]]"]]
# Created_in_future
+This plugin is deprecated, and can be replaced by function `cdate_geq_today()` in plugin [[datetime_cmp|plugins/contrib/datetime_cmp]].
+
+[[!toggle id=old text="Show/Hide old documentation"]]
+
+[[!toggleable id=old text="""
+# Created_in_future
+
This plugin provides a `created_in_future()` [[PageSpec|ikiwiki/pagespec/]]
function. It matches pages which have a creation date in the future.
@@ -18,3 +25,4 @@ It can be used to display a list of upcoming events.
## Code
Code and documentation this way: [[https://atelier.gresille.org/projects/gresille-ikiwiki/wiki/Created_in_future]].
+"""]]
diff --git a/doc/plugins/contrib/datetime_cmp.mdwn b/doc/plugins/contrib/datetime_cmp.mdwn
new file mode 100644
index 000000000..7508e0b21
--- /dev/null
+++ b/doc/plugins/contrib/datetime_cmp.mdwn
@@ -0,0 +1,85 @@
+[[!template id=plugin name=datetime_cmp author="[[Louis|spalax]]"]]
+[[!tag type/pagespec]]
+
+# Datetime_cmp
+
+This plugin provides a family of
+[pagespec](http://ikiwiki.info/ikiwiki/pagespec/) matching pages according to
+creation or modification times.
+
+It also sets the date of the next modification of the page on relevant date, so
+that the page will be rebuilt if the condition changes.
+
+## List of functions
+
+The list of functions is given by the following regexp:
+
+ [ct](date|time)_(lt|gt|leq|geq|eq|neq)_(abs|page|now|today)(|_delta)
+
+where:
+
+ * `[ct]`: compare creation or modification time or date:
+ * `c`reation time;
+ * `m`odification time.
+ * `(date|time)`: compare full date and time, or only date (useful when time is irrelevant):
+ * `time`: compare full date and time;
+ * `date`: compare only date.
+ * `(lt|gt|leq|geq|eq|neq)`: operator of comparison:
+ * `lt`: less than;
+ * `gt`: greater than;
+ * `leq`: less or equal than;
+ * `geq`: greater or equal than;
+ * `eq`: equal;
+ * `neq`: not equal.
+ * `(abs|page|now|today)`: element to compare to:
+ * `abs`: absolute date or time (given in argument);
+ * `page`: other page (given in argument);
+ * `now`: date or time of compilation;
+ * `today`: same meaning as `now`.
+ * `(|_delta)`: used to add a time delta (to use comparisons such as *created at least two day after `some_page`*):
+ * *empty*: no delta;
+ * `_delta`: delta (given in argument).
+
+### Number of arguments
+
+[[!table header=no data="""
+ | `now` `today` | `page` | `abs`
+no delta | *no arguments* | `pagename` | `date`
+delta | `delta` | `pagename, delta` | `date, delta`
+"""]]
+
+### Format of arguments
+
+* *date* or *time*: anything that can be recognized by perl [[str2time|http://search.cpan.org/~rse/lcwa-1.0.0/lib/lwp/lib/HTTP/Date.pm]] function, *without any comma*.
+* *delta*: One of the following patterns:
+ * `Y-M-D`: positive date;
+ * `H:M:S`: positive time;
+ * `Y-M-D H:M:S`: positive date and time;
+ * Add `-` at the beginning of the string to make durations negative.
+* several arguments: when two arguments are provided, they are passed as one string, which is then split according to the last comma.
+
+## Time zones
+
+Key `timezone` in the setup file is used to define time zone. If not set, we
+try to guess the local time zone.
+
+## Examples
+
+### Some functions
+
+* `ctime_gt_page(foo)`: match pages created after page `foo`.
+* `cdate_eq_today()`: match pages created the day the wiki is compiled.
+* `mtime_eq_now()`: match pages modified the time the wiki is compiled (likely no page, since comparison is done up to the milisecond).
+* `cdate_geq_page_delta(foo, 00-00-01)`: match pages created at least one day after page `foo`.
+* `cdate_gt_page(foo)`: same as the previous one.
+* `mdate_gt_today_delta(-00-01-00)`: match pages modified one month ago, or later (can be used to display recent changes).
+
+### Use case
+
+It can be used to display a list of upcoming events.
+
+ \[[!inline pages="events/* and cdate_geq_today()" reverse=yes sorted=meta(date)]]
+
+## Code
+
+Code and documentation this way: [[https://atelier.gresille.org/projects/gresille-ikiwiki/wiki/datetime_cmp]].