--- /dev/null
+##Foreword :
+Disabling of filecheck is not actually possible because btw it cause the attachment.pm to malfunction and
+any of pagespec that could contain a *mimetype* condition.
+
+attachment.pm imports "statically" filecheck so actually disabling it should be *interdicted* .
+
+<pre>
+sub import {
+ add_underlay("attachment");
+ add_underlay("javascript");
+ add_underlay("jquery");
+ hook(type => "getsetup", id => "attachment", call => \&getsetup);
+ hook(type => "checkconfig", id => "attachment", call => \&checkconfig);
+ hook(type => "formbuilder_setup", id => "attachment", call => \&formbuilder_setup);
+ hook(type => "formbuilder", id => "attachment", call => \&formbuilder, last => 1);
+ IkiWiki::loadplugin("filecheck");
+}
+</pre>
+
+----
+
+## How bad is it ?
+
+So I tried on three pages to inline <tt>!mimetype(image/*)</tt> while I allowed attachment of <tt>mimetype(image/*)</tt>
+
+My profiling tests in the bug report shows that most of the time is spend in the "Fallback using file" block code,
+I tried to comment that block and see how it'll perform. Obviously this is much much faster ... but is the mimetype
+discovered using only *File::MimeInfo* ?
+
+
+Dumping some strings before return to STDERR, rebuilding . This is just a [[!toggle id="code-test" text="dumpdebug adding"]]
+
+[[!toggleable id="code-test" text="""
+<pre>
+sub match_mimetype ($$;@) {
+ my $page=shift;
+ my $wanted=shift;
+
+ my %params=@_;
+ my $file=exists $params{file} ? $params{file} : IkiWiki::srcfile($IkiWiki::pagesources{$page});
+ if (! defined $file) {
+ return IkiWiki::ErrorReason->new("file does not exist");
+ }
+
+ # Get the mime type.
+ #
+ # First, try File::Mimeinfo. This is fast, but doesn't recognise
+ # all files.
+ eval q{use File::MimeInfo::Magic};
+ my $mimeinfo_ok=! $@;
+ my $mimetype;
+ print STDERR " --- match_mimetype (".$file.")\n";
+ if ($mimeinfo_ok) {
+ my $mimetype=File::MimeInfo::Magic::magic($file);
+ }
+
+ # Fall back to using file, which has a more complete
+ # magic database.
+ #if (! defined $mimetype) {
+ # open(my $file_h, "-|", "file", "-bi", $file);
+ # $mimetype=<$file_h>;
+ # chomp $mimetype;
+ # close $file_h;
+ #}
+
+ if (! defined $mimetype || $mimetype !~s /;.*//) {
+ # Fall back to default value.
+ $mimetype=File::MimeInfo::Magic::default($file)
+ if $mimeinfo_ok;
+ if (! defined $mimetype) {
+ $mimetype="unknown";
+ }
+ }
+
+ my $regexp=IkiWiki::glob2re($wanted);
+ if ($mimetype!~$regexp) {
+ print STDERR " xxx MIME unknown ($mimetype - $wanted - $regexp ) \n";
+ return IkiWiki::FailReason->new("file MIME type is $mimetype, not $wanted");
+ }
+ else {
+ print STDERR " vvv MIME found\n";
+ return IkiWiki::SuccessReason->new("file MIME type is $mimetype");
+ }
+}
+</pre>
+"""]]
+
+The results dump to stderr (or a file called... 'say *mime*) looks like this :
+<pre>
+--- match_mimetype (/usr/share/ikiwiki/attachment/ikiwiki/jquery.fileupload-ui.js)
+ xxx MIME unknown (text/plain - image/* - (?i-xsm:^image\/.*$) )
+ --- match_mimetype (/usr/share/ikiwiki/locale/fr/directives/ikiwiki/directive/fortune.mdwn)
+ xxx MIME unknown (text/plain - image/* - (?i-xsm:^image\/.*$) )
+ --- match_mimetype (/usr/share/ikiwiki/locale/fr/basewiki/shortcuts.mdwn)
+ xxx MIME unknown (text/plain - image/* - (?i-xsm:^image\/.*$)
+ --- match_mimetype (/usr/share/ikiwiki/smiley/smileys/alert.png)
+ xxx MIME unknown (application/octet-stream - image/* - (?i-xsm:^image\/.*$) )
+ --- match_mimetype (/usr/share/ikiwiki/attachment/ikiwiki/images/ui-bg_flat_75_ffffff_40x100.png)
+ xxx MIME unknown (application/octet-stream - image/* - (?i-xsm:^image\/.*$)
+</pre>
+
+<tt>---</tt> prepend signals the file on analysis<br/>
+<tt>xxx</tt> prepend signals a returns failure : mime is unknown, the match is a failure<br/>
+<tt>vvv</tt> prepend signals a return success.<br/>
+
+
+This is nasty-scary results ! Something missed me or this mime-filecheck is plain nuts ?
+
+*Question 1* : How many files have been analysed : **3055** (yet on a tiny tiny wiki)
+<pre>grep "^ --- " mime | wc -l
+3055
+</pre>
+
+*Question 2* : How many time it fails : *all the time*
+<pre>
+ grep "^ xxx " mime | wc -l
+3055
+</pre>
+
+*Question 1bis* : Doh btw , how many files have been re-analysed ? ** 2835 ** OMG !!
+<pre>grep "^ --- " mime | sort -u | wc -l
+220
+</pre>
+
+## Conclusion
+
+- Only the system command *file -bi* works. While it is **should** be easy on the cpu , it's also hard on the I/O -> VM :(
+- Something nasty with the mime implementation and/or my system configuration -> Hints ? :D
+- Need to cache during the rebuild : a same page needs not being rechecked for its mime while it's locked !
+
+
+--mathdesc
--- /dev/null
+[[!comment format=mdwn
+ username="mathdesc"
+ subject="For lighttpd with mod_magnet"
+ date="2012-08-18T18:27:32Z"
+ content="""
+Same can be done for lighttpd via a lua script (said rewrite.lua) using *mod_magnet* than need to be installed and
+called in your conf like this :
+
+<pre>
+# error-handler for status 404
+$HTTP[\"url\"] =~ \"^/mysite/\" {
+magnet.attract-physical-path-to = ( server.document-root + \"/rewrite.lua\" )
+}
+</pre>
+
+Ref :
+[[mod_magnet docs|http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModMagnet]]
+
+
+
+<pre>
+
+ function removePrefix(str, prefix)
+ return str:sub(1,#prefix+1) == prefix..\"/\" and str:sub(#prefix+2)
+ end
+
+
+
+ attr = lighty.stat(lighty.env[\"physical.path\"])
+ local prefix = '/mysite'
+ if (not attr) then
+ -- we couldn't stat() the file
+ -- let's generate a xapian query with it
+ new_uri =removePrefix(lighty.env[\"uri.path\"], prefix)
+ print (\"page not found : \" .. new_uri .. \" asking xapian\")
+ lighty.env[\"uri.path\"] = \"/mysite/ikiwiki.cgi\"
+ lighty.env[\"uri.query\"] = \"P=\" .. new_uri
+ lighty.env[\"physical.rel-path\"] = lighty.env[\"uri.path\"]
+ lighty.env[\"physical.path\"] = lighty.env[\"physical.doc-root\"] .. lighty.env[\"physical.rel-path\"]
+ end
+</pre>
+
+Hope this is useful to you :)
+"""]]
--- /dev/null
+Hi! Please apply the following [[patch]] to make the
+`archivepage.tmpl` template more semantic and easier to style with
+a local CSS:
+
+ From 4e5cc0d9e5582f20df9f26dd5b1937ead0b46827 Mon Sep 17 00:00:00 2001
+ From: intrigeri <intrigeri@boum.org>
+ Date: Sat, 18 Aug 2012 10:34:36 +0200
+ Subject: [PATCH] Ease archivepage styling by using named classes, move
+ styling to the CSS.
+
+ ---
+ doc/style.css | 4 ++++
+ templates/archivepage.tmpl | 8 ++++----
+ 2 files changed, 8 insertions(+), 4 deletions(-)
+
+ diff --git a/doc/style.css b/doc/style.css
+ index 6e2afce..5fb4100 100644
+ --- a/doc/style.css
+ +++ b/doc/style.css
+ @@ -202,6 +202,10 @@ div.recentchanges {
+ margin-top: 1em;
+ }
+
+ +.archivepagedate {
+ + font-style: italic;
+ +}
+ +
+ .error {
+ color: #C00;
+ }
+ diff --git a/templates/archivepage.tmpl b/templates/archivepage.tmpl
+ index 93bdd9c..3e0bd9b 100644
+ --- a/templates/archivepage.tmpl
+ +++ b/templates/archivepage.tmpl
+ @@ -1,10 +1,10 @@
+ -<p>
+ +<div class="archivepage">
+ <TMPL_IF PERMALINK>
+ <a href="<TMPL_VAR PERMALINK>"><TMPL_VAR TITLE></a><br />
+ <TMPL_ELSE>
+ <a href="<TMPL_VAR PAGEURL>"><TMPL_VAR TITLE></a><br />
+ </TMPL_IF>
+ -<i>
+ +<span class="archivepagedate">
+ Posted <TMPL_VAR CTIME>
+ <TMPL_IF AUTHOR>
+ by <span class="author">
+ @@ -15,5 +15,5 @@ by <span class="author">
+ </TMPL_IF>
+ </span>
+ </TMPL_IF>
+ -</i>
+ -</p>
+ +</span>
+ +</div>
+ --
+ 1.7.10.4
+