defr/DualBlog
changeset 61:25c6e59f019e
Suppression des urls en dur présentes dans le code.
Le code ne présuppose plus qu'il est hébergé directement sur
http://defr.org/blog. Ce n'est par contre pas vrai pour les différents
templates pour le moment, et les fichiers CSS pensent toujours qu'on est
hébergé dans le repertoire /blog, mais ca reste des présupposés à mon avis
moins ennuyeux.
Accessoirement, le code suppose que les trois constantes supplémentaires
suivantes ait été définie dans le fichier config.php:
BLOG_URL, l'adresse du blog, sans / à la fin
BLOG_DEFAULT_GRAVATAR, l'image par défaut pour les personnes laissant des
commentaires
ADMIN_MAIl, l'adresse mail ou sont envoyé les informations sur les
commentaires autorisés.
Le code ne présuppose plus qu'il est hébergé directement sur
http://defr.org/blog. Ce n'est par contre pas vrai pour les différents
templates pour le moment, et les fichiers CSS pensent toujours qu'on est
hébergé dans le repertoire /blog, mais ca reste des présupposés à mon avis
moins ennuyeux.
Accessoirement, le code suppose que les trois constantes supplémentaires
suivantes ait été définie dans le fichier config.php:
BLOG_URL, l'adresse du blog, sans / à la fin
BLOG_DEFAULT_GRAVATAR, l'image par défaut pour les personnes laissant des
commentaires
ADMIN_MAIl, l'adresse mail ou sont envoyé les informations sur les
commentaires autorisés.
| author | Franck Deroche <webmaster@defr.org> |
|---|---|
| date | Tue Mar 11 15:53:15 2008 +0100 (10 months ago) |
| parents | 46be148257ae |
| children | 96b3c34d3705 |
| files | admin.php comment.php includes/class.post.php includes/class.skeleton.php |
line diff
1.1 --- a/admin.php Tue Mar 11 14:55:20 2008 +0100
1.2 +++ b/admin.php Tue Mar 11 15:53:15 2008 +0100
1.3 @@ -88,7 +88,7 @@
1.4
1.5 $fp = fsockopen($ar_tbAddress['host'], 80, $errno, $errstr, 15);
1.6 $argToSend = "title=" . htmlentities(urlencode($row['Titre'])) . "&blog_name=Dual+Blog";
1.7 - $argToSend .= "&url=http://defr.org/blog/posts/{$row['num_mess']}&excerpt="
1.8 + $argToSend .= "&url=" . BLOG_URL . "/posts/{$row['num_mess']}&excerpt="
1.9 . htmlentities(urlencode(substr(strip_tags($row['Message']), 0, 255) . "..."));
1.10
1.11 $toSend = $genToSend . "Content-Length: " . strlen($argToSend) . "\n\n";
2.1 --- a/comment.php Tue Mar 11 14:55:20 2008 +0100
2.2 +++ b/comment.php Tue Mar 11 15:53:15 2008 +0100
2.3 @@ -27,7 +27,7 @@
2.4 VALUES({$id}, '{$Auteur}', '{$Adresse}', '{$AdresseMail}', '{$Comment}', '{$DateComment}', '{$ip}')
2.5 ");
2.6 $Data->Query("UPDATE Mess SET NbCommentaires=NbCommentaires+1 WHERE num_mess={$id}");
2.7 - mail('webmaster+blogcomment@defr.org', 'Nouveau commentaire sur de ' . $Auteur, $Auteur . " vient de mettre en ligne le commentaire suivant: \n" . wordwrap($Comment, 70));
2.8 + mail(ADMIN_MAIL, 'Nouveau commentaire de ' . $Auteur, $Auteur . " vient de mettre en ligne le commentaire suivant: \n" . wordwrap($Comment, 70));
2.9 }
2.10 else {
2.11 $infos = 'Votre commentaire doit etre fait de XML valide pour apparaitre.';
2.12 @@ -46,7 +46,7 @@
2.13
2.14 // Récupération des commentaires
2.15 $Data->Query("SELECT * FROM Commentaires Where MessId={$id} AND Visible=1 ORDER BY num_comm");
2.16 - $defaultGravatar = urlencode("http://defr.org/Misc/NoGravatar.png");
2.17 + $defaultGravatar = urlencode(BLOG_DEFAULT_GRAVATAR);
2.18 while(0 !== ($row = $Data->GetRow())) {
2.19 $commentTpl = new Template(Skeleton::getTemplateFile('comment'));
2.20 $dateFormatee = strftime(" à %Hh%M, le %A %d %B %Y", strtotime($row['DateComment']));
3.1 --- a/includes/class.post.php Tue Mar 11 14:55:20 2008 +0100
3.2 +++ b/includes/class.post.php Tue Mar 11 15:53:15 2008 +0100
3.3 @@ -30,7 +30,7 @@
3.4
3.5 // On détermine l'url de ce post
3.6 $strippedTitle = TextUtils::StripTitle($infos['Titre']);
3.7 - $this->url = '/blog/posts/' . $infos['num_mess'] . '-' . $strippedTitle;
3.8 + $this->url = '/posts/' . $infos['num_mess'] . '-' . $strippedTitle;
3.9
3.10 // On détermine le label du lien vers les commentaires
3.11 $this->commentLabel = "Un p'tit commentaire ?";
3.12 @@ -39,7 +39,7 @@
3.13
3.14 // On s'occupe de l'indicateur d'humeur
3.15 if(!empty($infos['Emot'])) {
3.16 - $mood = array('src' => "/blog/mood/{$infos['Emot']}.png",
3.17 + $mood = array('src' => BLOG_URL . "/mood/{$infos['Emot']}.png",
3.18 'alt' => 'Mood: ' . $infos['Emot']);
3.19 $this->mood = (object)$mood;
3.20 }
3.21 @@ -58,7 +58,7 @@
3.22 while(0 !== ($tag = $db->GetRow(2)))
3.23 {
3.24 $tags .= sprintf("<a href='%s'>%s</a> |",
3.25 - '/blog/tags/' . urlencode($tag['Tag']),
3.26 + BLOG_URL . '/tags/' . urlencode($tag['Tag']),
3.27 $tag['Tag']);
3.28 }
3.29 $tags = substr($tags, 0, -1);
3.30 @@ -84,8 +84,8 @@
3.31 'postContent' => $this->mess,
3.32 'postNumber' => $this->infos->num_mess,
3.33 'postComments' => $this->commentLabel,
3.34 - '#linkPostNumber@href' => $this->url,
3.35 - '#linkPostComments@href' => $this->url,
3.36 + '#linkPostNumber@href' => $this->getURL(true),
3.37 + '#linkPostComments@href' => $this->getURL(true),
3.38 'postTags' => $this->tags
3.39 );
3.40 if(!empty($this->mood->src)) {
3.41 @@ -97,7 +97,7 @@
3.42 }
3.43
3.44 public function getURL() {
3.45 - return $this->url;
3.46 + return BLOG_URL . $this->url;
3.47 }
3.48 }
3.49 ?>
4.1 --- a/includes/class.skeleton.php Tue Mar 11 14:55:20 2008 +0100
4.2 +++ b/includes/class.skeleton.php Tue Mar 11 15:53:15 2008 +0100
4.3 @@ -53,7 +53,7 @@
4.4 $monthName = TextUtils::getMonthName($row['Month']);
4.5 $curArchiveTpl->setParams(array(
4.6 'a' => $monthName . ' ' . $row['Year'],
4.7 - 'a@href' => "http://defr.org/blog/posts/{$row['Year']}/{$row['Month']}",
4.8 + 'a@href' => BLOG_URL . "/posts/{$row['Year']}/{$row['Month']}",
4.9 'postCount' => '(' . $row['Nb'] . ')'
4.10 ));
4.11 $archives[] = array('li' => $curArchiveTpl);
4.12 @@ -71,14 +71,14 @@
4.13 // On récupère une version filtrée du titre du post ...
4.14 $tf = TextUtils::StripTitle($row['Titre']);
4.15 // ... Qui nous permet d'obtenir l'adresse du commentaire sur le post
4.16 - $c_url = "/blog/posts/{$row['MessId']}-$tf#c{$row['num_comm']}";
4.17 + $c_url = BLOG_URL . "/posts/{$row['MessId']}-$tf#c{$row['num_comm']}";
4.18 // Si jamais on a une adresse mail, on rajoute un mailto:
4.19 if(strpos($row['Adresse'], '@') !== false)
4.20 $row['Adresse'] = 'mailto:' . $row['Adresse'];
4.21 // On commence par définir les paramètres généraux
4.22 $params = array(
4.23 '#CommentAuthor' => $row['Auteur'],
4.24 - '#CommentAuthor@href' => urlencode($row['Adresse']),
4.25 + '#CommentAuthor@href' => $row['Adresse'],
4.26 '#Post' => $row['Titre'],
4.27 '#Post@href' => $c_url
4.28 );
4.29 @@ -128,9 +128,9 @@
4.30 $retVal = new Template('calendar.xml');
4.31 $retVal->setParams(array(
4.32 '#calPrev' => TextUtils::getMonthName($prevMonth) . ' ' . $prevYear,
4.33 - '#calPrev@href' => '/blog/posts/' . $prevYear . '/' . $prevMonth,
4.34 + '#calPrev@href' => BLOG_URL . '/posts/' . $prevYear . '/' . $prevMonth,
4.35 '#calNext' => TextUtils::getMonthName($nextMonth) . ' ' . $nextYear,
4.36 - '#calNext@href' => '/blog/posts/' . $nextYear . '/' . $nextMonth,
4.37 + '#calNext@href' => BLOG_URL . '/posts/' . $nextYear . '/' . $nextMonth,
4.38 'currentMonth' => TextUtils::getMonthName($cMonth) . ' ' . $cYear
4.39 ));
4.40 } else {
4.41 @@ -201,7 +201,7 @@
4.42 $type = ($styleSheet->enabled) ? "" : "Alternate ";
4.43 $type .= "StyleSheet";
4.44 $params['possibleStyleSheets'][] = array(
4.45 - 'link@href' => '/blog/css/' . $styleSheet->CSSFile,
4.46 + 'link@href' => BLOG_URL . '/css/' . $styleSheet->CSSFile,
4.47 'link@rel' => $type,
4.48 'link@title' => $styleSheet->name
4.49 );
