Skip to content

Commit

Permalink
php add type jsonp. update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
ganlvtech committed Sep 21, 2018
1 parent 157c42f commit 7a2ae33
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ matrix:
before_install:
- nvm install node
script:
- php php/crawl.php
- php php/format.php
- npm install
- export BUILD_GITHUB_PAGES=true
- npm run build
- chmod 777 ./build_github_pages.sh
- ./build_github_pages.sh
deploy:
provider: pages
local-dir: dist
Expand Down
7 changes: 7 additions & 0 deletions build_github_pages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
php php/crawl.php
php php/format.php
npm install
export BUILD_GITHUB_PAGES=true
npm run build
sed -i "s/requestType:\ 'jsonp'/jsonUrl:\ '\/down_52pojie_cn\/list.json'/g" ./dist/index.html
9 changes: 4 additions & 5 deletions build_release.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env bash
npm install
echo "VUE_APP_ROUTER_MODE=history" > .env.local
echo "USE_FANCY_INDEX=true" >> .env.local
echo "FANCY_INDEX_DIR=.fancyindex" >> .env.local
export VUE_APP_ROUTER_MODE=history
export USE_FANCY_INDEX=true
export FANCY_INDEX_DIR=.fancyindex
npm run build
rm .env.local
rm dist/index.html
rm dist/list.json
cp LICENSE dist/
cp php/scan.php dist/
cp README.md dist/
Expand Down
21 changes: 17 additions & 4 deletions php/scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,39 @@

// ==================== config ====================

// Windows
define('BASE_DIR', 'C:\Users\Ganlv\Downloads');
define('OUTPUT_FILE', dirname(__DIR__) . '\public\list.json');
// define('OUTPUT_FILE', dirname(__DIR__) . '\public\list.json');

// Use jsonp
define('OUTPUT_FILE', dirname(__DIR__) . '\public\list.js');

// Linux
// define('BASE_DIR', '/home/ganlv/Downloads');
// define('OUTPUT_FILE', BASE_DIR . '/list.json');
// define('OUTPUT_FILE', BASE_DIR . '/list.js');

$exclude_files = [
'/.fancyindex',
'/list.json',
'/list.js',
];



// ==================================================

define('JSONP_CALLBACK', '__jsonpCallbackDown52PojieCn');
date_default_timezone_set('Asia/Shanghai');

foreach ($exclude_files as &$file) {
$file = BASE_DIR . $file;
}
$list = scan(BASE_DIR, $exclude_files);
file_put_contents(OUTPUT_FILE, json_encode($list, JSON_UNESCAPED_UNICODE));

$output = json_encode($list, JSON_UNESCAPED_UNICODE);
if (substr(OUTPUT_FILE, -2) === '.js') {
$output = JSONP_CALLBACK . '(' . $output . ');';
}
file_put_contents(OUTPUT_FILE, $output);

function scan($dir, $exclude_files = [])
{
Expand Down

0 comments on commit 7a2ae33

Please sign in to comment.