added var staticpath to templates to allow JS/CSS files to be reached with running on --local or archive

master
Castro0o 5 years ago
parent 72e71019ea
commit b59d8bae0e

@ -51,6 +51,7 @@ there should be an HTML [jinja2 template](https://jinja.palletsprojects.com/en/2
If not the `templates/default.html` will be used to render the pages under that Category. If not the `templates/default.html` will be used to render the pages under that Category.
**CSS/JS files** are stored in `static/`. See `templates/default.html` to see how it links to `static/archive.css`
--- ---

@ -19,7 +19,7 @@ p.add_argument("--one", default=False, action="store_true", help="Output one pag
p.add_argument("--local", default=False, action="store_true", help="When creating a local archives. Add full URL to images") p.add_argument("--local", default=False, action="store_true", help="When creating a local archives. Add full URL to images")
args = p.parse_args() args = p.parse_args()
print(args)
# site and login # site and login
site = Site(host=args.host, path=args.path) site = Site(host=args.host, path=args.path)
@ -83,7 +83,11 @@ for cat in publish.members():
print(p) print(p)
htmlsrc = site.parse(page=p.name)['text']['*'] htmlsrc = site.parse(page=p.name)['text']['*']
htmlsrc = rewritelinks(htmlsrc) htmlsrc = rewritelinks(htmlsrc)
html = template.render(page=p, body=htmlsrc) if args.local is True:
html = template.render(page=p, body=htmlsrc, staticpath='..')
else:
html = template.render(page=p, body=htmlsrc, staticpath='0')
with open(os.path.join(args.output, filenameforpage(p)), 'w') as f: with open(os.path.join(args.output, filenameforpage(p)), 'w') as f:
print(html, file=f) print(html, file=f)
if args.one: if args.one:

@ -0,0 +1,8 @@
body {
background-color: #aaa4a0;
}
a, a:visited{
color:black;
text-decoration: underline;
}

@ -2,8 +2,8 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="0/static/archive.css" /> <link rel="stylesheet" href="{{ staticpath }}/static/archive.css" />
<script type="text/javascript" src="0/static/archive.js"></script> <script type="text/javascript" src="{{ staticpath }}/static/archive.js"></script>
<title>{{ page.name }}</title> <title>{{ page.name }}</title>
</head> </head>
<body> <body>

@ -2,10 +2,10 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="0/static/archive.css" /> <link rel="stylesheet" href="{{ staticpath }}//static/archive.css" />
<script type="text/javascript" src="0/static/archive.js"></script> <script type="text/javascript" src="{{ staticpath }}//static/archive.js"></script>
<link rel="stylesheet" href="0/static/title.css" /> <link rel="stylesheet" href="{{ staticpath }}//static/title.css" />
<script type="text/javascript" src="0/static/title.js"></script> <script type="text/javascript" src="{{ staticpath }}//static/title.js"></script>
<title>{{ page.name }}</title> <title>{{ page.name }}</title>
</head> </head>
<body class="title"> <body class="title">

@ -2,10 +2,10 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="0/static/archive.css" /> <link rel="stylesheet" href="{{ staticpath }}/static/archive.css" />
<script type="text/javascript" src="0/static/archive.js"></script> <script type="text/javascript" src="{{ staticpath }}/static/archive.js"></script>
<link rel="stylesheet" href="0/static/title.css" /> <link rel="stylesheet" href="{{ staticpath }}/static/title.css" />
<script type="text/javascript" src="0/static/title.js"></script> <script type="text/javascript" src="{{ staticpath }}/static/title.js"></script>
<title>{{ page.name }}</title> <title>{{ page.name }}</title>
</head> </head>
<body class="title"> <body class="title">

Loading…
Cancel
Save