<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>piouPiouM&#039;s dev&#187; Archives pour le tag astuces – piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/tag/astuces/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Fri, 23 Dec 2011 23:41:36 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Compass&#160;: supprimer le cache buster des sprites</title>
		<link>http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html</link>
		<comments>http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html#comments</comments>
		<pubDate>Wed, 15 Jun 2011 18:22:54 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[compass]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=543</guid>
		<description><![CDATA[Le générateur de sprites de Compass 0.11.31 crée des images dont le nom a pour format &#60;map>-&#60;hash>.png où &#60;map> correspond au nom du répertoire qui contient les images du sprite et -&#60;hash> à un hash qui&#160;:


assure l&#8217;unicité du fichier généré&#160;;
fait office de cache buster.


Seulement voilà, chaque modification de sprite (par un ajout ou décalage d&#8217;image [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Le générateur de <strong>sprites de Compass 0.11.3</strong><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> crée des images dont le nom a pour format <code>&lt;map>-&lt;hash>.png</code> où <code>&lt;map></code> correspond au nom du répertoire qui contient les images du sprite et <code>-&lt;hash></code> à un hash qui&#160;:</p>

<ul>
<li>assure l&#8217;unicité du fichier généré&#160;;</li>
<li>fait office de <strong><span lang="en">cache buster</span></strong>.</li>
</ul>

<p>Seulement voilà, chaque modification de sprite (par un ajout ou décalage d&#8217;image par exemple) va générer une image avec un hash différent<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>, ce qui rend la gestion du dépôt d&#8217;un projet versionné assez prise de tête.<br />
Heureusement, il est possible de ruser.<span id="more-543"></span></p>

<p>Pour ce faire, il suffit d&#8217;implémenter les <span lang="en">callbacks <strong><code>on_sprite_saved</code></strong> et <strong><code>on_stylesheet_saved</code></strong></span> dans le fichier de configuration du projet, comme suit&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#</span>
<span style="color:#008000; font-style:italic;"># config.rb</span>
<span style="color:#008000; font-style:italic;">#</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Réaliser une copie des sprites avec un nom dépourvu du hash d'unicité.</span>
on_sprite_saved <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>filename<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>filename<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC00FF; font-weight:bold;">FileUtils</span>.<span style="color:#9900CC;">cp</span> filename, filename.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">-</span>s<span style="color:#006600; font-weight:bold;">&#91;</span>a<span style="color:#006600; font-weight:bold;">-</span>z0<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#125;</span>\.<span style="color:#9900CC;">png</span>$<span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#996600;">'.png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Remplacer dans les feuilles de styles générés les références aux sprites par</span>
<span style="color:#008000; font-style:italic;"># leurs équivalents dépourvus du hash d'unicité.</span>
on_stylesheet_saved <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>filename<span style="color:#006600; font-weight:bold;">|</span>
  <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>filename<span style="color:#006600; font-weight:bold;">&#41;</span>
    css = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">read</span> filename
    <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>filename, <span style="color:#996600;">'w+'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
      f <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> css.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">-</span>s<span style="color:#006600; font-weight:bold;">&#91;</span>a<span style="color:#006600; font-weight:bold;">-</span>z0<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#125;</span>\.<span style="color:#9900CC;">png</span><span style="color:#006600; font-weight:bold;">&#125;</span>, <span style="color:#996600;">'.png'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>


<p>Ainsi, après chaque génération de sprite par <a href="http://compass-style.org/" title="Compass Home | Compass Documentation">Compass</a>, une copie de l&#8217;image dépourvue du hash d&#8217;unicité est réalisée. Cela s&#8217;accompagne bien évidemment par un remplacement de leurs appels dans les feuilles de styles.<br />
Il ne reste plus qu&#8217;à ignorer les images ayant un hash au niveau de votre <span lang="en">repository</span> pour ne pas polluer ce dernier.</p>

<p>Je suis conscient qu&#8217;il y aurait plus <span lang="en">secure</span> (je pense notamment aux substitutions dans les feuilles de style), mais disons que cela me convient dans l&#8217;immédiat, et qu&#8217;accessoirement je ne fais pas de ruby <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/compass-rvm-multiple-instances.html' title='Instances multiples de Compass avec Ruby Version Manager (rvm)'>Instances multiples de Compass avec Ruby Version Manager (rvm)</a></li><li><a href='http://pioupioum.fr/developpement/drupal-iframe-page.html' title='Drupal 6 : utiliser une iframe comme contenu de page'>Drupal 6&#160;: utiliser une iframe comme contenu de page</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/snippets/apache-rotation-logs.html' title='Rotation des logs Apache'>Rotation des logs Apache</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p><strong>attention&#160;:</strong> les versions de Compass inférieures à 0.11.3 souffrent de bugs qui empêchent cette astuce de fonctionner.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>les fichiers obsolètes étants automatiquement supprimés, à moins que la variable de configuration <code>$&lt;map&gt;-clean-up</code> soit positionnée à <code>false</code>.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drupal 6&#160;: utiliser une iframe comme contenu de page</title>
		<link>http://pioupioum.fr/developpement/drupal-iframe-page.html</link>
		<comments>http://pioupioum.fr/developpement/drupal-iframe-page.html#comments</comments>
		<pubDate>Sun, 29 May 2011 18:17:22 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=529</guid>
		<description><![CDATA[Vous devez intégrer sous Drupal 6 des pages en provenance d&#8217;un site externe. Le web scraping est à exclure et de ce fait le chargement en iframe des pages externes a été retenu.
Marche à suivre.

Déclarer un menu de type callback

En premier lieu, il vous faut créer la page virtuelle qui aura la charge de faire [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Vous devez intégrer sous <strong><a href="http://drupal.org/" title="Drupal - Open Source CMS | drupal.org">Drupal</a> 6</strong> des pages en provenance d&#8217;un site externe. Le <strong><a href="http://fr.wikipedia.org/wiki/Web_scraping" title="Web scraping - Wikipédia">web scraping</a></strong> est à exclure et de ce fait le <strong>chargement en iframe</strong> des pages externes a été retenu.<br />
Marche à suivre.<span id="more-529"></span></p>

<h2>Déclarer un menu de type callback</h2>

<p>En premier lieu, il vous faut créer la page virtuelle qui aura la charge de faire appel au service externe <em>via</em> une iframe. Cela se fait en implémentant le <a href="http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_menu/6" title="hook_menu | Drupal API">hook_menu</a> pour y déclarer une entrée de type <a href="http://api.drupal.org/api/drupal/includes--menu.inc/constant/MENU_CALLBACK/6" title="MENU_CALLBACK | Drupal API">MENU_CALLBACK</a>. La fonction callback associée, <code>_mytheme_load_iframe()</code> ici<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>, prendra 3 arguments&#160;:</p>

<ol>
<li><strong>url</strong>&#160;: l&#8217;URL de la ressource externe à charger dans l&#8217;iframe&#160;;</li>
<li><strong>width</strong>&#160;: la largeur en pixels de l&#8217;iframe, de <strong>type <code>String</code> obligatoirement</strong>&#160;;</li>
<li><strong>height</strong>&#160;: la hauteur en pixels de l&#8217;iframe, obligatoirement de type <code>String</code>.</li>
</ol>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * template.php
 */</span>
<span style="color: #009933; font-style: italic;">/**
 * @implements hook_menu()
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> mytheme_menu<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'drupal/page/path'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'title'</span>            <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Mon contenu externe'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'page callback'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'_mytheme_load_iframe'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'page arguments'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
              <span style="color: #0000ff;">'url'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'http://example.com/service'</span><span style="color: #339933;">,</span>
              <span style="color: #0000ff;">'width'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'700'</span><span style="color: #339933;">,</span>
              <span style="color: #0000ff;">'height'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1000'</span><span style="color: #339933;">,</span>
            <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'access arguments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'access content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'type'</span>             <span style="color: #339933;">=&gt;</span> MENU_CALLBACK<span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Loads an external resource into an iframe.
 *
 * @param string $url   URL to load in the iframe.
 * @param string $width The width of the iframe.
 * @param string $height The height of the iframe.
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> _mytheme_load_iframe<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> theme<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mytheme_simple_iframe'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$iframe_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Comme vous pouvez le lire, la méthode de callback fait appel à la fonction <a href="http://api.drupal.org/api/drupal/includes--theme.inc/function/theme/6" title="theme | Drupal API">theme()</a> sur un hook <code>mytheme_simple_iframe</code> qui n&#8217;existe pas.</p>

<h2>Création d&#8217;un hook de thème</h2>

<p>La création d&#8217;un hook permettant de faire appel à un fichier template est des plus simple, grâce au <a href="http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_theme/6" title="hook_theme | Drupal API">hook_theme</a>. Définissez dans votre fichier <code>template.php</code> (ou dans un fichier de module) le hook <code>mytheme_simple_iframe</code>&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * template.php
 */</span>
<span style="color: #009933; font-style: italic;">/**
 * @implements hook_theme()
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> mytheme_theme<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'mytheme_simple_iframe'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
        <span style="color: #0000ff;">'template'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'simple_iframe'</span><span style="color: #339933;">,</span>
        <span style="color: #0000ff;">'arguments'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
            <span style="color: #0000ff;">'url'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'width'</span>  <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'700'</span><span style="color: #339933;">,</span>
            <span style="color: #0000ff;">'height'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'500'</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
      <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Simple de compréhension, on déclare un fichier de template <code>simple_iframe</code> auquel 3 variables seront passées. Les arguments <code>width</code> et <code>height</code> ont une valeur par défaut de précisée, ce qui permet de les omettre dans la définition de la ressource externe dans le hook_menu.</p>

<p>Enfin, créez le fichier de template qui affichera une iframe.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * simple_iframe.tpl.php
 */</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div class=&quot;iframe&quot;&gt;
  &lt;iframe src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$url</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; width=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$width</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; height=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$height</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; frameborder=&quot;0&quot; align=&quot;left&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;</pre></td></tr></table></div>


<p>Désormais, tout accès à l&#8217;URL <code>/drupal/page/path</code> chargera le template <code>simple_iframe.tpl.php</code> lorsque <strong>Drupal</strong> effectuera le rendu de la variable <code>$content</code> du fichier <code>page.tpl.php</code>.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li><li><a href='http://pioupioum.fr/snippets/apache-rotation-logs.html' title='Rotation des logs Apache'>Rotation des logs Apache</a></li><li><a href='http://pioupioum.fr/developpement/git-alias-productivite.html' title='Git : des alias pour aller plus vite'>Git&#160;: des alias pour aller plus vite</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>où <code>my_hook</code> correspond au nom du thème ou du module qui sert à enregistrer ces définitions.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/drupal-iframe-page.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Optimiser le chargement des AdSense</title>
		<link>http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html</link>
		<comments>http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html#comments</comments>
		<pubDate>Thu, 11 Mar 2010 16:48:57 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[optimiser]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=357</guid>
		<description><![CDATA[Il n&#8217;y a rien de plus horripilant que d&#8217;attendre que des publicités chargent pour accéder au contenu d&#8217;un article. C&#8217;est malheureusement une situation que l&#8217;on rencontre fréquemment. La faute en incombe au fonctionnement des blocs AdSense des publicitaires.

En effet, ils nécessitent que nous insérerions le code correspondant à un bloc à l&#8217;endroit où il sera [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Il n&#8217;y a rien de plus horripilant que d&#8217;attendre que des publicités chargent pour accéder au contenu d&#8217;un article. C&#8217;est malheureusement une situation que l&#8217;on rencontre fréquemment. La faute en incombe au fonctionnement des blocs <strong>AdSense</strong> des publicitaires.</p>

<p>En effet, ils nécessitent que nous insérerions le code correspondant à un bloc à l&#8217;endroit où il sera affiché. Cela pour deux raisons notamment&#160;:</p>

<ol>
<li>Des variables globales identifiants l&#8217;annonce sont déclarées.</li>
<li>Le script qui va charger l&#8217;annonce est immédiatement exécuté et fait appel à des actions d&#8217;écriture dans le flux <em>via</em> <a href="https://developer.mozilla.org/fr/DOM/document.write">write</a>.</li>
</ol>

<p>Le deuxième point oblige le navigateur à traiter le code de l&#8217;adsense dès qu&#8217;il le rencontre puisque ce dernier n&#8217;utilise pas de gestionnaire de chargement. En plus d&#8217;écrire dans le flux courant, le système du publicitaire va charger des éléments extérieurs. Pour peu que la latence des réponses soit élevée, l&#8217;impression de <strong>ralentissement du chargement de la page</strong> augmente.</p>

<p>S&#8217;est ainsi que si un article est précédé d&#8217;un encart publicitaire, l&#8217;utilisateur devra patiemment attendre le chargement de ce dernier avant de pouvoir accéder au contenu désiré.<br />
L&#8217;expérience utilisateur s&#8217;en trouve dégradée.</p>

<h2>En finir avec les ralentissements de chargement des pages</h2>

<p>Vous l&#8217;aurez peut-être remarqué, mais sur <a href="http://pioupioum.fr/" title="piouPiouM&#8217;s dev : bloc-note d&#8217;un développeur web. PHP, git, shell, plugins WordPress, SPIP, jQuery">piouPiouM&#8217;s dev</a>, le <strong>chargement des blocs publicitaires</strong> est comme <strong>temporisé</strong>, ne gênant ainsi en rien la navigation sur le site.<br />
Voyons dans la suite du billet comment y parvenir, en prenant pour exemple le service <a href="https://www.google.com/adsense/">Google Adsense</a>.
<span id="more-357"></span></p>

<h2 id="integration-maquette">Intégration dans une maquette</h2>

<p>On commence par définir les emplacements des encarts publicitaires. Cela vous permet ainsi d&#8217;intégrer les annonces dans vos maquettes <abbr title="Hyper Text Markup Language">HTML</abbr>, tout en vous assurant que cette apparence sera conservée pour les utilisateurs n&#8217;ayant pas JavaScript d&#8217;activé, ou qui bloquent les annonces publicitaires.<br />
Je prend ici le parti d&#8217;annoncer la couleur, en précisant la mention <em>Publicité</em>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;ads-[ads_id]&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;ads [ads_format]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    Publicité
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>


<p>En sommes, il s&#8217;agit d&#8217;un simple élément <code>&lt;div&gt;</code> ayant pour attributs&#160;:</p>

<ul>
<li>un identifiant <strong>[ads_id]</strong>&#160;: un identifiant unique qui va servir de point d&#8217;ancrage au contenu de l&#8217;adsense. Vous pouvez par exemple, dans le cas de Google Adsense, utiliser le nom du critère personnalisé en notation CamelCase.</li>
<li>une classe <strong>ads</strong>&#160;: le style des encarts de pub lorsque celles-ci sont en attente de chargement.</li>
<li>une classe <strong>[ads_format]</strong>&#160;: le format de l&#8217;encart publicitaire. Par exemple, <code>square250</code> pour une annonce de 250px de côtés ou encore <code>banner468</code> pour une bannière au format 468 x 60.</li>
</ul>

<p>Appliquez les styles <abbr title="Cascading Style Sheets">CSS</abbr> qui suivent.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* @group Tools */</span>
&nbsp;
<span style="color: #6666ff;">.hide</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* @end   Tools */</span>
<span style="color: #808080; font-style: italic;">/* @group Adsense */</span>
&nbsp;
<span style="color: #6666ff;">.ads</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#F4F4F4</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#666666</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">11px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">text-transform</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">uppercase</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.square250</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.banner468</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">60px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">468px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* @end   Adsense */</span></pre></td></tr></table></div>


<h2 id="ads-code-annonceur">Insertion du code de l&#8217;annonceur</h2>

<p>Insérez en fin de page les différents codes donnés par votre annonceur (ici, Google Adsense).</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;hide&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #808080; font-style: italic;">&lt;!-- Ads --&gt;</span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;adsref-[ads_id]&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
google_ad_client = &quot;pub-[client_id]&quot;;
google_ad_slot   = &quot;[slot_id]&quot;;
google_ad_width  = 250;
google_ad_height = 250;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>


<p><strong>Chaque annonce</strong> est incluse dans un élément ayant pour identifiant <code>adsref-[ads_id]</code> (voir <a href="#integration-maquette">Intégration de la maquette</a>) qui fait le lien avec l&#8217;emplacement final de la publicité.</p>

<p>Le tout étant masqué à l&#8217;aide d&#8217;un <code>div.hide</code>. Il serait en effet désagréable d&#8217;afficher les annonces publicitaires en bas de page, même si ce n&#8217;est que pour une poignée de [micro]secondes.</p>

<h2 id="jquery-ads-loader">Un Adsense Loader avec jQuery</h2>

<p>Il ne reste plus qu&#8217;à déplacer à l&#8217;aide de JavaScript les blocs AdSense aux endroits souhaités. Avec <a href="http://pioupioum.fr/tag/jquery/" title="Archives pour le tag jQuery – piouPiouM&#039;s dev">jQuery</a> cela donne&#160;:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> $ads<span style="color: #339933;">;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div[id^=&quot;adsref-&quot;]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>          <span style="color: #006600; font-style: italic;">// pour chaque bloc d'annonce #adsref-[ads_id]</span>
        $ads <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#ads-'</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span>.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">7</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// supprimer de #ads-[ads_id] tout éventuel contenu</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ins:first'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span>$ads<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>           <span style="color: #006600; font-style: italic;">// déplacer l'annonce dans #ads-[ads_id]</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>Bien évidemment, et comme vous êtes sensible aux bonnes pratiques liées à la <a href="http://performance.survol.fr/" title="Performance web">performance web</a>, vous insérerez naturellement ce code en fin de page <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/javascript-array-intersection.html' title='JavaScript : optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles'>JavaScript&#160;: optimiser le calcul de l&#8217;intersection de tableaux de grandes tailles</a></li><li><a href='http://pioupioum.fr/outils-astuces/facebook-application-add-page-tab-bookmarklet.html' title='Bookmarklet : ajout rapide d&#8217;application onglet à vos pages fan Facebook'>Bookmarklet&#160;: ajout rapide d&#8217;application onglet à vos pages fan Facebook</a></li><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li><li><a href='http://pioupioum.fr/developpement/drupal-iframe-page.html' title='Drupal 6 : utiliser une iframe comme contenu de page'>Drupal 6&#160;: utiliser une iframe comme contenu de page</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-forcer-chargement-jquery-footer.html' title='WordPress : forcer le chargement de jQuery en bas de page'>WordPress&#160;: forcer le chargement de jQuery en bas de page</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</title>
		<link>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html</link>
		<comments>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html#comments</comments>
		<pubDate>Tue, 09 Feb 2010 14:50:30 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[media]]></category>
		<category><![CDATA[upload]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=316</guid>
		<description><![CDATA[WordPress ne supporte en upload qu&#8217;une liste exhaustive de formats de fichiers. Si comme moi vous souhaitez uploader1 des fichiers issus de TextMate, comme les .tmCommand et autres .tmSnippet, ajoutez le code qui suit dans le fichier functions.php de votre thème2.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
&#60;?php
// Add the new filter
add_filter&#40;'upload_mimes', 'addUploadMimes'&#41;;
&#160;
/**
 * Adds new supported media types for upload.
 *
 [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>WordPress ne supporte en upload qu&#8217;une liste exhaustive de formats de fichiers. Si comme moi vous souhaitez uploader<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup> des fichiers issus de <a href="http://macromates.com/" title="TextMate — The Missing Editor for Mac OS X">TextMate</a>, comme les <code>.tmCommand</code> et autres <code>.tmSnippet</code>, ajoutez le code qui suit dans le fichier <code>functions.php</code> de votre thème<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// Add the new filter</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'upload_mimes'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'addUploadMimes'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Adds new supported media types for upload.
 *
 * @see wp_check_filetype() or get_allowed_mime_types()
 * @param array $mimes Array of mime types keyed by the file extension regex corresponding to those types.
 * @return array
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> addUploadMimes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$mimes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mimes</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">'tmbundle|tmCommand|tmDragCommand|tmSnippet|tmLanguage|tmPreferences'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'application/octet-stream'</span>
	<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$mimes</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>


<p>Indiquez en clé les nouvelles extensions de fichier (séparées par des <em>pipes</em>) et en valeur le type mime associé.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/outils-astuces/wordpress-shortcode-afficher-fichiers-joints.html' title='Shortcode WordPress : afficher les documents liés aux billets'>Shortcode WordPress&#160;: afficher les documents liés aux billets</a></li><li><a href='http://pioupioum.fr/outils-astuces/wordpress-recuperation-avancee-images-article.html' title='WordPress : récupération avancée des images d&#8217;un article'>WordPress&#160;: récupération avancée des images d&#8217;un article</a></li><li><a href='http://pioupioum.fr/outils-astuces/afficher-images-article-page-media.html' title='WordPress : lister les images d&#8217;un article sur une page media'>WordPress&#160;: lister les images d&#8217;un article sur une page media</a></li><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li><li><a href='http://pioupioum.fr/developpement/drupal-iframe-page.html' title='Drupal 6 : utiliser une iframe comme contenu de page'>Drupal 6&#160;: utiliser une iframe comme contenu de page</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>sous Mac OS X tout du moins, <a href="http://swfupload.org/" title="SWFUpload News | SWFUpload">SWFUpload</a> me désactive la sélection des fichiers de TextMate m&#8217;obligeant à passer par l&#8217;interface d&#8217;upload native du navigateur. Je suis preneur de toute solution.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>à choisir, l&#8217;ajouter dans un plugin serait plus judicieux puisque cette fonctionnalité ne dépend pas du thème.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rotation des logs Apache</title>
		<link>http://pioupioum.fr/snippets/apache-rotation-logs.html</link>
		<comments>http://pioupioum.fr/snippets/apache-rotation-logs.html#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:14:46 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Snippets]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=306</guid>
		<description><![CDATA[Effectuer une rotation de ses logs Apache chaque semaine à l&#8217;aide de rotatelogs&#160;:

CustomLog "&#124;/usr/sbin/rotatelogs /var/log/www/mondomaine.tld/mondomaine.tld-access_log 604800" "combined"


Notez le pipe au début d&#8217;argument qui permet la redirection du logfile vers rotatelogs.
Merci à patpro pour l&#8217;astuce.

Continuez votre lecture sur des sujets similaires

Compass&#160;: supprimer le cache buster des spritesDrupal 6&#160;: utiliser une iframe comme contenu de pageInstances multiples [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Effectuer une <strong>rotation de ses logs Apache</strong> chaque semaine à l&#8217;aide de <strong><a href="http://httpd.apache.org/docs/2.0/programs/rotatelogs.html" title="rotatelogs - Piped logging program to rotate Apache logs - Apache HTTP Server">rotatelogs</a></strong>&#160;:</p>

<pre><code>CustomLog "|/usr/sbin/rotatelogs /var/log/www/mondomaine.tld/mondomaine.tld-access_log 604800" "combined"
</code></pre>

<p>Notez le <em>pipe</em> au début d&#8217;argument qui permet la redirection du logfile vers rotatelogs.<br />
Merci à <a href="http://www.patpro.net/" title="Je pensais qu'il était avec vous... | patpro.net">patpro</a> pour l&#8217;astuce.</p>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li><li><a href='http://pioupioum.fr/developpement/drupal-iframe-page.html' title='Drupal 6 : utiliser une iframe comme contenu de page'>Drupal 6&#160;: utiliser une iframe comme contenu de page</a></li><li><a href='http://pioupioum.fr/developpement/compass-rvm-multiple-instances.html' title='Instances multiples de Compass avec Ruby Version Manager (rvm)'>Instances multiples de Compass avec Ruby Version Manager (rvm)</a></li><li><a href='http://pioupioum.fr/snippets/php-installer-apc-macosx.html' title='PHP : installer APC sous Mac OS X Leopard'>PHP&#160;: installer APC sous Mac OS X Leopard</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/snippets/apache-rotation-logs.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git&#160;: des alias pour aller plus vite</title>
		<link>http://pioupioum.fr/developpement/git-alias-productivite.html</link>
		<comments>http://pioupioum.fr/developpement/git-alias-productivite.html#comments</comments>
		<pubDate>Wed, 30 Dec 2009 09:18:24 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[cheat sheets]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[productivité]]></category>
		<category><![CDATA[scm]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=295</guid>
		<description><![CDATA[Les alias sont des raccourcis vers des commandes de Git. Fini les répétitions et autres saisies de commandes rébarbatives&#160;! Pour ajouter de nouveaux alias, créez ou éditez la section [alias] de l&#8217;un des fichiers qui suivent (voir les exemples du billet pour avoir une information sur la syntaxe)&#160;:


~/.gitconfig pour en bénéficier dans tous vos dépôts.
.git/config [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Les <strong>alias</strong> sont des <strong>raccourcis</strong> vers des commandes de <strong>Git</strong>. Fini les répétitions et autres saisies de commandes rébarbatives&#160;! Pour ajouter de nouveaux alias, créez ou éditez la section <code>[alias]</code> de l&#8217;un des fichiers qui suivent (voir les exemples du billet pour avoir une information sur la syntaxe)&#160;:</p>

<ul>
<li><code>~/.gitconfig</code> pour en bénéficier dans tous vos dépôts.</li>
<li><code>.git/config</code> d&#8217;un projet pour restreindre son accès à cet unique projet.</li>
</ul>

<p>Il est également possible de recourir à la commande <a href="http://www.kernel.org/pub/software/scm/git/docs/git-config.html" title="git-config(1) Manual Page">git config</a>&#160;:</p>

<pre><code>$ git config --global alias.st 'status'
</code></pre>

<p>Ici, la commande <code>git st</code> devient un alias de <a href="http://www.kernel.org/pub/software/scm/git/docs/git-status.html" title="git-status(1) Manual Page">git status</a>.</p>

<p><strong>Note&#160;:</strong> supprimer le flag <code>--global</code> va ajouter l&#8217;alias dans le scope du projet courant.
<span id="more-295"></span></p>

<h2 id="toc">Table des matières</h2>

<ol>
<li><a href="#mes-alias">Mes alias</a></li>
<li><a href="#alias-utilisateurs-svn">Des raccourcis pour les utilisateurs de SVN</a></li>
<li><a href="#annuler-dernier-commit">Annuler le dernier commit</a></li>
<li><a href="#editer-dernier-commit">Éditer le dernier commit</a></li>
<li><a href="#speed-diff">Faire le point rapidement</a></li>
<li><a href="#historique-sexy">Afficher un historique condensé des commits</a></li>
<li><a href="#derniers-changements-pull">Afficher les changements réalisés depuis le dernier pull</a></li>
<li><a href="#ajouter-rapidement-commit">Ajouter rapidement des fichiers à commiter</a></li>
<li><a href="#ouvrir-dans-textmate">Ouvrir dans TextMate les fichiers non commités</a></li>
</ol>

<h2 id="mes-alias">Mes alias</h2>

<p>Voici les alias que j&#8217;utilise dans le scope global, en provenance donc de mon fichier <code>~/.gitconfig</code>&#160;:</p>

<pre><code>[alias]
    amend = commit --amend
    st = status
    who = shortlog -sne
    oneline = log --pretty=oneline --abbrev-commit --graph
    changes = diff --name-status
    dic = diff --cached
    diffstat = diff --stat
    svnpull = svn rebase
    svnpush = svn dcommit
    lc = !git oneline ORIG_HEAD.. --stat --no-merges
    addm = !git-ls-files -m -z | xargs -0 git-add &amp;&amp; git status
    addu = !git-ls-files -o --exclude-standard -z | xargs -0 git-add &amp;&amp; git status
    rmm = !git ls-files -d -z | xargs -0 git-rm &amp;&amp; git status
    mate = !git-ls-files -m -z | xargs -0 mate
    mateall = !git-ls-files -m -o --exclude-standard -z | xargs -0 mate
</code></pre>

<h2 id="alias-utilisateurs-svn">Des raccourcis pour les utilisateurs de SVN</h2>

<pre><code>[alias]
    st = status
    df = diff
    co = checkout
    ci = commit
    br = branch
    svnpull = svn rebase
    svnpush = svn dcommit
</code></pre>

<p><strong>Attention&#160;:</strong> la commande <a href="http://www.kernel.org/pub/software/scm/git/docs/git-checkout.html" title="git-checkout(1) Manual Page">git checkout</a> n&#8217;a pas la même utilité dans Git que dans Subversion&#160;!</p>

<h2 id="annuler-dernier-commit">Annuler le dernier commit</h2>

<p>Le flag <code>--soft</code> va conserver les modifications dans le répertoire de travail.</p>

<pre><code>[alias]
    undo = git reset --soft HEAD^
</code></pre>

<p><strong>Important&#160;:</strong> nous travaillons ici en local. Il est malvenu d&#8217;annuler un commit sur le dépôt distant (désynchro, arbre cassé, etc). On assume ses erreurs <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<h2 id="editer-dernier-commit">Éditer le dernier commit</h2>

<pre><code>[alias]
    amend = commit --amend
</code></pre>

<h2 id="speed-diff">Faire le point rapidement</h2>

<pre><code>[alias]
    changes = diff --name-status
    dic = diff --cached
    diffstat = diff --stat
</code></pre>

<h2 id="historique-sexy">Afficher un historique condensé des commits</h2>

<pre><code>[alias]
    oneline = log --pretty=oneline --abbrev-commit --graph --decorate
</code></pre>

<h2 id="derniers-changements-pull">Afficher les changements réalisés depuis le dernier pull</h2>

<pre><code>[alias]
    lc = !git oneline ORIG_HEAD.. --stat --no-merges
</code></pre>

<h2 id="ajouter-rapidement-commit">Ajouter rapidement des fichiers à commiter</h2>

<p>Les alias qui suivent vont lister les fichiers d&#8217;un certain type pour les ajouter à l&#8217;index avant commit. J&#8217;affiche ensuite l&#8217;état du projet pour valider qu&#8217;aucune erreur ne s&#8217;est produite.</p>

<p>On peut donc chaîner les commandes à condition de préfixer l&#8217;alias par un point d&#8217;exclamation&nbsp;<code>!</code>.</p>

<pre><code>[alias]
    addm = !git-ls-files -m -z | xargs -0 git-add &amp;&amp; git status                     # ajouter les fichiers modifiés.
    addu = !git-ls-files -o --exclude-standard -z | xargs -0 git-add &amp;&amp; git status  # ajouter les fichiers inconnus.
    rmm  = !git ls-files -d -z | xargs -0 git-rm &amp;&amp; git status                      # supprimer les fichiers marqués
                                                                                    # comme effacés.
</code></pre>

<h2 id="ouvrir-dans-textmate">Ouvrir dans TextMate les fichiers non commités</h2>

<p>Pratique pour reprendre son travail là où l&#8217;avait arrêté (poke <a href="http://jeremy.wordpress.com/2009/12/01/ouvrir-tous-les-fichiers-modifies-git/" title="Ouvrir tous les fichiers modifiés (git) &laquo;  Jérémy Lecour">Jérémy Lecour</a>), <code>git mate</code> permet d&#8217;ouvrir dans <a href="http://macromates.com/" title="TextMate — The Missing Editor for Mac OS X">mon éditeur de code préféré</a> les fichiers modifiés depuis le dernier commit.<br />
L&#8217;alias <code>git mateall</code> tiendra compte des fichiers inconnus de l&#8217;index du projet.</p>

<pre><code>[alias]
    mate = !git-ls-files -m -z | xargs -0 mate
    mateall = !git-ls-files -m -o --exclude-standard -z | xargs -0 mate
</code></pre>

<div class="updated">

<h5>Mises à jour</h5>

<ul>
<li>
<strong>2 juin 2010</strong><br />
Mise à jour des alias d&#8217;<a href="#ajouter-rapidement-commit">ajout rapide de fichiers à commiter</a> et d&#8217;<a href="#ouvrir-dans-textmate">édition dans TextMate</a>. Les chemins contenant des espaces provoquaient une erreur fatale.</li>
<li>
<strong>29 novembre 2010</strong><br />
Ajout de l&#8217;argument <code>--decorate</code> à l&#8217;alias <a href="#historique-sexy">oneline</a> soufflé par <a href="http://twitter.com/#!/n1k0/status/9239169213665281">n1k0</a> <em>via</em> <a href="http://blog.kfish.org/2010/04/git-lola.html">git lola</a>.</li>
</ul>

</div>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/git-10-commandes-utiles.html' title='Git : 10 commandes utiles'>Git&#160;: 10 commandes utiles</a></li><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li><li><a href='http://pioupioum.fr/developpement/drupal-iframe-page.html' title='Drupal 6 : utiliser une iframe comme contenu de page'>Drupal 6&#160;: utiliser une iframe comme contenu de page</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li></ul>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/git-alias-productivite.html/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Git&#160;: 10 commandes utiles</title>
		<link>http://pioupioum.fr/developpement/git-10-commandes-utiles.html</link>
		<comments>http://pioupioum.fr/developpement/git-10-commandes-utiles.html#comments</comments>
		<pubDate>Wed, 23 Dec 2009 09:36:46 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[astuces]]></category>
		<category><![CDATA[cheat sheets]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[scm]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=285</guid>
		<description><![CDATA[Cela fait plus d&#8217;un an et demi que j&#8217;utilise Git dans mes environnements de travail personnel et professionnel. Jamais je ne l&#8217;échangerai contre SVN&#160;! Oups, je m&#8217;égare  

Git c&#8217;est bien, mais encore faut-il retenir son nombre croissant de commandes pour l&#8217;utiliser au mieux. Ce billet va être le premier d&#8217;une série qui va m&#8217;aider [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Cela fait plus d&#8217;un an et demi que j&#8217;utilise <a href="http://git-scm.com/" title="Git - Fast Version Control System">Git</a> dans mes environnements de travail personnel et professionnel. Jamais je ne l&#8217;échangerai contre <a href="http://subversion.tigris.org/" title="subversion.tigris.org">SVN</a>&#160;! Oups, je m&#8217;égare <img src='http://pioupioum.fr/wp/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<p><strong>Git c&#8217;est bien</strong>, mais encore faut-il retenir son nombre croissant de commandes pour l&#8217;utiliser au mieux. Ce billet va être le premier d&#8217;une série qui va m&#8217;aider à mettre sur &#8220;papier&#8221; les commandes qui me sont le plus utiles.<span id="more-285"></span></p>

<h2 id="toc">Liste des commandes utiles</h2>

<ol>
<li><a href="#editer-commentaire-dernier-commit">Éditer le commentaire du dernier commit</a></li>
<li><a href="#supprimer-branche-serveur">Supprimer une branche distante</a></li>
<li><a href="#supprimer-tag-serveur">Supprimer un tag du repository distant</a></li>
<li><a href="#compter-commit-utilisateur">Compter le nombre de commits par utilisateur</a></li>
<li><a href="#commit-autre-identite">Commiter sous une autre identité</a></li>
<li><a href="#antidater-commit">Antidater un commit</a></li>
<li><a href="#abandonner-suivi-fichiers">Abandonner le suivi de fichiers</a></li>
<li><a href="#copier-untracked-files-hors-reposity">Copier les fichiers inconnus de Git en dehors du répertoire de travail</a></li>
<li><a href="#supprimer-fichiers-non-suivis">Supprimer les fichiers inconnus de Git</a></li>
<li><a href="#exporter-archive-zip-tar-gz">Exporter son projet dans une archive ZIP ou TAR.GZ</a></li>
</ol>

<h2 id="editer-commentaire-dernier-commit">Éditer le commentaire du dernier commit</h2>

<p>Une commande qui se passe d&#8217;explications.</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git commit <span style="color: #660033;">--amend</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Le nouveau commentaire.&quot;</span></pre></div></div>


<p><strong>Edit&#160;:</strong><br />
Comme le précise <a href="http://jeremy.wordpress.com/">Jérémy</a> dans les commentaires, cette commande n&#8217;est à utiliser que sur un commit qui n&#8217;a pas été diffusé sur un autre repository. Autrement, cela casserait l&#8217;historique et des divergences peuvent apparaître.</p>

<h2 id="supprimer-branche-serveur">Supprimer une branche distante</h2>

<p>Effacer une branche du dépôt distant s&#8217;effectue de la même manière que si vous la publiez à l&#8217;aide de la commande <code>git push</code>, mais en précédant le nom de la branche d&#8217;un double point.</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git push origin :ma_branche</pre></div></div>


<h2 id="supprimer-tag-serveur">Supprimer un tag du repository distant</h2>

<p>La commande <code>git push --tags</code> ne pousse pas les tags supprimés localement. Afin de supprimer un tag sur le serveur distant, il faut reprendre la syntaxe de suppression d&#8217;une branche&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git push origin :my_tag</pre></div></div>


<p>Il est également possible d&#8217;utiliser la commande <a href="http://www.kernel.org/pub/software/scm/git/docs/git-tag.html" title="git-tag(1) Manual Page">git tag</a> et son flag <code>-d</code>&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git tag <span style="color: #660033;">-d</span> my_tag</pre></div></div>


<h2 id="compter-commit-utilisateur">Compter le nombre de commits par utilisateur</h2>

<p>Avec <a href="http://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html" title="git-shortlog(1) Manual Page">git shortlog</a> et ses flags <code>-n</code> et <code>-s</code> on obtient la sortie suivante pour le dépôt du <a href="http://www.pluf.org/" title="Pluf : Pluf, PHP WebApp Framework">framework PHP Pluf</a>&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">git shortlog <span style="color: #660033;">-sn</span>
   <span style="color: #000000;">163</span>  Loic d<span style="color: #ff0000;">'Anterroches
     4  Jürgen Hörmann
     2  Mehdi Kabab
     1  Baptiste Durand-Bret
     1  Jakub Vitak</span></pre></div></div>


<p>Ajoutez l&#8217;option <code>-e</code> pour afficher les adresses e-mails.</p>

<h2 id="commit-autre-identite">Commiter sous une autre identité</h2>

<p>Un contributeur vous a envoyé un patch et vous souhaitez lui attribuer le commit<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>&#160;? Le flag <code>--author</code> est là pour ça&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git commit <span style="color: #660033;">--author</span> <span style="color: #ff0000;">&quot;Prénom Nom &lt;email@address.com&gt;&quot;</span></pre></div></div>


<h2 id="antidater-commit">Antidater un commit</h2>

<p>Très pratique pour maintenir à jour son historique de commits, la définition de la variable <code>GIT_AUTHOR_DATE</code> permet de préciser la date et heure du commit.</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #007800;">GIT_AUTHOR_DATE</span>=<span style="color: #ff0000;">&quot;2009-11-26 08:32 +100&quot;</span> git commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Un commit antidaté.&quot;</span></pre></div></div>


<h2 id="abandonner-suivi-fichiers">Abandonner le suivi de fichiers</h2>

<p>Lors d&#8217;une phase de débogage, il est généralement peu utile de suivre les modifications de certains fichiers. La commande <a href="http://www.kernel.org/pub//software/scm/git/docs/git-update-index.html" title="git-update-index(1) Manual Page">git update-index</a> et son flag <code>--assume-unchanged</code> va permettre d&#8217;ignorer les changements du ou des fichiers précisés.</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git update-index <span style="color: #660033;">--assume-unchanged</span> README.md</pre></div></div>


<p>Pour revenir à la normale, utilisez le flag <code>--no-assume-unchanged</code>&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git update-index <span style="color: #660033;">--no-assume-unchanged</span> README.md</pre></div></div>


<h2 id="copier-untracked-files-hors-reposity">Copier les fichiers inconnus de Git en dehors du répertoire de travail</h2>

<p>Sous Mac <abbr title="Operating System">OS</abbr> X<sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup> la commande est&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git ls-files <span style="color: #660033;">--others</span> <span style="color: #660033;">--exclude-standard</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cpio</span> <span style="color: #660033;">-pmd</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>de<span style="color: #000000; font-weight: bold;">/</span>destination</pre></div></div>


<p>Retirez l&#8217;option <code>--exclude-standard</code> si vous désirez exporter les fichiers ignorés par Git.</p>

<h2 id="supprimer-fichiers-inconnus">Supprimer les fichiers inconnus de Git</h2>

<p>Il m&#8217;arrive de créer des fichiers qui ne seront finalement pas ajoutés à l&#8217;index de ma copie locale. Ces fichiers apparaissent donc inlassablement dans la liste des fichiers <em>untracked</em>. Au lieu de les supprimer manuellement, je charge Git de le faire&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git clean <span style="color: #660033;">-n</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">&lt;</span>path<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>


<p>Ici, la commande <a href="http://www.kernel.org/pub/software/scm/git/docs/git-clean.html" title="git-clean(1) Manual Page">git clean</a> ne va rien supprimer. En effet, le flag <code>-n</code> réalise un <strong>dry run</strong> pour lister les fichiers et répertoires concernés par le nettoyage du répertoire de travail, ou du chemin <code>&lt;path&gt;</code> si ce dernier est précisé.</p>

<p>Si vous souhaitez supprimer uniquement les fichiers et conserver les répertoires vides, enlevez l&#8217;option <code>-d</code>.</p>

<p>Ajoutez le flag <code>-x</code> pour inclure les fichiers ignorés par Git (cf. le fichier .gitignore). Pour ne supprimer que les fichiers ignorés, optez pour l&#8217;option <code>-X</code>.</p>

<p>Dernière astuce, tant que l&#8217;option <code>clean.requireForce</code> n&#8217;est pas définie à <code>false</code> dans votre fichier de configuration, Git contraindra <code>git clean</code> à ne fonctionner qu&#8217;avec les flags <code>-n</code> et <code>-f</code>. Autrement dit, soit vous réalisez un test <em>dry run</em>, soit vous forcez l&#8217;action du nettoyage de votre arbre de travail. Et c&#8217;est une bonne chose, personne n&#8217;est à l&#8217;abri d&#8217;une erreur&#160;!</p>

<h2 id="exporter-archive-zip-tar-gz">Exporter son projet dans une archive ZIP ou TAR.GZ</h2>

<p>Si vous souhaitez fournir une archive d&#8217;une version précise de votre projet, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-archive.html" title="git-archive(1) Manual Page">git archive</a> va pouvoir vous aider. En considérant que la version visée est marquée par le tag 1.0&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git archive <span style="color: #660033;">--format</span>=<span style="color: #c20cb9; font-weight: bold;">zip</span> <span style="color: #660033;">--prefix</span>=mon_projet-<span style="color: #000000;">1.0</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-9</span> <span style="color: #000000;">1.0</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>de<span style="color: #000000; font-weight: bold;">/</span>destination<span style="color: #000000; font-weight: bold;">/</span>mon-projet-1.0.zip</pre></div></div>


<p>Détail sur les options&#160;:</p>

<ul>
<li><code>--format</code> pour spécifier le format de l&#8217;archive. <code>git archive --list</code> pour connaître la liste des formats supportés.</li>
<li><code>--prefix</code> va préfixer tous les noms de fichiers et dossiers. <strong>N&#8217;oubliez pas le slash terminal</strong> si vous souhaitez regrouper les documents dans un dossier.</li>
<li><code>-9</code> est une option spécifique du format d&#8217;exportation ZIP. De 0 à 9, il détermine le niveau de compression.</li>
<li><code>1.0</code> est le nom du tag. Vous pouvez également exporter des branches, le HEAD et autres <em>tree-ish</em>.</li>
<li>pour finir on redirige le tout dans un fichier.</li>
</ul>

<p>Pour exporter les fichiers contenu dans le répertoire d&#8217;une branche donnée la commande devient&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git archive <span style="color: #660033;">--format</span>=<span style="color: #c20cb9; font-weight: bold;">zip</span> <span style="color: #660033;">--prefix</span>=mon_projet-dev<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-9</span> dev:src<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>de<span style="color: #000000; font-weight: bold;">/</span>destination<span style="color: #000000; font-weight: bold;">/</span>mon_projet-dev.zip</pre></div></div>


<p>Enfin, l&#8217;export au format TAR.GZ se fait de la manière suivante&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git archive <span style="color: #660033;">--format</span>=<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--prefix</span>=mon_projet-<span style="color: #000000;">1.0</span><span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000;">1.0</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>chemin<span style="color: #000000; font-weight: bold;">/</span>de<span style="color: #000000; font-weight: bold;">/</span>destination<span style="color: #000000; font-weight: bold;">/</span>mon-projet-1.0.tar.gz</pre></div></div>


<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/developpement/git-alias-productivite.html' title='Git : des alias pour aller plus vite'>Git&#160;: des alias pour aller plus vite</a></li><li><a href='http://pioupioum.fr/developpement/compass-sprites-supprimer-cache-buster.html' title='Compass : supprimer le cache buster des sprites'>Compass&#160;: supprimer le cache buster des sprites</a></li><li><a href='http://pioupioum.fr/developpement/drupal-iframe-page.html' title='Drupal 6 : utiliser une iframe comme contenu de page'>Drupal 6&#160;: utiliser une iframe comme contenu de page</a></li><li><a href='http://pioupioum.fr/developpement/optimiser-rapidite-chargement-adsense-jquery.html' title='Optimiser le chargement des AdSense'>Optimiser le chargement des AdSense</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-autoriser-upload-media-format-inconnu.html' title='WordPress : autoriser l&#8217;upload de fichiers au format non-supporté'>WordPress&#160;: autoriser l&#8217;upload de fichiers au format non-supporté</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>une bonne pratique a encourager&#160;!&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>si la commande <code>cpio</code> fonctionne différemment sur d&#8217;autres <abbr title="Operating System">OS</abbr>, merci de me le signaler en commentaire. Je mettrai à jour en conséquence le snippet.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/git-10-commandes-utiles.html/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

