Skip to content

Commit

Permalink
add subdir prefix from config
Browse files Browse the repository at this point in the history
  • Loading branch information
jdub233 committed Jun 26, 2019
1 parent d53411b commit b5b299d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config.example.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CAPTURE_URL: "https://www.bu.edu"

SUBDIR_PREFIX: ""

#S3 Bucket details
S3_BUCKET_NAME: "static-page-bucket"
S3_PATH: "page"
9 changes: 6 additions & 3 deletions handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ const Url = require('url-parse');

const captureURL = new Url(process.env.CAPTURE_URL);

// Allow for a prefix to the subdirectory, and add a slash if it is set.
const subDirPrefix = (process.env.SUBDIR_PREFIX !== '') ? `${process.env.SUBDIR_PREFIX}/` : '';

const scrapeOptions = {
urls: [`${process.env.CAPTURE_URL}?cachebust=${Date.now()}`],
urlFilter: function(url) {
return url.indexOf(`${captureURL.protocol}//${captureURL.host}`) === 0;
},
directory: `/tmp/page-capture/capture-${Date.now()}`,
subdirectories: [
{directory: 'img', extensions: ['.jpg', '.png', '.svg', '.gif', '.mp4', '.webm', '.mov']},
{directory: 'js', extensions: ['.js']},
{directory: 'css', extensions: ['.css']}
{directory: `${subDirPrefix}img`, extensions: ['.jpg', '.png', '.svg', '.gif', '.mp4', '.webm', '.mov']},
{directory: `${subDirPrefix}js`, extensions: ['.js']},
{directory: `${subDirPrefix}css`, extensions: ['.css']}
],
};

Expand Down

0 comments on commit b5b299d

Please sign in to comment.