Fix bad merge

This commit is contained in:
Knah Tsaeb 2014-04-11 17:28:35 +02:00
parent 897f3db53c
commit af79fc3d18

View file

@ -1,14 +1,14 @@
<?php <?php
/* /*
VroumVroumBlog 0.3.0 VroumVroumBlog 0.3.0
This blog automatically publishes articles from an external RSS 2.0 or ATOM feed. This blog automatically publishes articles from an external RSS 2.0 or ATOM feed.
Requirement for the source RSS feed: Requirement for the source RSS feed:
- Source feed MUST be a valid RSS 2.0, RDF 1.0 or ATOM 1.0 feed. - Source feed MUST be a valid RSS 2.0, RDF 1.0 or ATOM 1.0 feed.
- Source feed MUST be valid UTF-8 - Source feed MUST be valid UTF-8
- Source feed MUST contain article body - Source feed MUST contain article body
This program is public domain. COPY COPY COPY! This program is public domain. COPY COPY COPY!
*/ */
$vvbversion = '0.3.0'; $vvbversion = '0.3.0';
if (!version_compare(phpversion(), '5.3.0', '>=')) if (!version_compare(phpversion(), '5.3.0', '>='))
@ -34,9 +34,9 @@ else die("Functions file not found.");
if (!defined('ROOT_DIR')) if (!defined('ROOT_DIR'))
define('ROOT_DIR', __DIR__); define('ROOT_DIR', __DIR__);
if (!defined('CONFIG_FILE')) define('CONFIG_FILE', ROOT_DIR . '/vvb.ini'); if (!defined('CONFIG_FILE')) define('CONFIG_FILE', ROOT_DIR . '/vvb.ini');
if (!defined('ARTICLES_DB_FILE')) define('ARTICLES_DB_FILE', ROOT_DIR . '/articles.db'); if (!defined('ARTICLES_DB_FILE')) define('ARTICLES_DB_FILE', ROOT_DIR . '/articles.db');
if (!defined('MEDIA_DIR')) define('MEDIA_DIR', ROOT_DIR . '/media'); if (!defined('MEDIA_DIR')) define('MEDIA_DIR', ROOT_DIR . '/media');
if (!defined('LOCAL_URL')) if (!defined('LOCAL_URL'))
{ {
@ -74,7 +74,7 @@ class VroumVroum_Feed_Exception extends Exception
foreach ($errors as $error) foreach ($errors as $error)
{ {
$return = $xml[$error->line - 1] . "\n"; $return = $xml[$error->line - 1] . "\n";
$return .= str_repeat('-', $error->column) . "^\n"; $return .= str_repeat('-', $error->column) . "^\n";
switch ($error->level) { switch ($error->level) {
@ -90,11 +90,11 @@ class VroumVroum_Feed_Exception extends Exception
} }
$return .= trim($error->message) . $return .= trim($error->message) .
"\n Line: ".$error->line . "\n Line: ".$error->line .
"\n Column: ".$error->column; "\n Column: ".$error->column;
if ($error->file) { if ($error->file) {
$return .= "\n File: ".$error->file; $return .= "\n File: ".$error->file;
} }
$out[] = $return; $out[] = $return;
@ -145,7 +145,6 @@ class VroumVroum_Config
public $site_type = ''; public $site_type = '';
public $site_title = ''; public $site_title = '';
public $site_description = ''; public $site_description = '';
public $site_meta_description = '';
public $site_url = ''; public $site_url = '';
public $feed_url = ''; public $feed_url = '';
public $articles_per_page = 10; public $articles_per_page = 10;
@ -227,23 +226,23 @@ class VroumVroum_Blog
if ($create_articles_db) if ($create_articles_db)
{ {
$this->articles->exec(' $this->articles->exec('
CREATE TABLE articles ( CREATE TABLE articles (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
feed_id TEXT, feed_id TEXT,
title TEXT, title TEXT,
uri TEXT, uri TEXT,
url TEXT, url TEXT,
date INT, date INT,
content TEXT content TEXT
); );
CREATE TABLE update_log ( CREATE TABLE update_log (
date INT PRIMARY KEY, date INT PRIMARY KEY,
success INT, success INT,
log TEXT log TEXT
); );
CREATE UNIQUE INDEX feed_id ON articles (feed_id); CREATE UNIQUE INDEX feed_id ON articles (feed_id);
CREATE INDEX date ON articles (date); CREATE INDEX date ON articles (date);
'); ');
} }
$this->articles->createFunction('countintegers', array($this, 'sql_countintegers')); $this->articles->createFunction('countintegers', array($this, 'sql_countintegers'));
@ -257,7 +256,7 @@ class VroumVroum_Blog
protected function log_update($success, $log = '') protected function log_update($success, $log = '')
{ {
$this->articles->exec('INSERT INTO update_log (date, success, log) VALUES (\''.time().'\', \''.(int)(bool)$success.'\', $this->articles->exec('INSERT INTO update_log (date, success, log) VALUES (\''.time().'\', \''.(int)(bool)$success.'\',
\''.$this->articles->escapeString($log).'\');'); \''.$this->articles->escapeString($log).'\');');
// Delete old log // Delete old log
$this->articles->exec('DELETE FROM update_log WHERE date > (SELECT date FROM update_log ORDER BY date DESC LIMIT 100,1);'); $this->articles->exec('DELETE FROM update_log WHERE date > (SELECT date FROM update_log ORDER BY date DESC LIMIT 100,1);');
@ -281,9 +280,9 @@ class VroumVroum_Blog
$content = $this->mirrorMediasForArticle($content, $url); $content = $this->mirrorMediasForArticle($content, $url);
$this->articles->exec('INSERT INTO articles (id, feed_id, title, uri, url, date, content) VALUES (NULL, $this->articles->exec('INSERT INTO articles (id, feed_id, title, uri, url, date, content) VALUES (NULL,
\''.$this->articles->escapeString($feed_id).'\', \''.$this->articles->escapeString($title).'\', \''.$this->articles->escapeString($feed_id).'\', \''.$this->articles->escapeString($title).'\',
\''.$this->articles->escapeString($uri).'\', \''.$this->articles->escapeString($url).'\', \''.$this->articles->escapeString($uri).'\', \''.$this->articles->escapeString($url).'\',
\''.(int)$date.'\', \''.$this->articles->escapeString($content).'\');'); \''.(int)$date.'\', \''.$this->articles->escapeString($content).'\');');
$id = $this->articles->lastInsertRowId(); $id = $this->articles->lastInsertRowId();
@ -305,8 +304,8 @@ class VroumVroum_Blog
$content = $this->mirrorMediasForArticle($content, $url); $content = $this->mirrorMediasForArticle($content, $url);
$this->articles->exec('UPDATE articles SET title=\''.$this->articles->escapeString($title).'\', $this->articles->exec('UPDATE articles SET title=\''.$this->articles->escapeString($title).'\',
url=\''.$this->articles->escapeString($url).'\', content=\''.$this->articles->escapeString($content).'\', url=\''.$this->articles->escapeString($url).'\', content=\''.$this->articles->escapeString($content).'\',
date=\''.(int)$date.'\' WHERE id = \''.(int)$id.'\';'); date=\''.(int)$date.'\' WHERE id = \''.(int)$id.'\';');
$title = self::removeHTML($title); $title = self::removeHTML($title);
$content = self::removeHTML($content); $content = self::removeHTML($content);
@ -328,9 +327,9 @@ class VroumVroum_Blog
return true; return true;
} }
public function mustUpdateXsaf() public function mustUpdateXsaf()
{ {
return file_exists('import.json'); return file_exists('import.json');
} }
@ -338,10 +337,10 @@ class VroumVroum_Blog
{ {
return stream_context_create( return stream_context_create(
array( array(
'http' => array( 'http' => array(
'method' => 'GET', 'method' => 'GET',
'timeout' => $this->config->update_timeout, 'timeout' => $this->config->update_timeout,
'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Autoblogs; +https://github.com/mitsukarenai/Projet-Autoblog/) Gecko/20100101 Firefox/20.0\r\n", 'header' => "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:20.0; Autoblogs; +https://github.com/mitsukarenai/Projet-Autoblog/) Gecko/20100101 Firefox/20.0\r\n",
) )
) )
); );
@ -380,10 +379,10 @@ class VroumVroum_Blog
{ {
$date = isset($item->published) ? (string) $item->published : (string) $item->updated; $date = isset($item->published) ? (string) $item->published : (string) $item->updated;
$guid = !empty($item->id) ? (string)$item->id : (string)$item->link['href']; $guid = !empty($item->id) ? (string)$item->id : (string)$item->link['href'];
if( count($item->content->children()) > 0 ) $content = (string)$item->content->asXML(); if( count($item->content->children()) > 0 ) $content = (string)$item->content->asXML();
else $content = (string)$item->content; else $content = (string)$item->content;
$id = $this->insertOrUpdateArticle($guid, (string)$item->title, $id = $this->insertOrUpdateArticle($guid, (string)$item->title,
(string)$item->link['href'], strtotime($date), $content ); (string)$item->link['href'], strtotime($date), $content );
@ -433,33 +432,33 @@ class VroumVroum_Blog
return $updated; return $updated;
} }
public function updateXsaf() { public function updateXsaf() {
if($this->mustUpdateXsaf()) { if($this->mustUpdateXsaf()) {
$json = json_decode(file_get_contents('import.json'), true); $json = json_decode(file_get_contents('import.json'), true);
$count = count($json['files']); $count = count($json['files']);
file_put_contents('import.lock', $count); /* one-process locking */ file_put_contents('import.lock', $count); /* one-process locking */
$remoteurl = $json['url']; $remoteurl = $json['url'];
if (!file_exists('media')) { if (!file_exists('media')) {
mkdir('media'); mkdir('media');
} }
$time = time(); $time = time();
$maxtime = $time + 3; /* max exec time: 3 seconds */ $maxtime = $time + 3; /* max exec time: 3 seconds */
while ($time <= $maxtime) { while ($time <= $maxtime) {
$file = array_shift($json['files']); /* get first element while unstacking */ $file = array_shift($json['files']); /* get first element while unstacking */
if(!empty($file)) { if(!empty($file)) {
$this->_copy($remoteurl.$file, "media/$file"); $this->_copy($remoteurl.$file, "media/$file");
file_put_contents('import.json', json_encode($json)); file_put_contents('import.json', json_encode($json));
} }
else { else {
unlink('import.json'); unlink('import.json');
break; break;
} /* first element empty: import finished */ } /* first element empty: import finished */
$time = time(); $time = time();
} }
unlink('import.lock'); unlink('import.lock');
} }
} }
public function listArticlesByPage($page = 1) public function listArticlesByPage($page = 1)
@ -501,11 +500,11 @@ class VroumVroum_Blog
public function searchArticles($query) public function searchArticles($query)
{ {
$res = $this->articles->query('SELECT id, uri, title, content $res = $this->articles->query('SELECT id, uri, title, content
FROM articles FROM articles
WHERE content LIKE \'%'.$this->articles->escapeString($query).'%\' WHERE content LIKE \'%'.$this->articles->escapeString($query).'%\'
OR title LIKE \'%'.$this->articles->escapeString($query).'%\' OR title LIKE \'%'.$this->articles->escapeString($query).'%\'
ORDER BY id DESC ORDER BY id DESC
LIMIT 0,100;'); LIMIT 0,100;');
$out = array(); $out = array();
@ -526,7 +525,7 @@ class VroumVroum_Blog
} }
$schemes = array('http', 'https'); $schemes = array('http', 'https');
$extensions = explode(',', preg_quote('jpg,jpeg,png,apng,gif,svg,pdf,odt,ods,epub,webp,wav,mp3,ogg,aac,wma,flac,opus,mp4,webm', '!')); $extensions = explode(',', preg_quote('jpg,jpeg,png,apng,gif,svg,pdf,odt,ods,epub,webp,wav,mp3,ogg,aac,wma,flac,opus,mp4,webm', '!'));
$extensions = implode('|', $extensions); $extensions = implode('|', $extensions);
$from = parse_url($url); $from = parse_url($url);
@ -574,7 +573,7 @@ class VroumVroum_Blog
} }
return $content; return $content;
} }
public function getXsafCounter() { public function getXsafCounter() {
if($this->mustUpdateXsaf()) { if($this->mustUpdateXsaf()) {
$json = json_decode(file_get_contents('import.json'), true); $json = json_decode(file_get_contents('import.json'), true);
@ -604,36 +603,36 @@ if (isset($_GET['feed'])) // FEED
{ {
header('Content-Type: application/atom+xml; charset=UTF-8'); header('Content-Type: application/atom+xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?> echo '<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xml:lang="fr-FR"> <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xml:lang="fr-FR">
<title type="text">'.escape($config->site_title).'</title> <title type="text">'.escape($config->site_title).'</title>
<subtitle type="text">'.escape(html_entity_decode(strip_tags($config->site_description), ENT_COMPAT, 'UTF-8')).'</subtitle> <subtitle type="text">'.escape(html_entity_decode(strip_tags($config->site_description), ENT_COMPAT, 'UTF-8')).'</subtitle>
<updated>'.date(DATE_ATOM, filemtime(ARTICLES_DB_FILE)).'</updated> <updated>'.date(DATE_ATOM, filemtime(ARTICLES_DB_FILE)).'</updated>
<link rel="alternate" type="text/html" href="'.str_replace('?feed./', '', LOCAL_URL).'" /> <link rel="alternate" type="text/html" href="'.str_replace('?feed./', '', LOCAL_URL).'" />
<id>'.LOCAL_URL.'</id> <id>'.LOCAL_URL.'</id>
<link rel="self" type="application/atom+xml" href="'.LOCAL_URL.'" /> <link rel="self" type="application/atom+xml" href="'.LOCAL_URL.'" />
<generator uri="https://github.com/mitsukarenai/Projet-Autoblog" version="3">Projet Autoblog</generator>'; <generator uri="https://github.com/mitsukarenai/Projet-Autoblog" version="3">Projet Autoblog</generator>';
foreach($vvb->listLastArticles() as $art) foreach($vvb->listLastArticles() as $art)
{ {
echo ' echo '
<entry> <entry>
<author> <author>
<name>'.escape($config->site_title).'</name> <name>'.escape($config->site_title).'</name>
<uri>'.escape($config->site_url).'</uri> <uri>'.escape($config->site_url).'</uri>
</author> </author>
<title type="html"><![CDATA['.escape($art['title']).']]></title> <title type="html"><![CDATA['.escape($art['title']).']]></title>
<link rel="alternate" type="text/html" href="'.str_replace('?feed', '?', LOCAL_URL).urlencode(str_replace('./?', '', $vvb->getLocalURL($art))).'" /> <link rel="alternate" type="text/html" href="'.str_replace('?feed', '?', LOCAL_URL).urlencode(str_replace('./?', '', $vvb->getLocalURL($art))).'" />
<id>'.str_replace('?feed', '?', LOCAL_URL).urlencode(str_replace('./?', '', $vvb->getLocalURL($art))).'</id> <id>'.str_replace('?feed', '?', LOCAL_URL).urlencode(str_replace('./?', '', $vvb->getLocalURL($art))).'</id>
<updated>'.date(DATE_ATOM, $art['date']).'</updated> <updated>'.date(DATE_ATOM, $art['date']).'</updated>
<content type="html"> <content type="html">
<![CDATA[(<a href="'.escape($art['url']).'">source</a>)<br />'.escape_content($art['content']).']]> <![CDATA[(<a href="'.escape($art['url']).'">source</a>)<br />'.escape_content($art['content']).']]>
</content> </content>
</entry>'; </entry>';
} }
echo ' echo '
</feed>'; </feed>';
exit; exit;
} }
@ -641,7 +640,7 @@ if (isset($_GET['opml'])) // OPML
{ {
//header('Content-Type: application/octet-stream'); //header('Content-Type: application/octet-stream');
header('Content-type: text/xml'); header('Content-type: text/xml');
header('Content-Disposition: attachment; filename="'.escape($config->site_title).'.xml"'); header('Content-Disposition: attachment; filename="'.escape($config->site_title).'.xml"');
$opmlfile = new SimpleXMLElement('<opml></opml>'); $opmlfile = new SimpleXMLElement('<opml></opml>');
$opmlfile->addAttribute('version', '1.0'); $opmlfile->addAttribute('version', '1.0');
$opmlhead = $opmlfile->addChild('head'); $opmlhead = $opmlfile->addChild('head');
@ -663,7 +662,7 @@ if (isset($_GET['media'])) // MEDIA
header('Content-Type: application/json'); header('Content-Type: application/json');
if(is_dir(MEDIA_DIR)) if(is_dir(MEDIA_DIR))
{ {
$url = str_replace('?media', 'media/', LOCAL_URL); $url = str_replace('?media', 'media/', LOCAL_URL);
$files = scandir(MEDIA_DIR); $files = scandir(MEDIA_DIR);
unset($files[0]); // . unset($files[0]); // .
unset($files[1]); // .. unset($files[1]); // ..
@ -692,214 +691,127 @@ if (!$search && !empty($_SERVER['QUERY_STRING']) && !is_numeric($_SERVER['QUERY_
} }
} }
// common CSS // common CSS
<<<<<<< HEAD
$css=' * { margin: 0; padding: 0; }
body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; }
img { max-width: 100%; height: auto; }
a { text-decoration: none; color: #000;font-weight:bold; }
.header a { text-decoration: none; color: #000;font-weight:bold; }
.header { text-align:center; padding: 30px 3%; max-width:70em;margin:0 auto; }
.article .title { margin-bottom: 1em; }
.article .title h2 a:hover { color:#403976; }
.article h4 { font-weight: normal; font-size: small; color: #666; }
.article .source a { color: #666; }
.searchForm { float:right; }
.searchForm input { }
.pagination { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
.pagination b { font-size: 1.2em; color: #333; }
.pagination a { color:#000; margin: 0 0.5em; }
.pagination a:hover { color:#333; }
.footer a { color:#000; }
.footer a:hover { color:#333; }
.content ul, .content ol { margin-left: 2em; }
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6,
.content ul, .content ol, .content p, .content object, .content div, .content blockquote,
.content dl, .content pre { margin-bottom: 0.8em; }
.content pre, .content blockquote { background: #ddd; border: 1px solid #999; padding: 0.2em; max-width: 100%; overflow: auto; }
.content h1 { font-size: 1.5em; }
.content h2 { font-size: 1.4em;color:#000; }
.result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; }
#error { position: fixed; top: 0; left: 0; right: 0; padding: 1%; background: #fff; border-bottom: 2px solid red; color: darkred; }
||||||| merged common ancestors
$css=' * { margin: 0; padding: 0; }
body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; }
img { max-width: 100%; height: auto; }
a { text-decoration: none; color: #000;font-weight:bold; }
.header a { text-decoration: none; color: #000;font-weight:bold; }
.header { text-align:center; padding: 30px 3%; max-width:70em;margin:0 auto; }
.article .title { margin-bottom: 1em; }
.article .title h2 a:hover { color:#403976; }
.article h4 { font-weight: normal; font-size: small; color: #666; }
.article .source a { color: #666; }
.searchForm { float:right; }
.searchForm input { }
.pagination { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
.pagination b { font-size: 1.2em; color: #333; }
.pagination a { color:#000; margin: 0 0.5em; }
.pagination a:hover { color:#333; }
.footer a { color:#000; }
.footer a:hover { color:#333; }
.content ul, .content ol { margin-left: 2em; }
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6,
.content ul, .content ol, .content p, .content object, .content div, .content blockquote,
.content dl, .content pre { margin-bottom: 0.8em; }
.content pre, .content blockquote { background: #ddd; border: 1px solid #999; padding: 0.2em; max-width: 100%; overflow: auto; }
.content h1 { font-size: 1.5em; }
.content h2 { font-size: 1.4em;color:#000; }
.result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; }
#error { position: fixed; top: 0; left: 0; right: 0; padding: 1%; background: #fff; border-bottom: 2px solid red; color: darkred; }
=======
$css='* { margin: 0; padding: 0; } $css='* { margin: 0; padding: 0; }
body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; } body { font-family:sans-serif; background-color: #efefef; padding: 1%; color: #333; }
img { max-width: 100%; height: auto; } img { max-width: 100%; height: auto; }
a { text-decoration: none; color: #000;font-weight:bold; } a { text-decoration: none; color: #000;font-weight:bold; }
body > header a { text-decoration: none; color: #000;font-weight:bold; } body > header a { text-decoration: none; color: #000;font-weight:bold; }
body > header { text-align:center; padding: 30px 3%; max-width:70em;margin:0 auto; } body > header { text-align:center; padding: 30px 3%; max-width:70em;margin:0 auto; }
body > article > header { margin-bottom: 1em; } body > article > header { margin-bottom: 1em; }
body > article > header h2 a:hover { color:#403976; } body > article > header h2 a:hover { color:#403976; }
body > article h4 { font-weight: normal; font-size: small; color: #666; } body > article h4 { font-weight: normal; font-size: small; color: #666; }
body > article .source a { color: #666; } body > article .source a { color: #666; }
body > header > form { float:right; } body > header > form { float:right; }
body > header > form input { } body > header > form input { }
body > nav { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } body > nav { background-color:white;padding: 12px 10px 12px 10px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
body > nav strong { font-size: 1.2em; color: #333; } body > nav strong { font-size: 1.2em; color: #333; }
body > nav a { color:#000; margin: 0 0.5em; } body > nav a { color:#000; margin: 0 0.5em; }
body > nav a:hover { color:#333; } body > nav a:hover { color:#333; }
body > footer a { color:#000; } body > footer a { color:#000; }
body > footer a:hover { color:#333; } body > footer a:hover { color:#333; }
.content ul, .content ol { margin-left: 2em; } .content ul, .content ol { margin-left: 2em; }
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6, .content h1, .content h2, .content h3, .content h4, .content h5, .content h6,
.content ul, .content ol, .content p, .content object, .content div, .content blockquote, .content ul, .content ol, .content p, .content object, .content div, .content blockquote,
.content dl, .content pre { margin-bottom: 0.8em; } .content dl, .content pre { margin-bottom: 0.8em; }
.content pre, .content blockquote { background: #ddd; border: 1px solid #999; padding: 0.2em; max-width: 100%; overflow: auto; } .content pre, .content blockquote { background: #ddd; border: 1px solid #999; padding: 0.2em; max-width: 100%; overflow: auto; }
.content h1 { font-size: 1.5em; } .content h1 { font-size: 1.5em; }
.content h2 { font-size: 1.4em;color:#000; } .content h2 { font-size: 1.4em;color:#000; }
.result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; } .result h3 a { color: darkblue; text-decoration: none; text-shadow: 1px 1px 1px #fff; }
#error { position: fixed; top: 0; left: 0; right: 0; padding: 1%; background: #fff; border-bottom: 2px solid red; color: darkred; } #error { position: fixed; top: 0; left: 0; right: 0; padding: 1%; background: #fff; border-bottom: 2px solid red; color: darkred; }
>>>>>>> master
'; ';
switch($site_type) { switch($site_type) {
case 'microblog': case 'microblog':
case 'twitter': case 'twitter':
$css .= "\n".' /* twitter/microblog style */ $css .= "\n".' /* twitter/microblog style */
body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; } body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; }
body > article > header h2 { width: 10em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 0.7em;margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } body > article > header h2 { width: 10em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 0.7em;margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; }
body > article > header h2 a { color:#333; text-decoration:none; } body > article > header h2 a { color:#333; text-decoration:none; }
body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:0 auto;box-shadow:0px 5px 7px #aaa; } body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:0 auto;box-shadow:0px 5px 7px #aaa; }
body > article .source { font-size: 0.8em; color: #666; } body > article .source { font-size: 0.8em; color: #666; }
body > footer { margin-top:1em;text-align:center; font-size: small; color:#333; clear: both; } body > footer { margin-top:1em;text-align:center; font-size: small; color:#333; clear: both; }
.content {font-size:0.9em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}'; .content {font-size:0.9em;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;}';
break; break;
case 'shaarli': case 'shaarli':
$css .= "\n".' /* shaarli style */ $css .= "\n".' /* shaarli style */
body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; } body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px; }
body > article > header title h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } body > article > header title h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; }
body > article > header h2 a { color:#000; text-decoration:none; } body > article > header h2 a { color:#000; text-decoration:none; }
body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
body > article footer.source { margin-top:1em;font-size: 0.8em; color: #666; } body > article footer.source { margin-top:1em;font-size: 0.8em; color: #666; }
body > footer { text-align:center; font-size: small; color:#333; clear: both; }'; body > footer { text-align:center; font-size: small; color:#333; clear: both; }';
break; break;
case 'generic': case 'generic':
case 'youtube': case 'youtube':
default: default:
$css .= "\n".' /* youtube style */ $css .= "\n".' /* youtube style */
body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px;text-transform:uppercase; } body > header h1 a { color: #333;font-size:40pt;text-shadow: #ccc 0px 5px 5px;text-transform:uppercase; }
body > article > header h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; } body > article > header h2 { margin: 0; color:#333; text-shadow: 1px 1px 1px #fff; }
body > article > header h2 a { color:#000; text-decoration:none; } body > article > header h2 a { color:#000; text-decoration:none; }
body > article footer.source { font-size: 0.8em; color: #666; } body > article footer.source { font-size: 0.8em; color: #666; }
body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; } body > article { background-color:white;padding: 12px 10px 33px;border:1px solid #aaa;max-width:70em;margin:1em auto;box-shadow:0px 5px 7px #aaa; }
body > footer { text-align:center; font-size: small; color:#333; clear: both; }'; body > footer { text-align:center; font-size: small; color:#333; clear: both; }';
} }
// HTML HEADER // HTML HEADER
echo '<!DOCTYPE html> echo '<!DOCTYPE html>
<html lang="fr" dir="ltr"> <html lang="fr" dir="ltr">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="utf-8" />
<title>'.escape($config->site_title).'</title> <title>'.escape($config->site_title).'</title>
<link rel="canonical" href="'.escape($config->site_url).'"> <link rel="canonical" href="'.escape($config->site_url).'">
<link rel="alternate" type="application/atom+xml" title="'.__('ATOM Feed').'" href="?feed"> <link rel="alternate" type="application/atom+xml" title="'.__('ATOM Feed').'" href="?feed">
<style type="text/css" media="screen,projection"> <style type="text/css" media="screen,projection">
<<<<<<< HEAD '.$css.'
'.$css.' </style>';
</style>
</head>
<body>
<div class="header">
<h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1>
<hr>
<h1><a href="./">'.escape($config->site_title).'</a></h1>';
if (!empty($config->site_description)){
echo '<p>'.$config->site_description.'<br><a href="../../">&lArr; retour index</a></p>';
}
echo '<p class="pagination">'.$config->site_meta_description.'<br></p>';
||||||| merged common ancestors
'.$css.'
</style>
</head>
<body>
<div class="header">
<h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1>
<hr>
<h1><a href="./">'.escape($config->site_title).'</a></h1>';
if (!empty($config->site_description))
echo '<p>'.$config->site_description.'<br><a href="../../">&lArr; retour index</a></p>';
=======
'.$css.'
</style>';
if( $vvb->mustUpdateXsaf()) { if( $vvb->mustUpdateXsaf()) {
echo ' <meta http-equiv="Refresh" content="1">'; echo ' <meta http-equiv="Refresh" content="1">';
} }
echo ' echo '
</head> </head>
<body> <body>
<header> <header>
<h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1> <h1><a href="../../" style="font-size:0.8em;">PROJET AUTOBLOG'. (strlen(HEAD_TITLE) > 0 ? ' ~ '. HEAD_TITLE : '') .'</a></h1>
<hr /> <hr />
<h1><a href="./">'.escape($config->site_title).'</a></h1>'; <h1><a href="./">'.escape($config->site_title).'</a></h1>';
if (!empty($config->site_description)) if (!empty($config->site_description))
echo ' echo '
<p>'.$config->site_description.'</p> <p>'.$config->site_description.'</p>
<p><a href="../../">&lArr; retour index</a></p>'; <p><a href="../../">&lArr; retour index</a></p>';
>>>>>>> master
echo ' echo '
<form method="get" action="'.escape(LOCAL_URL).'"> <form method="get" action="'.escape(LOCAL_URL).'">
<input type="search" name="q" value="'.escape($search).'" /> <input type="search" name="q" value="'.escape($search).'" />
<input type="submit" value="'.__('Search').'" /> <input type="submit" value="'.__('Search').'" />
</form> </form>
</header> </header>
'; ';
if( $vvb->mustUpdateXsaf()) { if( $vvb->mustUpdateXsaf()) {
echo ' echo '
<article> <article>
<header> <header>
<h2>'.__('Update').'</h2> <h2>'.__('Update').'</h2>
</header> </header>
<div class="content" id="update"> <div class="content" id="update">
'.__('Import running: '). $vvb->getXsafCounter() . __(' files remaining').'<br> '.__('Import running: '). $vvb->getXsafCounter() . __(' files remaining').'<br>
'.__('The page should refresh every second. If not, <a href="javascript:window.location.reload()">refresh manually</a>.').' '.__('The page should refresh every second. If not, <a href="javascript:window.location.reload()">refresh manually</a>.').'
</div> </div>
</article>'; </article>';
} }
elseif ($vvb->mustUpdate()) elseif ($vvb->mustUpdate())
{ {
echo ' echo '
<article> <article>
<header> <header>
<h2>'.__('Update').'</h2> <h2>'.__('Update').'</h2>
</header> </header>
<div class="content" id="update"> <div class="content" id="update">
'.__('Updating database... Please wait.').' '.__('Updating database... Please wait.').'
</div> </div>
</article>'; </article>';
} }
if (!empty($search)) if (!empty($search))
@ -907,22 +819,22 @@ if (!empty($search))
$results = $vvb->searchArticles($search); $results = $vvb->searchArticles($search);
$text = sprintf(__('<strong>%d</strong> results for <em>%s</em>'), count($results), escape($search)); $text = sprintf(__('<strong>%d</strong> results for <em>%s</em>'), count($results), escape($search));
echo ' echo '
<article id="results"> <article id="results">
<header> <header>
<h2>'.__('Search').'</h2> <h2>'.__('Search').'</h2>
'.$text.' '.$text.'
</header> </header>
<article>'; <article>';
foreach ($results as $art) foreach ($results as $art)
{ {
echo ' echo '
<article class="result"> <article class="result">
<header> <header>
<h3><a href="./?'.escape($art['uri']).'">'.escape($art['title']).'</a></h3> <h3><a href="./?'.escape($art['uri']).'">'.escape($art['title']).'</a></h3>
</header> </header>
<p>'.$art['content'].'</p> <p>'.$art['content'].'</p>
</article>'; </article>';
} }
} }
elseif (!is_null($article)) elseif (!is_null($article))
@ -930,13 +842,13 @@ elseif (!is_null($article))
if (!$article) if (!$article)
{ {
echo ' echo '
<article> <article>
<header> <header>
<h2>'.__('Not Found').'</h2> <h2>'.__('Not Found').'</h2>
'.(!empty($uri) ? '<p><tt>'.escape($vvb->getLocalURL($uri)) . '</tt></p>' : '').' '.(!empty($uri) ? '<p><tt>'.escape($vvb->getLocalURL($uri)) . '</tt></p>' : '').'
'.__('Article not found.').' '.__('Article not found.').'
</header> </header>
</article>'; </article>';
} }
else else
{ {
@ -959,29 +871,29 @@ else
$max = $vvb->countArticles(); $max = $vvb->countArticles();
if ($max > $config->articles_per_page) { if ($max > $config->articles_per_page) {
echo "\n".' <nav>'."\n"; echo "\n".' <nav>'."\n";
if ($page > 1) if ($page > 1)
echo ' <a rel="prev" href="'.$vvb->getLocalURL($page - 1).'">&larr; '.__('Newer').'</a>'."\n"; echo ' <a rel="prev" href="'.$vvb->getLocalURL($page - 1).'">&larr; '.__('Newer').'</a>'."\n";
$last = ceil($max / $config->articles_per_page); $last = ceil($max / $config->articles_per_page);
for ($i = 1; $i <= $last; $i++) { for ($i = 1; $i <= $last; $i++) {
echo ' '.($i == $page ? '<strong>'.$i.'</strong>' : '<a href="'.$vvb->getLocalURL($i).'">'.$i.'</a>')."\n"; echo ' '.($i == $page ? '<strong>'.$i.'</strong>' : '<a href="'.$vvb->getLocalURL($i).'">'.$i.'</a>')."\n";
} }
if ($page < $last) if ($page < $last)
echo ' <a rel="next" href="'.$vvb->getLocalURL($page + 1).'">'.__('Older').' &rarr;</a>'."\n"; echo ' <a rel="next" href="'.$vvb->getLocalURL($page + 1).'">'.__('Older').' &rarr;</a>'."\n";
echo ' </nav>'; echo ' </nav>';
} }
} }
echo ' echo '
<footer> <footer>
<p>Propulsé par <a href="https://github.com/mitsukarenai/Projet-Autoblog">Projet Autoblog '.$vvbversion.'</a> - <a href="?feed">'.__('ATOM Feed').'</a></p> <p>Propulsé par <a href="https://github.com/mitsukarenai/Projet-Autoblog">Projet Autoblog '.$vvbversion.'</a> - <a href="?feed">'.__('ATOM Feed').'</a></p>
<p>'.__('Download:').' <a href="./'.basename(CONFIG_FILE).'">'.__('configuration').'</a> (<a href="?opml">OPML</a>) <p>'.__('Download:').' <a href="./'.basename(CONFIG_FILE).'">'.__('configuration').'</a> (<a href="?opml">OPML</a>)
<a href="./'.basename(ARTICLES_DB_FILE).'">'.__('articles').'</a></p> <a href="./'.basename(ARTICLES_DB_FILE).'">'.__('articles').'</a></p>
<p><a href="./?media">'.__('Media export').' <sup> JSON</sup></a></p> <p><a href="./?media">'.__('Media export').' <sup> JSON</sup></a></p>
</footer>'; </footer>';
if( $vvb->mustUpdateXsaf() ) { if( $vvb->mustUpdateXsaf() ) {
try { try {
@ -999,9 +911,9 @@ if( $vvb->mustUpdateXsaf() ) {
catch (VroumVroum_Feed_Exception $e) catch (VroumVroum_Feed_Exception $e)
{ {
echo ' echo '
<div id="error"> <div id="error">
'.escape($e->getMessage()).' '.escape($e->getMessage()).'
</div>'; </div>';
$updated = 0; $updated = 0;
} }
} }
@ -1022,34 +934,34 @@ elseif ($vvb->mustUpdate())
catch (VroumVroum_Feed_Exception $e) catch (VroumVroum_Feed_Exception $e)
{ {
echo ' echo '
<div id="error"> <div id="error">
'.escape($e->getMessage()).' '.escape($e->getMessage()).'
</div>'; </div>';
$updated = 0; $updated = 0;
} }
if ($updated > 0) if ($updated > 0)
{ {
echo ' echo '
<script type="text/javascript"> <script type="text/javascript">
window.onload = function () { window.onload = function () {
document.getElementById("update").innerHTML = "'.__('Update complete!').' <a href=\\"#reload\\" onclick=\\"window.location.reload();\\">'.__('Click here to reload this webpage.').'</a>"; document.getElementById("update").innerHTML = "'.__('Update complete!').' <a href=\\"#reload\\" onclick=\\"window.location.reload();\\">'.__('Click here to reload this webpage.').'</a>";
}; };
</script>'; </script>';
} }
else else
{ {
echo ' echo '
<script type="text/javascript"> <script type="text/javascript">
window.onload = function () { window.onload = function () {
document.body.removeChild(document.getElementById("update").parentNode); document.body.removeChild(document.getElementById("update").parentNode);
}; };
</script>'; </script>';
} }
} }
echo ' echo '
</body> </body>
</html>'; </html>';
@ -1065,14 +977,14 @@ function display_article($article)
{ {
global $vvb, $config; global $vvb, $config;
echo ' echo '
<article> <article>
<header> <header>
<h2><a href="'.$vvb->getLocalURL($article).'">'.escape($article['title']).'</a></h2> <h2><a href="'.$vvb->getLocalURL($article).'">'.escape($article['title']).'</a></h2>
'.strftime(__('_date_format'), $article['date']).' '.strftime(__('_date_format'), $article['date']).'
</header> </header>
<div class="content">'.escape_content($article['content']).'</div> <div class="content">'.escape_content($article['content']).'</div>
<footer class="source"><p>'.__('Source:').' <a href="'.escape($article['url']).'">'.escape($article['url']).'</a></p></footer> <footer class="source"><p>'.__('Source:').' <a href="'.escape($article['url']).'">'.escape($article['url']).'</a></p></footer>
</article>'; </article>';
} }
?> ?>