]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/inline_sort_order_and_meta_date_value.mdwn
(no commit message)
[ikiwiki.git] / doc / bugs / inline_sort_order_and_meta_date_value.mdwn
1 I have a directory containing two files. f1 (<http://alcopop.org/~jon/repro2/src/blog/debgtd.html>) has 
2
3     meta date="2008-07-02 14:13:17"
4
5 f2 (<http://alcopop.org/~jon/repro2/src/blog/moving.html>) has
6
7     meta date="2008-07-02 21:04:21"
8
9 They have both been modified recently:
10
11     >>> stat(f1)
12     (33188, 459250L, 65027L, 1, 1000, 1000, 1686L, 1227967177, 1227966706, 1227966706)
13     >>> stat(f2)
14     (33188, 458868L, 65027L, 1, 1000, 1000, 938L, 1227967187, 1227966705, 1227966705)
15
16 Note that f1 is fractionally newer than f2 in terms of ctime and mtime, but f2 is much newer in terms of the meta information.
17
18 Another page includes them both via inline:
19
20     inline pages="blog/*" show=5
21
22 The resulting page is rendered with f1 above f2, seemingly not using the meta directive information: <http://alcopop.org/~jon/repro2/dest/blog/>. The footer in the inline pages does use the correct time e.g. <em>Posted Wed 02 Jul 2008 14:13:17 BST</em>.
23
24 If I instead include them using creation_year in the pagespec, they are ordered correctly.
25
26 <http://alcopop.org/~jon/repro2/> contains the src used to reproduce this, the precise ikiwiki invocation (inside Makefile) and the results (dest).
27
28 -- [[users/Jon]]
29
30
31 > On Ikiwiki 2.53.3 (Debian Lenny), my inlines are also sorted using mtime
32 > by default -- despite what the [[documentation|/ikiwiki/directive/inline]]
33 > says -- but setting the supposed default sort order manually produces the
34 > correct results.  For example, the following inline sorts my blog
35 > entires using their meta date or ctime:
36
37 >     inline pages="blog/*" show="10" sort="age"
38
39 > I'll try to look at the code this weekend and see if age is really the
40 > default sort order.
41
42 > -- [David A. Harding](http://dtrt.org), 2008-12-20
43
44 Here is the code. As you can see, sort="age" is equivilant to leaving
45 out the sort option. --[[Joey]] 
46
47         if (exists $params{sort} && $params{sort} eq 'title') {
48                 @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
49         }
50         elsif (exists $params{sort} && $params{sort} eq 'mtime') {
51                 @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
52         }
53         elsif (! exists $params{sort} || $params{sort} eq 'age') {
54                 @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
55         }
56         else {
57                 return sprintf(gettext("unknown sort type %s"), $params{sort});
58         }
59
60 > On further testing, I find that the bug is limited to the first time
61 > creation time should be used and has nothing to do with setting the sort
62 > parameter. Revised steps to reproduce: --[David A.  Harding](http://dtrt.org), 2008-12-20
63
64 > 1. Create pages that sort different by mtime and ctime
65
66 > 2. inline pages="somepages/*"
67
68 > 3. ikiwiki --setup setup_file
69
70 > 4. Pages are output incorrectly in mtime order
71
72 > 5. ikiwiki --setup setup_file
73
74 > 6. Pages are output correctly in ctime order
75
76 > 7. Create new page in somepages/, set its ctime to earlier than another
77 >    page in sompages/
78
79 > 8. ikiwiki --setup setup_file
80
81 > 9. All previously sorted pages output correctly in ctime order but new
82 >    page is output incorrectly at the top as if its mtime was its ctime
83
84 > 10. ikiwiki --setup setup_file
85
86 > 11. All pages, including new page, are output correctly in ctime order
87
88 You're confusing ctime and creation time. This is perhaps not suprising, as
89 ikiwiki uses the term 'ctime' to refer to creation time. However, the unix
90 ctime value is not the same thing. Unix ctime can change if a file changes
91 owner, or in some cases, permissions. Unix ctime also always changes
92 when the file is modified. Ikiwiki wants a first creation date of the file,
93 and it accomplishes this by recording the initial ctime of a file the first
94 time it processes it, and *preserving* that creation time forever, ignoring
95 later ctime changes.
96
97 I suspect that this, coupled with the fact that ikiwiki sorts newest pages
98 first, explains everything you describe. If not, please send me a shell script
99 test case I can run, as instructions like "Create pages that sort different by
100 mtime and ctime" are not ones that I know how to follow (given that touch sets
101 *both*). --[[Joey]] 
102
103 > Sorry. I conflated Unix ctime and ikiwiki's creation time because I
104 > didn't think the difference was important to this case. I'm a writer,
105 > and I should have known better -- I appologize. Revised steps to
106 > reproduce are below; feel free to delete this whole misunderstanding
107 > to make the bug report more concise.
108 >
109 > 1. Create pages in the srcdir that should sort in one order by
110 >    last-modification time and in a diffent order by original creation
111 >    time.  For example:
112
113 >         $ echo -e '\[[!meta date="2007-01-01"]]\nNew.' > test/new.mdwn
114 >         $ echo -e '\[[!meta date="2006-01-01"]]\nOld.' > test/old.mdwn
115
116 > 2. Create a page that includes the files.  For example:
117
118 >
119 >         $ echo '\[[!inline pages="test/*"]]' > sort-test.mdwn
120
121 > 3. Run ikiwiki.  For example `ikiwiki --setup setup_file`
122
123 > 4. Pages are output incorrectly in modification time order. For example,
124 >    actual partial HTML of the sort-test/index.html from commands used
125 >    above (whitespace-only lines removed; one whitespace-only line
126 >    added):
127
128 >         <div class="inlinepage">
129 >         <span class="header">
130 >         <a href="./../test/old/">old</a>
131 >         </span>
132 >         <p>Old.</p>
133 >         <span class="pagedate">
134 >         Posted Sun 01 Jan 2006 12:00:00 AM EST
135 >         </span>
136 >         </div>
137
138 >         <div class="inlinepage">
139 >         <span class="header">
140 >         <a href="./../test/new/">new</a>
141 >         </span>
142 >         <p>New.</p>
143 >         <span class="pagedate">
144 >         Posted Mon 01 Jan 2007 12:00:00 AM EST
145 >         </span>
146 >         </div>
147
148 > 5. Run ikiwiki again with the same command line.  For example: `ikiwiki --setup setup_file`
149
150 > 6. Pages are output correctly in creation time order. For example,
151 >    actual partial HTML of the sort-test/index.html from commands used
152 >    above (whitespace-only lines removed; one whitespace-only line
153 >    added):
154
155 >         <div class="inlinepage">
156 >         <span class="header">
157 >         <a href="./../test/new/">new</a>
158 >         </span>
159 >         <p>New.</p>
160 >         <span class="pagedate">
161 >         Posted Mon 01 Jan 2007 12:00:00 AM EST
162 >         </span>
163 >         </div>
164
165 >         <div class="inlinepage">
166 >         <span class="header">
167 >         <a href="./../test/old/">old</a>
168 >         </span>
169 >         <p>Old.</p>
170 >         <span class="pagedate">
171 >         Posted Sun 01 Jan 2006 12:00:00 AM EST
172 >         </span>
173 >         </div>
174
175 > 7. Create a new page with the current Unix mtime and Unix ctime, but a
176 >    !meta date before the most recent creation date of another page.
177 >    For example:
178
179 >         $ echo -e '\[[!meta date="2005-01-01"]]\nOlder.' > test/older.mdwn
180
181 > 8. Run ikiwiki again with the same command line.  For example: `ikiwiki --setup setup_file`
182
183 > 9. All previously sorted pages output correctly in order of their
184 >    creation time, but the new page is output incorrectly at the top as
185 >    if its modification time was its creation time.  For example,
186 >    actual partial HTML of the sort-test/index.html from commands used
187 >    above (whitespace-only lines removed; two whitespace-only
188 >    lines added):
189
190 >         <div class="inlinepage">
191 >         <span class="header">
192 >         <a href="./../test/older/">older</a>
193 >         </span>
194 >         <p>Older.</p>
195 >         <span class="pagedate">
196 >         Posted Sat 01 Jan 2005 12:00:00 AM EST
197 >         </span>
198 >         </div>
199
200 >         <div class="inlinepage">
201 >         <span class="header">
202 >         <a href="./../test/new/">new</a>
203 >         </span>
204 >         <p>New.</p>
205 >         <span class="pagedate">
206 >         Posted Mon 01 Jan 2007 12:00:00 AM EST
207 >         </span>
208 >         </div>
209
210 >         <div class="inlinepage">
211 >         <span class="header">
212 >         <a href="./../test/old/">old</a>
213 >         </span>
214 >         <p>Old.</p>
215 >         <span class="pagedate">
216 >         Posted Sun 01 Jan 2006 12:00:00 AM EST
217 >         </span>
218 >         </div>
219
220 > 10. Run ikiwiki again with the same command line.  For example: `ikiwiki --setup setup_file`
221
222 > 11. All pages, including new page, are output correctly in creation time
223 >     order. For example, actual partial HTML of the sort-test/index.html
224 >     from commands used above (whitespace-only lines removed; two
225 >     whitespace-only lines added): 
226
227 >         <div class="inlinepage">
228 >         <span class="header">
229 >         <a href="./../test/new/">new</a>
230 >         </span>
231 >         <p>New.</p>
232 >         <span class="pagedate">
233 >         Posted Mon 01 Jan 2007 12:00:00 AM EST
234 >         </span>
235 >         </div>
236
237 >         <div class="inlinepage">
238 >         <span class="header">
239 >         <a href="./../test/old/">old</a>
240 >         </span>
241 >         <p>Old.</p>
242 >         <span class="pagedate">
243 >         Posted Sun 01 Jan 2006 12:00:00 AM EST
244 >         </span>
245 >         </div>
246
247 >         <div class="inlinepage">
248 >         <span class="header">
249 >         <a href="./../test/older/">older</a>
250 >         </span>
251 >         <p>Older.</p>
252 >         <span class="pagedate">
253 >         Posted Sat 01 Jan 2005 12:00:00 AM EST
254 >         </span>
255 >         </div>
256
257 > File status after all the above actions:
258
259 >         $ stat test/*
260 >           File: `test/new.mdwn'
261 >           Size: 33              Blocks: 8          IO Block: 4096   regular file
262 >         Device: ca20h/51744d    Inode: 684160      Links: 1
263 >         Access: (0644/-rw-r--r--)  Uid: ( 1000/ harding)   Gid: ( 1000/ harding)
264 >         Access: 2008-12-20 21:48:32.000000000 -0500
265 >         Modify: 2008-12-20 21:27:03.000000000 -0500
266 >         Change: 2008-12-20 21:27:03.000000000 -0500
267 >           File: `test/older.mdwn'
268 >           Size: 35              Blocks: 8          IO Block: 4096   regular file
269 >         Device: ca20h/51744d    Inode: 684407      Links: 1
270 >         Access: (0644/-rw-r--r--)  Uid: ( 1000/ harding)   Gid: ( 1000/ harding)
271 >         Access: 2008-12-20 21:48:32.000000000 -0500
272 >         Modify: 2008-12-20 21:42:10.000000000 -0500
273 >         Change: 2008-12-20 21:42:10.000000000 -0500
274 >           File: `test/old.mdwn'
275 >           Size: 33              Blocks: 8          IO Block: 4096   regular file
276 >         Device: ca20h/51744d    Inode: 684161      Links: 1
277 >         Access: (0644/-rw-r--r--)  Uid: ( 1000/ harding)   Gid: ( 1000/ harding)
278 >         Access: 2008-12-20 21:48:32.000000000 -0500
279 >         Modify: 2008-12-20 21:27:09.000000000 -0500
280 >         Change: 2008-12-20 21:27:09.000000000 -0500
281
282 > My ikiwiki configuration file (being used to port a blog from pyblosxom
283 > to ikiwiki):
284
285 >         harding@mail:~$ sed 's/#.*//; /^[       ]*$/d' .ikiwiki/gnuisance.setup 
286 >         use IkiWiki::Setup::Standard {
287 >               wikiname => "HardingBlog",
288 >               adminemail => 'dave@dtrt.org',
289 >               srcdir => "/srv/backup/git/gnuisance.net",
290 >               destdir => "/srv/test.dtrt.org",
291 >               url => "http://srv.dtrt.org",
292 >               wrappers => [
293 >               ],
294 >               atom => 1,
295 >               syslog => 0,
296 >               prefix_directives => 1,
297 >               add_plugins => [qw{goodstuff tag}],
298 >               disable_plugins => [qw{passwordauth}],
299 >               tagbase => "tag",
300 >         }
301 >
302 > --[David A. Harding](http://dtrt.org/), 2008-12-20
303
304 Thank you for a textbook excellent reproduction recipe.
305
306 What appears to be going on here is that meta directives are not processed
307 until the leaf pages are rendered, and thus the ctime setting is not
308 available at the time that they are inlined, and the newer unix ctime is
309 used. On the second build, the meta data has already been recorded.
310
311 This can probably be avoided by processing meta date at scan time.
312
313 Verified, fix works. [[done]]
314 --[[Joey]]