Upgraded git time to handle any file name

This commit is contained in:
Yann Esposito (Yogsototh) 2011-09-14 10:35:16 +02:00
parent 29e7957bbb
commit 60ca6b0604
14 changed files with 37 additions and 31 deletions

View file

@ -27,7 +27,7 @@ def gitmtime
ext=%{.#{@item[:extension]}}
filepath<<=ext
if not FileTest.exists?(filepath)
filepath.sub!(ext,%{/index#{ext}})
filepath.sub!(ext,%{#{@item.raw_filename}#{ext}})
end
str=`git log -1 --format='%ci' -- #{filepath}`
if str.nil? or str.empty?
@ -43,4 +43,5 @@ But it works as expected.
Now the date you see at the bottom is exactly the date I modified the _content_ of the page.
Thanks to Eric Sunshine to provide me some hints at cleaning my code.
_Edit_:
Thanks to Eric Sunshine and Kris to provide me some hints at cleaning my code.

View file

@ -27,7 +27,7 @@ def gitmtime
ext=%{.#{@item[:extension]}}
filepath<<=ext
if not FileTest.exists?(filepath)
filepath.sub!(ext,%{/index#{ext}})
filepath.sub!(ext,%{#{@item.raw_filename}#{ext}})
end
str=`git log -1 --format='%ci' -- #{filepath}`
if str.nil? or str.empty?
@ -43,4 +43,5 @@ Bien entendu je sais que c'est très lent et absolument pas optimisé.
Mais ça fonctionne comme prévu.
Maintenant la date que vous voyez en bas de la page correspond exactement à la dernière date de modification de son contenu.
Je tiens à remercier Eric Sunshine pour ses conseils sur ce problème.
_Mise à jour_:
Je tiens à remercier Eric Sunshine et Kris pour leurs conseils sur ce problème.

View file

@ -3,7 +3,7 @@ def gitmtime
ext=%{.#{@item[:extension]}}
filepath<<=ext
if not FileTest.exists?(filepath)
filepath.sub!(ext,%{/index#{ext}})
filepath.sub!(ext,%{#{@item.raw_filename}#{ext}})
end
str=`git log -1 --format='%ci' -- #{filepath}`
if str.nil? or str.empty?

View file

@ -35,7 +35,7 @@ def gitmtime
ext=%{.#{@item[:extension]}}
filepath<<=ext
if not FileTest.exists?(filepath)
filepath.sub!(ext,%{/index#{ext}})
filepath.sub!(ext,%{#{@item.raw_filename}#{ext}})
end
str=`git log -1 --format='%ci' -- #{filepath}`
if str.nil? or str.empty?
@ -54,5 +54,7 @@ fr: Bien entendu je sais que c'est très lent et absolument pas optimisé.
fr: Mais ça fonctionne comme prévu.
fr: Maintenant la date que vous voyez en bas de la page correspond exactement à la dernière date de modification de son contenu.
en: Thanks to Eric Sunshine to provide me some hints at cleaning my code.
fr: Je tiens à remercier Eric Sunshine pour ses conseils sur ce problème.
en: _Edit_:
en: Thanks to Eric Sunshine and Kris to provide me some hints at cleaning my code.
fr: _Mise à jour_:
fr: Je tiens à remercier Eric Sunshine et Kris pour leurs conseils sur ce problème.

View file

@ -4,7 +4,7 @@ def gitmtime
ext=%{.#{@item[:extension]}}
filepath<<=ext
if not FileTest.exists?(filepath)
filepath.sub!(ext,%{/index#{ext}})
filepath.sub!(ext,%{#{@item.raw_filename}#{ext}})
end
str=`git log -1 --format='%ci' -- #{filepath}`
if str.nil? or str.empty?

View file

@ -74,7 +74,7 @@ This is how I do this with <a href="http://nanoc.stoneship.org">nanoc</a>:</p>
ext<span class="Keyword">=</span><span class="String"><span class="String">%{</span>.<span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span><span class="StringVariable"><span class="StringVariable">@</span>item</span><span class="StringEmbeddedSource">[</span><span class="StringConstant"><span class="StringConstant">:</span>extension</span><span class="StringEmbeddedSource">]</span><span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>
filepath<span class="Keyword">&lt;&lt;=</span>ext
<span class="Keyword">if</span> <span class="Keyword">not</span> <span class="Support">FileTest</span>.<span class="Entity">exists?</span>(filepath)
filepath.<span class="Entity">sub!</span>(ext,<span class="String"><span class="String">%{</span>/index<span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>ext<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>)
filepath.<span class="Entity">sub!</span>(ext,<span class="String"><span class="String">%{</span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span><span class="StringVariable"><span class="StringVariable">@</span>item</span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">.</span><span class="Entity">raw_filename</span></span><span class="StringEmbeddedSource">}</span></span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>ext<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>)
<span class="Keyword">end</span>
str<span class="Keyword">=</span><span class="String"><span class="String">`</span>git log -1 --format='%ci' -- <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>filepath<span class="StringEmbeddedSource">}</span></span><span class="String">`</span></span>
<span class="Keyword">if</span> str.<span class="Entity">nil?</span> <span class="Keyword">or</span> str.<span class="Entity">empty?</span>
@ -90,7 +90,8 @@ This is how I do this with <a href="http://nanoc.stoneship.org">nanoc</a>:</p>
But it works as expected.
Now the date you see at the bottom is exactly the date I modified the <em>content</em> of the page.</p>
<p>Thanks to Eric Sunshine to provide me some hints at cleaning my code.</p>
<p><em>Edit</em>:
Thanks to Eric Sunshine and Kris to provide me some hints at cleaning my code.</p>
</div>

View file

@ -167,7 +167,7 @@ But I will revive a bit this blog.&lt;/p&gt;
&lt;p&gt;I had written an efficient &lt;em&gt;&amp;amp;&lt;/em&gt; simplistic MVC javascript framework.&lt;/p&gt;
&lt;p&gt;Best wishes for &lt;em&gt;2011&lt;/em&gt;!&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-10-26:/Scratch/en/blog/2010-10-26-LaTeX-like-macro-and-markdown/</id>
@ -271,7 +271,7 @@ Then my new design obey to the following rules:&lt;/p&gt;
&lt;/ul&gt;
&lt;p&gt;I hope the new design please you.&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-09-02:/Scratch/en/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/</id>
@ -412,7 +412,7 @@ Now all should scroll smoothly on all platforms.
I was inspired by Readability and iBooks&lt;small&gt;&amp;copy;&lt;/small&gt; (the iPhone&lt;small&gt;&amp;copy;&lt;/small&gt; application).&lt;/p&gt;
&lt;p&gt;Tell me what you think of this new design.&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-07-07:/Scratch/en/blog/2010-07-07-CSS-rendering-problems-by-navigator/</id>
@ -772,7 +772,7 @@ a.....&lt;span class="Constant"&gt;&lt;strong&gt;a......b&lt;/strong&gt;&lt;/spa
&lt;p&gt;and you have to make this behaviour with only one regular expression. The problem is the complementary of regular languages is not regular. Then, for some expression it is absolutely not impossible.&lt;/p&gt;
&lt;p&gt;But sometimes with some simple regular expression it should be possible&lt;sup&gt;&lt;a href="#note1"&gt;&amp;dagger;&lt;/a&gt;&lt;/sup&gt;. Say you want to match everything containing the some word say &lt;code&gt;bull&lt;/code&gt; but don&amp;rsquo;t want to match &lt;code&gt;bullshit&lt;/code&gt;. Here is a nice way to do that:&lt;/p&gt;...&lt;/p&gt;</content>
&lt;p&gt;But sometimes with some simple regular expression it should be possible&lt;sup&gt;&lt;a href="#note1"&gt;&amp;dagger;&lt;/a&gt;&lt;/sup&gt;. Say you want to match everything containing the some word say &lt;code&gt;bull&lt;/code&gt; but don&amp;rsquo;t want to match &lt;code&gt;bullshit&lt;/code&gt;. Here is a nice way to do that:&lt;/p&gt;...</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-01-12:/Scratch/en/blog/2010-01-12-antialias-font-in-Firefox-under-Ubuntu/</id>
@ -802,7 +802,7 @@ a.....&lt;span class="Constant"&gt;&lt;strong&gt;a......b&lt;/strong&gt;&lt;/spa
&lt;div&gt;&lt;pre class="twilight"&gt;
&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt; chsh
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2009-12-14:/Scratch/en/blog/2009-12-14-Git-vs--Bzr/</id>
@ -835,7 +835,7 @@ a.....&lt;span class="Constant"&gt;&lt;strong&gt;a......b&lt;/strong&gt;&lt;/spa
<content type="html">&lt;p&gt;It is unbelievable you cannot filter your call with an iPhone! The only reason I see for that is a negotiation with phone operator to force users to get phone advertising. It is simple unacceptable.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;m a &#955; iPhone&amp;rsquo;s user. The only way to filter your call and to manage blacklist is to &lt;em&gt;jailbreak&lt;/em&gt; your iPhone. And I don&amp;rsquo;t want to do that. Then, if like me you find it unacceptable, just write a line to Apple: &lt;a href="http://www.apple.com/feedback/iphone.html"&gt;http://www.apple.com/feedback/iphone.html&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2009-11-12:/Scratch/en/blog/2009-11-12-Git-for-n00b/commandes-avancees/</id>

View file

@ -103,7 +103,7 @@
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Copyright ©, Yann Esposito</a>
</div>
<div id="lastmod">
Modified: 04/20/2011
Modified: 09/14/2011
</div>
<div>
Entirely done with

View file

@ -4,7 +4,7 @@ def gitmtime
ext=%{.#{@item[:extension]}}
filepath<<=ext
if not FileTest.exists?(filepath)
filepath.sub!(ext,%{/index#{ext}})
filepath.sub!(ext,%{#{@item.raw_filename}#{ext}})
end
str=`git log -1 --format='%ci' -- #{filepath}`
if str.nil? or str.empty?

View file

@ -74,7 +74,7 @@ Voici comment je m&rsquo;y prend avec <a href="http://nanoc.stoneship.org">nanoc
ext<span class="Keyword">=</span><span class="String"><span class="String">%{</span>.<span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span><span class="StringVariable"><span class="StringVariable">@</span>item</span><span class="StringEmbeddedSource">[</span><span class="StringConstant"><span class="StringConstant">:</span>extension</span><span class="StringEmbeddedSource">]</span><span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>
filepath<span class="Keyword">&lt;&lt;=</span>ext
<span class="Keyword">if</span> <span class="Keyword">not</span> <span class="Support">FileTest</span>.<span class="Entity">exists?</span>(filepath)
filepath.<span class="Entity">sub!</span>(ext,<span class="String"><span class="String">%{</span>/index<span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>ext<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>)
filepath.<span class="Entity">sub!</span>(ext,<span class="String"><span class="String">%{</span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span><span class="StringVariable"><span class="StringVariable">@</span>item</span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">.</span><span class="Entity">raw_filename</span></span><span class="StringEmbeddedSource">}</span></span><span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>ext<span class="StringEmbeddedSource">}</span></span><span class="String">}</span></span>)
<span class="Keyword">end</span>
str<span class="Keyword">=</span><span class="String"><span class="String">`</span>git log -1 --format='%ci' -- <span class="StringEmbeddedSource"><span class="StringEmbeddedSource">#{</span>filepath<span class="StringEmbeddedSource">}</span></span><span class="String">`</span></span>
<span class="Keyword">if</span> str.<span class="Entity">nil?</span> <span class="Keyword">or</span> str.<span class="Entity">empty?</span>
@ -90,7 +90,8 @@ Voici comment je m&rsquo;y prend avec <a href="http://nanoc.stoneship.org">nanoc
Mais ça fonctionne comme prévu.
Maintenant la date que vous voyez en bas de la page correspond exactement à la dernière date de modification de son contenu.</p>
<p>Je tiens à remercier Eric Sunshine pour ses conseils sur ce problème.</p>
<p><em>Mise à jour</em>:
Je tiens à remercier Eric Sunshine et Kris pour leurs conseils sur ce problème.</p>
</div>

View file

@ -155,7 +155,7 @@ Je n&amp;rsquo;en ai pas encore termin&#233; avec &#231;a. Mais si je tarde trop
&lt;p&gt;J&amp;rsquo;ai &#233;crit un framework MVC pour application javascript simple mais n&#233;anmoins tr&#232;s rapide.&lt;/p&gt;
&lt;p&gt;Meilleurs v&#339;ux &#224; tous&amp;nbsp;!&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-10-26:/Scratch/fr/blog/2010-10-26-LaTeX-like-macro-and-markdown/</id>
@ -246,7 +246,7 @@ J&amp;rsquo;ai donc d&#233;cid&#233; de faire un site &#224; minima.
Je voulais qu&amp;rsquo;il soit joli &lt;em&gt;et&lt;/em&gt; le plus simple possible pour assurer sa compatibilit&#233;.
Les r&#232;gles que je me suis fix&#233;es sont donc:&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-09-02:/Scratch/fr/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/</id>
@ -372,7 +372,7 @@ J&amp;rsquo;ai compl&#232;tement modifi&#233; le style de mon site web.
Il est inspir&#233; du style de l&amp;rsquo;application iBooks&lt;small&gt;&amp;copy;&lt;/small&gt; sur iPhone&lt;small&gt;&amp;copy;&lt;/small&gt;.&lt;/p&gt;
&lt;p&gt;Dites moi ce que vous pensez de ce nouveau design.&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-07-07:/Scratch/fr/blog/2010-07-07-CSS-rendering-problems-by-navigator/</id>
@ -601,7 +601,7 @@ Parce qu&amp;rsquo;il est facile de &lt;em&gt;merger&lt;/em&gt; par erreur, je p
&lt;p&gt;Disons que j&amp;rsquo;ai les branches&amp;nbsp;:&lt;/p&gt;
...&lt;/p&gt;</content>
...</content>
</entry>
<entry>
<id>tag:yannesposito.com,2010-03-22:/Scratch/fr/blog/2010-03-22-Git-Tips/</id>
@ -736,7 +736,7 @@ a.....&lt;span class="Constant"&gt;&lt;strong&gt;a......b&lt;/strong&gt;&lt;/spa
&lt;div&gt;&lt;pre class="twilight"&gt;
&lt;span class="Keyword"&gt;&amp;gt;&lt;/span&gt; chsh
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2009-12-14:/Scratch/fr/blog/2009-12-14-Git-vs--Bzr/</id>
@ -769,7 +769,7 @@ a.....&lt;span class="Constant"&gt;&lt;strong&gt;a......b&lt;/strong&gt;&lt;/spa
<content type="html">&lt;p&gt;Il est vraiment incroyable que le filtrage d&amp;rsquo;appel soit impossible avec un iPhone&amp;nbsp;! Le &lt;em&gt;seul&lt;/em&gt; int&#233;r&#234;t que j&amp;rsquo;y vois, c&amp;rsquo;est une n&#233;gociation avec les op&#233;rateurs pour interdire aux utilisateurs de passer &#224; travers la publicit&#233;. C&amp;rsquo;est tout simplement inacceptable.&lt;/p&gt;
&lt;p&gt;Je suis un utilisateur &#955; de l&amp;rsquo;iPhone. Le seul moyen de filtrer ses appels, de faire des blacklists ou autre c&amp;rsquo;est de &lt;em&gt;jailbreaker&lt;/em&gt; son iPhone. Et je n&amp;rsquo;en ai aucune envie. Alors si comme moi, vous trouvez &#231;a inacceptable, envoyez un mot &#224; Apple&amp;nbsp;: &lt;a href="http://www.apple.com/feedback/iphone.html"&gt;http://www.apple.com/feedback/iphone.html&lt;/a&gt;&lt;/p&gt;
&lt;/p&gt;</content>
</content>
</entry>
<entry>
<id>tag:yannesposito.com,2009-11-12:/Scratch/fr/blog/2009-11-12-Git-for-n00b/c-est-parti-pour-l-aventure/</id>

View file

@ -148,7 +148,7 @@
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.fr">Droits de reproduction ©, Yann Esposito</a>
</div>
<div id="lastmod">
modifié le : 20/04/2011
modifié le : 14/09/2011
</div>
<div>
Site entièrement réalisé avec

View file

@ -206,7 +206,7 @@
</url>
<url>
<loc>http://yannesposito.com/Scratch/fr/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/</loc>
<lastmod>2011-09-12</lastmod>
<lastmod>2011-09-14</lastmod>
</url>
<url>
<loc>http://yannesposito.com/Scratch/en/blog/2010-07-07-CSS-rendering-problems-by-navigator/</loc>
@ -270,7 +270,7 @@
</url>
<url>
<loc>http://yannesposito.com/Scratch/en/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/</loc>
<lastmod>2011-09-12</lastmod>
<lastmod>2011-09-14</lastmod>
</url>
<url>
<loc>http://yannesposito.com/Scratch/en/blog/03_losthighway/</loc>

View file

@ -188,7 +188,7 @@
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/">Copyright ©, Yann Esposito</a>
</div>
<div id="lastmod">
Modified: 09/13/2011
Modified: 09/14/2011
</div>
<div>
Entirely done with