Ajout d'un export json pour la liste des medias

modified:   autoblog-0.3.php
	modified:   config.php
This commit is contained in:
Oros 2013-02-06 22:14:38 +01:00
parent cecde7f204
commit 34140b8761
3 changed files with 30 additions and 6 deletions

View file

@ -225,7 +225,6 @@ class VroumVroum_Blog
$create_articles_db = file_exists(ARTICLES_DB_FILE) ? false : true;
$this->articles = new SQLite3(ARTICLES_DB_FILE);
if ($create_articles_db)
{
$this->articles->exec('
@ -323,7 +322,13 @@ class VroumVroum_Blog
if (isset($_GET['update']))
return true;
$last_update = $this->articles->querySingle('SELECT date FROM update_log ORDER BY date DESC LIMIT 1;');
if($this->articles->busyTimeout(2000)){
$last_update = $this->articles->querySingle('SELECT date FROM update_log ORDER BY date DESC LIMIT 1;');
}else{
return false;
}
$this->articles->busyTimeout(0);
if (!empty($last_update) && (int) $last_update > (time() - $this->config->update_interval))
return false;
@ -590,6 +595,20 @@ if (isset($_GET['feed'])) // FEED
exit;
}
if (isset($_GET['media'])) // MEDIA
{
header('Content-Type: application/json');
if(is_dir(MEDIA_DIR))
{
$files = scandir(MEDIA_DIR);
unset($files[0]); // .
unset($files[1]); // ..
echo json_encode(array("url"=> LOCAL_URL.substr(MEDIA_DIR, strlen(ROOT_DIR)+1).'/', "files" => $files));
}
exit;
}
if (isset($_GET['update']))
{
$_SERVER['QUERY_STRING'] = '';
@ -791,7 +810,8 @@ echo '
<div class="footer">
<p>Powered by VroumVroumBlog '.$vvbversion.' - <a href="?feed">'.__('RSS Feed').'</a></p>
<p>'.__('Download:').' <a href="'.LOCAL_URL.basename(CONFIG_FILE).'">'.__('configuration').'</a>
- <a href="'.LOCAL_URL.basename(ARTICLES_DB_FILE).'">'.__('articles').'</a></p>
- <a href="'.LOCAL_URL.basename(ARTICLES_DB_FILE).'">'.__('articles').'</a><p/>
<p><a href="'.LOCAL_URL.'?media">'.__('Media export').' <sup> JSON</sup></a></p>
</div>';
if ($vvb->mustUpdate())

View file

@ -40,6 +40,10 @@ function __($str)
case 'configuration':
case 'articles':
return $str;
case 'Media export':
return 'Export fichiers media';
default:
return $str;
}
}

View file

@ -1,9 +1,9 @@
[VroumVroumBlogConfig]
SITE_TYPE="microblog"
SITE_TYPE="generic"
SITE_TITLE="identica-gatitac"
SITE_DESCRIPTION="Automicroblog de @gatitac"
SITE_URL="http://identi.ca/gatitac"
FEED_URL="http://identi.ca/api/statuses/user_timeline/gatitac.rss"
SITE_URL="http://korben.info/"
FEED_URL="http://korben.info/feed"
ARTICLES_PER_PAGE=10
UPDATE_INTERVAL=3600
UPDATE_TIMEOUT=30