aboutsummaryrefslogtreecommitdiff
path: root/doc/todo/transient_pages.mdwn
blob: 642114d974ad5601b6c6a2d5fa50705b5d36ecde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
On [[todo/auto-create_tag_pages_according_to_a_template]], [[chrysn]]
suggests:

> Instead of creating a file that gets checked in into the RCS, the
> source files could be left out and the output files be written as
> long as there is no physical source file (think of a virtual underlay).
> Something similar would be required to implement alias directive,
> which couldn't be easily done by writing to the RCS as the page's
> contents can change depending on which other pages claim it as an alias.

`add_autofile` could be adapted to do this, or a similar API could be
added.

This would also be useful for autoindex, as suggested on
[[plugins/autoindex/discussion]]. I'd also like to use it for
[[plugins/contrib/album]].

One refinement I'd suggest is that if the transient page is edited,
its transient contents are evaluated and used as the initial
content for the edit box; after that, it'd become a static page. --[[smcv]]

--------------------------

[[!template id=gitbranch branch=smcv/ready/transient author="[[smcv]]"]]
[[!tag patch]]

I think this branch is now enough to be useful. It adds the following:

If the `transient` plugin is loaded, `$srcdir/.ikiwiki/transient` is added
as an underlay.

Pages with the default extension in the transient underlay are automatically
deleted if a page of the same name is created in the srcdir (or an underlay
closer to the srcdir in stacking order).

`tag` enables `transient`, and if `tag_autocreate_commit` is set to 0
(default 1), autocreated tags are written to the transient underlay.

`autoindex` uses autofiles. It also enables `transient`, and if
`autoindex_commit` is set to 0 (default 1), autoindexes are written to
the transient underlay.

autoindex ignores pages in the transient underlay when deciding whether
to generate an index.

Not done yet:

`remove` can't remove transient pages: this turns out to be harder than
I'd hoped, because I don't want to introduce a vulnerability in the
non-regular-file detection...

Transient tags that don't match any pages aren't deleted: I'm not sure
that that's a good idea anyway, though. Similarly, transient autoindexes
of directories that become empty aren't deleted.

Recent changes and aggregated files could conceivably go in the transient
underlay too.

--------------------------

## An earlier version

I had a look at implementing this. It turns out to be harder than I thought
to have purely in-memory pages (several plugins want to be able to access the
source file as a file), but I did get this proof-of-concept branch
to write tag and autoindex pages into an underlay.

This loses the ability to delete the auto-created pages (although they don't
clutter up git this way, at least), and a lot of the code in autoindex is
probably now redundant, so this is probably not quite ready for merge, but
I'd welcome opinions.

Usage: set `tag_underlay` and/or `autoindex_underlay` to an absolute path,
which you must create beforehand. I suggest *srcdir* + `/.ikiwiki/transient`.

Refinements that could be made if this approach seems reasonable:

* make these options boolean, and have the path always be `.ikiwiki/transient`
* improve the `remove` plugin so it also deletes from this special underlay

>> Perhaps it should be something more generic, so that other plugins could use it (such as "album" mentioned above).
>> The `.ikiwiki/transient` would suit this, but instead of saying "tag_underlay" or "autoindex_underlay" have "use_transient_underlay" or something like that?
>> Or to make it more flexible, have just one option "transient_underlay" which is set to an absolute path, and if it is set, then one is using a transient-underlay.
>> --[[KathrynAndersen]]

>>> What I had in mind was more like `tag_autocreate_transient => 1` or
>>> `autoindex_transient => 1`; you might conceivably want tags to be
>>> checked in but autoindices to be transient, and it's fine for each
>>> plugin to make its own decision. Going from that to one boolean
>>> (or just always-transient if people don't think that's too
>>> astonishing) would be trivial, though.
>>>
>>> I don't think relocating the transient underlay really makes sense,
>>> except for prototyping: you only want one, and `.ikiwiki` is as good
>>> a place as any (ikiwiki already needs to be able to write there).
>>>
>>> For [[plugins/contrib/album]] I think I'd just make the photo viewer
>>> pages always-transient - you can always make a transient page
>>> permanent by editing it, after all.
>>>
>>> Do you think this approach has enough potential that I should
>>> continue to hack on it? Any thoughts on the implementation? --[[smcv]]

>>>> Ah, now I understand what you're getting at. Yes, it makes sense to put transient pages under `.ikiwiki`.
>>>> I haven't looked at the code, but I'd be interested in seeing whether it's generic enough to be used by other plugins (such as `album`) without too much fuss.
>>>> The idea of a transient underlay gives us a desirable feature for free: that if someone edits the transient page, it is made permanent and added to the repository.
>>>>
>>>> I think the tricky thing with removing these transient underlay pages is the question of how to prevent whatever auto-generated the pages in the first place from generating them again - or, conversely, how to force whatever auto-generated those pages to regenerate them if you've changed your mind.
>>>> I think you'd need something similar to `will_render` so that transient pages would be automatically removed if whatever auto-generated them is no longer around.
>>>> -- [[KathrynAndersen]]