fix shield cache dir

This commit is contained in:
mappu 2016-04-18 19:12:11 +12:00
parent 11336d3451
commit 85ef555bfd
2 changed files with 10 additions and 2 deletions

View File

@ -9,6 +9,8 @@ require __DIR__.'util.php';
require __DIR__.'template.php'; require __DIR__.'template.php';
require __DIR__.'CProject.php'; require __DIR__.'CProject.php';
define('SHIELDS_CACHE_DIR', __DIR__.'/../shields_cache/');
function main($args) { function main($args) {
$basedir = './'; $basedir = './';
$total = $args[0]; $total = $args[0];

View File

@ -1,8 +1,14 @@
<?php <?php
function mkshield($left_str, $right_str, $color_str) { function mkshield($left_str, $right_str, $color_str) {
$filename = rawurlencode(str_replace('-', '--', $left_str)).'-'.rawurlencode(str_replace('-', '--', $right_str)).'-'.rawurlencode($color_str).'.svg'; $filename = sprintf(
$cache_path = __DIR__.'/../../shields_cache/'.$filename; "%s-%s-%s.svg",
rawurlencode(str_replace('-', '--', $left_str)),
rawurlencode(str_replace('-', '--', $right_str)),
rawurlencode($color_str)
);
$cache_path = SHIELDS_CACHE_DIR.$filename;
if (file_exists($cache_path)) { if (file_exists($cache_path)) {
return file_get_contents($cache_path); return file_get_contents($cache_path);