scratch/output/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/index.html
Yann Esposito 70314df976 Recompiled
2012-05-02 17:43:56 +02:00

275 lines
No EOL
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="blog">
<link rel="shortcut icon" type="image/x-icon" href="/Scratch/img/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/Scratch/assets/css/main.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/solarized.css" />
<link rel="stylesheet" type="text/css" href="/Scratch/css/idc.css" />
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://feeds.feedburner.com/yannespositocomfr"/>
<link rel="alternate" lang="fr" xml:lang="fr" title="Maintenant sur Heroku" type="text/html" hreflang="fr" href="/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/" />
<link rel="alternate" lang="en" xml:lang="en" title="Now hosted by heroku" type="text/html" hreflang="en" href="/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/" />
<script type="text/javascript" src="/Scratch/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="/Scratch/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/Scratch/js/index.js"></script>
<script type="text/javascript" src="/Scratch/js/highlight/highlight.pack.js"></script>
<script type="text/javascript" src="/Scratch/js/article.js"></script>
<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->
<title>Maintenant sur Heroku</title>
</head>
<body lang="fr" class="article">
<script type="text/javascript">// <![CDATA[
document.write('<div id="blackpage"><img src="/Scratch/img/loading.gif" alt="Chargement en cours..."/></div>');
// ]]>
</script>
<div id="content">
<div id="choix">
<div class="return"><a href="#entete">&darr; Menu &darr;</a></div>
<div id="choixlang">
<a href="/Scratch/en/blog/2010-08-23-Now-heberged-on-heroku/" onclick="setLanguage('en')">in English</a>
</div>
<div class="flush"></div>
</div>
<div id="titre">
<h1>
Maintenant sur Heroku
</h1>
<h2>
Héberger un site web statique sur heroku
</h2>
</div>
<div class="flush"></div>
<div class="flush"></div>
<div id="afterheader">
<div class="corps">
<h1 class="first" id="maintenant-sur-herokuhttpherokucom">Maintenant sur <a href="http://heroku.com">Heroku</a></h1>
<p>Jai changé mon hébergeur. Mobileme nest absolument pas adapté à la diffusion de mon blog. Cest pourquoi je suis passé à <a href="http://heroku.com">Heroku</a>.</p>
<p>Mais comme vous devez le savoir mon blog est un site complètement statique.
Jutilise <a href="http://nanoc.stoneship.org/">nanoc</a> pour lengendrer.
Avoir un site statique amène beaucoup davantages par rapport à un site dynamique. Surtout en terme de sécurité.
Voici comment configurer un site statique sur heroku.</p>
<p>La racine de mes fichiers est /output. Vous devez simplement créer deux fichiers. Un fichier <code>config.ru</code><sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>&nbsp;:</p>
<div class="codefile"><a href="/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/code/config.ru">&#x27A5; config.ru</a></div>
<pre><code class="ruby">require 'rubygems'
require 'rack'
require 'rack/contrib'
require 'rack-rewrite'
require 'mime/types'
use Rack::ETag
module ::Rack
class TryStatic &lt; Static
def initialize(app, options)
super
@try = ([''] + Array(options.delete(:try)) + [''])
end
def call(env)
@next = 0
while @next &lt; @try.size &amp;&amp; 404 == (resp = super(try_next(env)))[0]
@next += 1
end
404 == resp[0] ? @app.call : resp
end
private
def try_next(env)
env.merge('PATH_INFO' =&gt; env['PATH_INFO'] + @try[@next])
end
end
end
use Rack::TryStatic,
:root =&gt; "output", # static files root dir
:urls =&gt; %w[/], # match all requests
:try =&gt; ['.html', 'index.html', '/index.html'] # try these postfixes sequentially
errorFile='output/Scratch/en/error/404-not_found/index.html'
run lambda { [404, {
"Last-Modified" =&gt; File.mtime(errorFile).httpdate,
"Content-Type" =&gt; "text/html",
"Content-Length" =&gt; File.size(errorFile).to_s
}, File.read(errorFile)] }
</code></pre>
<p>et un fichier <code>.gems</code> qui liste les gems nécessaires.</p>
<div class="codefile"><a href="/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/code/.gems">&#x27A5; .gems</a></div>
<pre><code class="ruby">rack
rack-rewrite
rack-contrib
</code></pre>
<p>Maintenant il suffit de suivre lintroduction rapide dheroku pour créer une nouvelle application&nbsp;:</p>
<pre><code class="zsh">git init
git add .
heroku create
git push heroku master
</code></pre>
<p>Maintenant je peux rediriger correctement mes erreurs 404.
Jespère que ça a pu vous être utile.</p>
<hr/><div class="footnotes">
<ol>
<li id="fn:1">
<p>Je me suis complètement inspiré de cet <a href="http://gmarik.info/blog/2010/05/10/blogging-with-jekyll-and-heroku-for-free">article</a>.<a href="#fnref:1" rel="reference">&#8617;</a></p>
</li>
</ol>
</div>
</div>
<div id="social">
<div class="left"> <a href="https://twitter.com/share" class="twitter-share-button" data-via="yogsototh">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</div>
<div class="left"> <div class="g-plusone" data-size="medium" data-annotation="inline" data-width="106"></div>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
</div>
<div class="flush"></div>
</div>
<div id="choixrss">
<a id="rss" href="http://feeds.feedburner.com/yannespositocomfr">
s'abonner
</a>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#comment').hide();
$('#clickcomment').click(showComments);
});
function showComments() {
$('#comment').show();
$('#clickcomment').fadeOut();
}
document.write('<div id="clickcomment">Commentaires &amp; Partage</div>');
</script>
<div class="flush"></div>
<div class="corps" id="comment">
<h2 class="first">commentaires</h2>
<noscript>
Vous devez activer javascript pour commenter.
</noscript>
<script type="text/javascript">
var idcomments_acct = 'a307f0044511ff1b5cfca573fc0a52e7';
var idcomments_post_id = '/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/';
var idcomments_post_url = 'http://yannesposito.com/Scratch/fr/blog/2010-08-23-Now-heberged-on-heroku/';
</script>
<span id="IDCommentsPostTitle" style="display:none"></span>
<script type='text/javascript' src='/Scratch/js/genericCommentWrapperV2.js'></script>
</div>
<div id="entete" class="corps_spaced">
<div id="liens">
<ul><li><a href="/Scratch/fr/">Bienvenue</a></li>
<li><a href="/Scratch/fr/blog/">Blog</a></li>
<li><a href="/Scratch/fr/softwares/">Softwares</a></li>
<li><a href="/Scratch/fr/about/">À propos</a></li></ul>
</div>
<div class="flush"></div>
<hr/>
<div id="next_before_articles">
<div id="previous_articles">
articles précédents
<div class="previous_article">
<a href="/Scratch/fr/blog/2010-07-09-Indecidabilities/"><span class="nicer">«</span>&nbsp;Indécidabilités (partie 1)</a>
</div>
<div class="previous_article">
<a href="/Scratch/fr/blog/2010-07-31-New-style-after-holidays/"><span class="nicer">«</span>&nbsp;Nouveau style après les vacances</a>
</div>
<div class="previous_article">
<a href="/Scratch/fr/blog/2010-07-07-CSS-rendering-problems-by-navigator/"><span class="nicer">«</span>&nbsp;N'utilisez pas de gradients avec Chrome</a>
</div>
</div>
<div id="next_articles">
articles suivants
<div class="next_article">
<a href="/Scratch/fr/blog/2010-08-31-send-mail-from-command-line-with-attached-file/">Envoyer un mail en ligne de commande avec un fichier attaché&nbsp;<span class="nicer">»</span></a>
</div>
<div class="next_article">
<a href="/Scratch/fr/blog/2010-09-02-base64-and-sha1-on-iPhone/">base64 et sha1 sur iPhone&nbsp;<span class="nicer">»</span></a>
</div>
<div class="next_article">
<a href="/Scratch/fr/blog/2010-09-02-Use-git-to-calculate-trusted-mtimes/">Utilisation de git pour calculer les mtimes&nbsp;<span class="nicer">»</span></a>
</div>
</div>
<div class="flush"></div>
</div>
</div>
<div id="bottom">
<div>
<a href="https://twitter.com/yogsototh">Follow @yogsototh</a>
</div>
<div>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.fr">Droits de reproduction ©, Yann Esposito</a>
</div>
<div id="lastmod">
Écrit le : 23/08/2010
modifié le : 20/04/2011
</div>
<div>
Site entièrement réalisé avec
<a href="http://www.vim.org">Vim</a>
et
<a href="http://nanoc.stoneship.org">nanoc</a>
</div>
</div>
<div class="clear"></div>
</div>
</body>
</html>