fix template locations

This commit is contained in:
Nick Sweeting 2018-06-10 21:12:55 -04:00
parent d0f2e693b3
commit a287900345
5 changed files with 18 additions and 22 deletions

View file

@ -142,7 +142,7 @@ env CHROME_BINARY=google-chrome-stable RESOLUTION=1440,900 FETCH_PDF=False ./arc
**Shell Options:**
- colorize console ouput: `USE_COLOR` value: [`True`]/`False`
- show progress bar: `SHOW_PROGRESS` value: [`True`]/`False`
- archive permissions: `ARCHIVE_PERMISSIONS` values: [`755`]/`644`/`...`
- archive permissions: `OUTPUT_PERMISSIONS` values: [`755`]/`644`/`...`
**Dependency Options:**
- path to Chrome: `CHROME_BINARY` values: [`chromium-browser`]/`/usr/local/bin/google-chrome`/`...`

View file

@ -18,7 +18,7 @@ from index import (
parse_json_link_index,
)
from config import (
ARCHIVE_PERMISSIONS,
OUTPUT_PERMISSIONS,
OUTPUT_DIR,
ANSI,
TIMEOUT,

View file

@ -24,29 +24,28 @@ FETCH_FAVICON = os.getenv('FETCH_FAVICON', 'True'
SUBMIT_ARCHIVE_DOT_ORG = os.getenv('SUBMIT_ARCHIVE_DOT_ORG', 'True' ).lower() == 'true'
RESOLUTION = os.getenv('RESOLUTION', '1440,1200' )
CHECK_SSL_VALIDITY = os.getenv('CHECK_SSL_VALIDITY', 'True' ).lower() == 'true'
ARCHIVE_PERMISSIONS = os.getenv('ARCHIVE_PERMISSIONS', '755' )
OUTPUT_PERMISSIONS = os.getenv('OUTPUT_PERMISSIONS', '755' )
CHROME_BINARY = os.getenv('CHROME_BINARY', 'chromium-browser' ) # change to google-chrome browser if using google-chrome
WGET_BINARY = os.getenv('WGET_BINARY', 'wget' )
WGET_USER_AGENT = os.getenv('WGET_USER_AGENT', None)
CHROME_USER_DATA_DIR = os.getenv('CHROME_USER_DATA_DIR', None)
TIMEOUT = int(os.getenv('TIMEOUT', '60'))
LINK_INDEX_TEMPLATE = os.getenv('LINK_INDEX_TEMPLATE', 'templates/link_index_fancy.html')
INDEX_TEMPLATE = os.getenv('INDEX_TEMPLATE', 'templates/index.html')
INDEX_ROW_TEMPLATE = os.getenv('INDEX_ROW_TEMPLATE', 'templates/index_row.html')
TEMPLATE_STATICFILES = os.getenv('TEMPLATE_STATICFILES', 'templates/static')
FOOTER_INFO = os.getenv('FOOTER_INFO', 'Content is hosted for personal archiving purposes only. Contact server owner for any takedown requests.',)
### Paths
REPO_DIR = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..'))
OUTPUT_DIR = os.path.abspath(os.path.join(REPO_DIR, 'output'))
SOURCES_DIR = os.path.abspath(os.path.join(OUTPUT_DIR, 'sources'))
OUTPUT_DIR = os.path.join(REPO_DIR, 'output')
SOURCES_DIR = os.path.join(OUTPUT_DIR, 'sources')
PYTHON_PATH = os.path.join(REPO_DIR, 'archiver')
TEMPLATES_DIR = os.path.join(PYTHON_PATH, 'templates')
# ******************************************************************************
# ********************** Do not edit below this point **************************
# ******************************************************************************
### Terminal Configuration
os.chdir(os.path.join(REPO_DIR, 'archiver'))
TERM_WIDTH = shutil.get_terminal_size((100, 10)).columns
ANSI = {
'reset': '\033[00;00m',

View file

@ -6,11 +6,8 @@ from string import Template
from distutils.dir_util import copy_tree
from config import (
INDEX_TEMPLATE,
INDEX_ROW_TEMPLATE,
LINK_INDEX_TEMPLATE,
TEMPLATE_STATICFILES,
ARCHIVE_PERMISSIONS,
TEMPLATES_DIR,
OUTPUT_PERMISSIONS,
ANSI,
GIT_SHA,
FOOTER_INFO,
@ -73,12 +70,12 @@ def write_html_links_index(out_dir, links):
path = os.path.join(out_dir, 'index.html')
copy_tree(TEMPLATE_STATICFILES, os.path.join(out_dir, "static"))
copy_tree(os.path.join(TEMPLATES_DIR, 'static'), os.path.join(out_dir, 'static'))
with open(INDEX_TEMPLATE, 'r', encoding='utf-8') as f:
with open(os.path.join(TEMPLATES_DIR, 'index.html'), 'r', encoding='utf-8') as f:
index_html = f.read()
with open(INDEX_ROW_TEMPLATE, 'r', encoding='utf-8') as f:
with open(os.path.join(TEMPLATES_DIR, 'index_row.html'), 'r', encoding='utf-8') as f:
link_row_html = f.read()
link_rows = '\n'.join(
@ -130,7 +127,7 @@ def parse_json_link_index(out_dir):
return {}
def write_html_link_index(out_dir, link):
with open(LINK_INDEX_TEMPLATE, 'r', encoding='utf-8') as f:
with open(os.path.join(TEMPLATES_DIR, 'link_index_fancy.html'), 'r', encoding='utf-8') as f:
link_html = f.read()
path = os.path.join(out_dir, 'index.html')

View file

@ -12,7 +12,7 @@ from urllib.parse import quote
from config import (
IS_TTY,
ARCHIVE_PERMISSIONS,
OUTPUT_PERMISSIONS,
REPO_DIR,
SOURCES_DIR,
OUTPUT_DIR,
@ -97,7 +97,7 @@ def check_dependencies():
raise SystemExit(1)
def chmod_file(path, cwd='.', permissions=ARCHIVE_PERMISSIONS, timeout=30):
def chmod_file(path, cwd='.', permissions=OUTPUT_PERMISSIONS, timeout=30):
"""chmod -R <permissions> <cwd>/<path>"""
if not os.path.exists(os.path.join(cwd, path)):
@ -168,7 +168,7 @@ def progress(seconds=TIMEOUT, prefix=''):
def pretty_path(path):
"""convert paths like .../bookmark-archiver/archiver/../output/abc into output/abc"""
return path.replace(REPO_DIR, '')
return path.replace(REPO_DIR + '/', '')
def download_url(url):