Browse Source

include version info in response header

pull/39/head v1.2.1
Aaron Parecki 7 years ago
parent
commit
236c3f5f9c
No known key found for this signature in database GPG Key ID: 276C2817346D6056
5 changed files with 40 additions and 1 deletions
  1. +1
    -0
      README.md
  2. +3
    -1
      controllers/Parse.php
  3. +11
    -0
      lib/helpers.php
  4. +23
    -0
      release-library.sh
  5. +2
    -0
      release.sh

+ 1
- 0
README.md View File

@ -21,6 +21,7 @@ The contents of the URL is checked in the following order:
* h-review
* h-recipe
* h-product
* h-item
## Library

+ 3
- 1
controllers/Parse.php View File

@ -10,9 +10,10 @@ class Parse {
public $mc;
private $_cacheTime = 120;
private $_pretty = false;
private static $_version = '1.2.1';
public static function useragent() {
return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 XRay/1.0.0 ('.\Config::$base.')';
return 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36 XRay/'.self::$_version.' ('.\Config::$base.')';
}
public function __construct() {
@ -35,6 +36,7 @@ class Parse {
$response->headers->set($k, $v);
}
$response->headers->set('Content-Type', 'application/json');
$response->headers->set('Version', 'XRay/'.self::$_version.' php-mf2/'.p3k\XRay\phpmf2_version());
$opts = JSON_UNESCAPED_SLASHES;
if($this->_pretty) $opts += JSON_PRETTY_PRINT;
$response->setContent(json_encode($params, $opts)."\n");

+ 11
- 0
lib/helpers.php View File

@ -36,3 +36,14 @@ function should_follow_redirects($url) {
return true;
}
}
function phpmf2_version() {
$composer = json_decode(file_get_contents(dirname(__FILE__).'/../composer.lock'));
$version = 'unknown';
foreach($composer->packages as $pkg) {
if($pkg->name == 'mf2/mf2') {
$version = $pkg->version;
}
}
return $version;
}

+ 23
- 0
release-library.sh View File

@ -0,0 +1,23 @@
#!/bin/bash
release_dir=../XRay-library-release
current=`pwd`
composer install --no-dev
rsync -ap --delete controllers $release_dir/
rsync -ap --delete lib $release_dir/
rsync -ap --delete public $release_dir/
rsync -ap --delete views $release_dir/
rsync -ap --delete --exclude=.git vendor $release_dir/
cp README.md $release_dir/
cp LICENSE.txt $release_dir/
cp index.php $release_dir/
cp .htaccess $release_dir/
cp controllers/.htaccess $release_dir/vendor/
cd $release_dir
zip -r xray.zip .
cd $current

+ 2
- 0
release.sh View File

@ -4,6 +4,8 @@ release_dir=../XRay-release
current=`pwd`
composer install
rsync -ap --delete controllers $release_dir/
rsync -ap --delete lib $release_dir/
rsync -ap --delete public $release_dir/

Loading…
Cancel
Save