More dynamic plugin directory lookup

I installed Qvitter in local/plugins/ rather than plugins/ which
meant that some statically assigned paths were incorrect. This patch
will instead find the current Qvitter directory when the plugin is
loaded and use that when finding ctime for files on the filesystem.
This commit is contained in:
Mikael Nordfeldth 2014-11-28 13:49:00 +01:00
parent ef51b7da86
commit 6083c43863
2 changed files with 9 additions and 7 deletions

View File

@ -34,6 +34,8 @@
· ·
· · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · */
const QVITTERDIR = __DIR__;
class QvitterPlugin extends Plugin {
public function settings($setting)
@ -265,7 +267,7 @@ class QvitterPlugin extends Plugin {
var qvitterEnabled = '.$qvitter_enabled.';
var qvitterAllLink = \''.common_local_url('all', array('nickname' => $user->nickname)).'\';
');
$action->script($this->path('js/toggleqvitter.js?changed='.date('YmdHis',filemtime(INSTALLDIR.'/plugins/Qvitter/js/toggleqvitter.js'))));
$action->script($this->path('js/toggleqvitter.js?changed='.date('YmdHis',filemtime(QVITTERDIR.'/js/toggleqvitter.js'))));
}
}

View File

@ -102,7 +102,7 @@ class QvitterAction extends ApiAction
<title><?php print $sitetitle; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?>css/qvitter.css?changed=<?php print date('YmdHis',filemtime(INSTALLDIR.'/plugins/Qvitter/css/qvitter.css')); ?>" />
<link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?>css/qvitter.css?changed=<?php print date('YmdHis',filemtime(QVITTERDIR.'/css/qvitter.css')); ?>" />
<link rel="stylesheet" type="text/css" href="<?php print $qvitterpath; ?>css/jquery.minicolors.css" />
<link rel="shortcut icon" type="image/x-icon" href="<?php print $qvitterpath; ?>/img/favicon.ico?v=4">
<?php
@ -446,11 +446,11 @@ class QvitterAction extends ApiAction
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lib/jquery.minicolors.min.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lib/jquery.jWindowCrop.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lib/load-image.min.js"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/dom-functions.js?changed=<?php print date('YmdHis',filemtime(INSTALLDIR.'/plugins/Qvitter/js/dom-functions.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/misc-functions.js?changed=<?php print date('YmdHis',filemtime(INSTALLDIR.'/plugins/Qvitter/js/misc-functions.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/ajax-functions.js?changed=<?php print date('YmdHis',filemtime(INSTALLDIR.'/plugins/Qvitter/js/ajax-functions.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lan.js?changed=<?php print date('YmdHis',filemtime(INSTALLDIR.'/plugins/Qvitter/js/lan.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/qvitter.js?changed=<?php print date('YmdHis',filemtime(INSTALLDIR.'/plugins/Qvitter/js/qvitter.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/dom-functions.js?changed=<?php print date('YmdHis',filemtime(QVITTERDIR.'/js/dom-functions.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/misc-functions.js?changed=<?php print date('YmdHis',filemtime(QVITTERDIR.'/js/misc-functions.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/ajax-functions.js?changed=<?php print date('YmdHis',filemtime(QVITTERDIR.'/js/ajax-functions.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/lan.js?changed=<?php print date('YmdHis',filemtime(QVITTERDIR.'/js/lan.js')); ?>"></script>
<script type="text/javascript" src="<?php print $qvitterpath; ?>js/qvitter.js?changed=<?php print date('YmdHis',filemtime(QVITTERDIR.'/js/qvitter.js')); ?>"></script>
<?php
// we might have custom javascript in the config file that we want to add