Make packaging work

This commit is contained in:
dave 2018-09-09 16:44:10 -07:00
parent f75283b1a2
commit 75c931c7d4
6 changed files with 48 additions and 1533 deletions

12
.gitignore vendored Normal file
View File

@ -0,0 +1,12 @@
build/
cache/
dist/
dropbox/
library/
node_modules/
photoapp.egg-info/
photos.db
styles/css/
styles/dist/
styles/mincss/
testenv/

View File

@ -42,5 +42,5 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['less:website', 'cssmin:website', 'concat:dist', 'watch']); grunt.registerTask('default', ['less:website', 'cssmin:website', 'concat:dist']);
}; };

1525
package-lock.json generated

File diff suppressed because it is too large Load Diff

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "photoapp",
"version": "1.0.0",
"description": "",
"main": null,
"dependencies": {
"grunt": "^1.0.3",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-cssmin": "^3.0.0",
"grunt-contrib-less": "^2.0.0",
"grunt-contrib-watch": "^1.1.0",
"purecss": "^1.0.0"
},
"devDependencies": {},
"scripts": {},
"author": "",
"license": "ISC"
}

View File

@ -2,15 +2,19 @@ import os
import cherrypy import cherrypy
import logging import logging
from photoapp.library import PhotoLibrary from photoapp.library import PhotoLibrary
from photoapp.types import Photo, PhotoSet from photoapp.types import Photo, PhotoSet, Tag, TagItem
from jinja2 import Environment, FileSystemLoader, select_autoescape from jinja2 import Environment, FileSystemLoader, select_autoescape
from sqlalchemy.exc import IntegrityError
from sqlalchemy import func from sqlalchemy import func
APPROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "../"))
class PhotosWeb(object): class PhotosWeb(object):
def __init__(self, library): def __init__(self, library, template_dir):
self.library = library self.library = library
self.tpl = Environment(loader=FileSystemLoader('templates'), self.tpl = Environment(loader=FileSystemLoader(template_dir),
autoescape=select_autoescape(['html', 'xml'])) autoescape=select_autoescape(['html', 'xml']))
self.tpl.globals.update(mime2ext=self.mime2ext) self.tpl.globals.update(mime2ext=self.mime2ext)
self.tpl.filters['basename'] = os.path.basename self.tpl.filters['basename'] = os.path.basename
@ -92,7 +96,7 @@ class ThumbnailView(object):
if thumb_path: if thumb_path:
return cherrypy.lib.static.serve_file(thumb_path, "image/jpeg") return cherrypy.lib.static.serve_file(thumb_path, "image/jpeg")
else: else:
return cherrypy.lib.static.serve_file(os.path.abspath("styles/dist/unknown.svg"), "image/svg+xml") return cherrypy.lib.static.serve_file(os.path.join(APPROOT, "styles/dist/unknown.svg"), "image/svg+xml")
@cherrypy.popargs('item_type', 'uuid') @cherrypy.popargs('item_type', 'uuid')
@ -153,7 +157,9 @@ def main():
library = PhotoLibrary(args.database_path, args.library) library = PhotoLibrary(args.database_path, args.library)
web = PhotosWeb(library) tpl_dir = os.path.join(APPROOT, "templates") if not args.debug else "templates"
web = PhotosWeb(library, tpl_dir)
web_config = {} web_config = {}
# TODO make auth work again # TODO make auth work again
@ -170,7 +176,7 @@ def main():
cherrypy.tree.mount(web, '/', {'/': web_config, cherrypy.tree.mount(web, '/', {'/': web_config,
'/static': {"tools.staticdir.on": True, '/static': {"tools.staticdir.on": True,
"tools.staticdir.dir": os.path.abspath("./styles/dist")}}) "tools.staticdir.dir": os.path.join(APPROOT, "styles/dist") if not args.debug else os.path.abspath("styles/dist")}})
cherrypy.config.update({ cherrypy.config.update({
# 'sessionFilter.on': True, # 'sessionFilter.on': True,

View File

@ -21,4 +21,8 @@ setup(name='photoapp',
"photovalidate = photoapp.validate:main", "photovalidate = photoapp.validate:main",
"photoinfo = photoapp.image:main" "photoinfo = photoapp.image:main"
] ]
}) },
include_package_data=True,
package_data={'photoapp': ['../templates/*.html',
'../styles/dist/*']},
zip_safe=False)