diff options
| -rw-r--r-- | TODO | 8 | ||||
| -rw-r--r-- | examples-for-debugging/controller_stuff (renamed from controller_stuff) | 0 | ||||
| -rw-r--r-- | examples-for-debugging/get_data.py (renamed from get_data.py) | 0 | ||||
| -rw-r--r-- | gallery/.ropeproject/config.py | 96 | ||||
| -rw-r--r-- | gallery/.ropeproject/globalnames | 1 | ||||
| -rw-r--r-- | gallery/.ropeproject/history | 1 | ||||
| -rw-r--r-- | gallery/.ropeproject/objectdb | 1 | ||||
| -rw-r--r-- | photoblaster/.ropeproject/globalnames | bin | 1385 -> 1808 bytes | |||
| -rw-r--r-- | photoblaster/config.py | 2 | ||||
| -rw-r--r-- | photoblaster/gallery.py | 39 | ||||
| -rw-r--r-- | photoblaster/server.py | 45 | ||||
| -rw-r--r-- | photoblaster/templates/gallery.html (renamed from share/frontend/gallery/index.html) | 35 | ||||
| -rw-r--r-- | run_server.py | 7 | ||||
| -rw-r--r-- | share/frontend/gallery-static/alternate.css (renamed from share/frontend/gallery/alternate.css) | 0 | ||||
| -rwxr-xr-x | share/frontend/gallery-static/gallery_style.css (renamed from share/frontend/gallery/gallery_style.css) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/ZeroClipboard.js (renamed from share/frontend/gallery/js/ZeroClipboard.js) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/gallery_isotope_config.js (renamed from share/frontend/gallery/js/gallery_isotope_config.js) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/jquery.isotope.min.js (renamed from share/frontend/gallery/js/jquery.isotope.min.js) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/jquery.js (renamed from share/frontend/gallery/js/jquery.js) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/main.js (renamed from share/frontend/gallery/js/main.js) | 32 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/pbembed.js (renamed from share/frontend/gallery/js/pbembed.js) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/querystring.js (renamed from share/frontend/gallery/js/querystring.js) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/js/title.js (renamed from share/frontend/gallery/js/title.js) | 0 | ||||
| -rw-r--r-- | share/frontend/gallery-static/main.css (renamed from share/frontend/gallery/main.css) | 2 | ||||
| -rw-r--r-- | share/frontend/gallery-static/style.css (renamed from share/frontend/gallery/style.css) | 0 | ||||
| -rw-r--r-- | test_gallery.py | 1 |
26 files changed, 76 insertions, 194 deletions
@@ -1,8 +0,0 @@ -the gallery -test second gallery method...hook it up to json -go on the server and reroute nginx to these static files - - -ON THE PLANE...install new imgrid -laundry -experiment with templates...maybe use one for gallery??? diff --git a/controller_stuff b/examples-for-debugging/controller_stuff index f945b63..f945b63 100644 --- a/controller_stuff +++ b/examples-for-debugging/controller_stuff diff --git a/get_data.py b/examples-for-debugging/get_data.py index 1bf8ca9..1bf8ca9 100644 --- a/get_data.py +++ b/examples-for-debugging/get_data.py diff --git a/gallery/.ropeproject/config.py b/gallery/.ropeproject/config.py deleted file mode 100644 index 3745e30..0000000 --- a/gallery/.ropeproject/config.py +++ /dev/null @@ -1,96 +0,0 @@ -# The default ``config.py`` - - -def set_prefs(prefs): - """This function is called before opening the project""" - - # Specify which files and folders to ignore in the project. - # Changes to ignored resources are not added to the history and - # VCSs. Also they are not returned in `Project.get_files()`. - # Note that ``?`` and ``*`` match all characters but slashes. - # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc' - # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc' - # '.svn': matches 'pkg/.svn' and all of its children - # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o' - # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o' - prefs['ignored_resources'] = [ - '*.pyc', '*~', '.ropeproject', '.hg', '.svn', '_svn', '.git', - '.tox', '.env', 'node_modules', 'bower_components'] - - # Specifies which files should be considered python files. It is - # useful when you have scripts inside your project. Only files - # ending with ``.py`` are considered to be python files by - # default. - #prefs['python_files'] = ['*.py'] - - # Custom source folders: By default rope searches the project - # for finding source folders (folders that should be searched - # for finding modules). You can add paths to that list. Note - # that rope guesses project source folders correctly most of the - # time; use this if you have any problems. - # The folders should be relative to project root and use '/' for - # separating folders regardless of the platform rope is running on. - # 'src/my_source_folder' for instance. - #prefs.add('source_folders', 'src') - - # You can extend python path for looking up modules - #prefs.add('python_path', '~/python/') - - # Should rope save object information or not. - prefs['save_objectdb'] = True - prefs['compress_objectdb'] = False - - # If `True`, rope analyzes each module when it is being saved. - prefs['automatic_soa'] = True - # The depth of calls to follow in static object analysis - prefs['soa_followed_calls'] = 0 - - # If `False` when running modules or unit tests "dynamic object - # analysis" is turned off. This makes them much faster. - prefs['perform_doa'] = True - - # Rope can check the validity of its object DB when running. - prefs['validate_objectdb'] = True - - # How many undos to hold? - prefs['max_history_items'] = 32 - - # Shows whether to save history across sessions. - prefs['save_history'] = True - prefs['compress_history'] = False - - # Set the number spaces used for indenting. According to - # :PEP:`8`, it is best to use 4 spaces. Since most of rope's - # unit-tests use 4 spaces it is more reliable, too. - prefs['indent_size'] = 4 - - # Builtin and c-extension modules that are allowed to be imported - # and inspected by rope. - prefs['extension_modules'] = [] - - # Add all standard c-extensions to extension_modules list. - prefs['import_dynload_stdmods'] = True - - # If `True` modules with syntax errors are considered to be empty. - # The default value is `False`; When `False` syntax errors raise - # `rope.base.exceptions.ModuleSyntaxError` exception. - prefs['ignore_syntax_errors'] = False - - # If `True`, rope ignores unresolvable imports. Otherwise, they - # appear in the importing namespace. - prefs['ignore_bad_imports'] = False - - # If `True`, rope will transform a comma list of imports into - # multiple separate import statements when organizing - # imports. - prefs['split_imports'] = False - - # If `True`, rope will sort imports alphabetically by module name - # instead of alphabetically by import statement, with from imports - # after normal imports. - prefs['sort_imports_alphabetically'] = False - - -def project_opened(project): - """This function is called after opening the project""" - # Do whatever you like here! diff --git a/gallery/.ropeproject/globalnames b/gallery/.ropeproject/globalnames deleted file mode 100644 index 29c40cd..0000000 --- a/gallery/.ropeproject/globalnames +++ /dev/null @@ -1 +0,0 @@ -€}q.
\ No newline at end of file diff --git a/gallery/.ropeproject/history b/gallery/.ropeproject/history deleted file mode 100644 index fcd9c96..0000000 --- a/gallery/.ropeproject/history +++ /dev/null @@ -1 +0,0 @@ -€]q(]q]qe.
\ No newline at end of file diff --git a/gallery/.ropeproject/objectdb b/gallery/.ropeproject/objectdb deleted file mode 100644 index 29c40cd..0000000 --- a/gallery/.ropeproject/objectdb +++ /dev/null @@ -1 +0,0 @@ -€}q.
\ No newline at end of file diff --git a/photoblaster/.ropeproject/globalnames b/photoblaster/.ropeproject/globalnames Binary files differindex 824f866..addb8d5 100644 --- a/photoblaster/.ropeproject/globalnames +++ b/photoblaster/.ropeproject/globalnames diff --git a/photoblaster/config.py b/photoblaster/config.py index c7eb7b5..0c211c7 100644 --- a/photoblaster/config.py +++ b/photoblaster/config.py @@ -1,4 +1,4 @@ -DEBUG = True +LOCAL = True MAX_SIZE = 1024 * 1024 * 1.2 * 1.5 diff --git a/photoblaster/gallery.py b/photoblaster/gallery.py deleted file mode 100644 index dfa913e..0000000 --- a/photoblaster/gallery.py +++ /dev/null @@ -1,39 +0,0 @@ -from photoblaster.db.pb import Pb - -BASE_HREF = "http://i.asdf.us/im/" -PARAMLIST = "addr start limit name interface random tag" -QUERY_LIMIT = 20 - -class Gallery(object): - def __init__(self): - self.pbdb = Pb() - - def select_random(self, - tag=None, - username=None, - start=None, - limit=QUERY_LIMIT): - filter_by = {} - if tag: - filter_by['tag'] = self._tag_translate(tag) - if username: - filter_by['username'] = username - columns = self.pbdb.get_random(filter_by=filter_by, - offset=start or 0, - limit=limit) - return columns #works - - def _tag_translate(self, tag): - return _TAG_TRANSLATE.get(tag, tag) - - def get_files(params): - """does a select * from im_cmd - with a where clause - the where clause needs to search by - name - id lt or gt - tag (using tag translate) - random (bool) - - normally the results are ordered by id descending - """ diff --git a/photoblaster/server.py b/photoblaster/server.py index b686b91..9896b7a 100644 --- a/photoblaster/server.py +++ b/photoblaster/server.py @@ -1,6 +1,6 @@ """All webserver logic lives here, including routes""" from flask import Flask, Response -from flask import request, jsonify +from flask import request, jsonify, render_template import sys import re @@ -14,7 +14,7 @@ from photoblaster.modules import PbGenerate, PbGrid, PbBreaker, PbPattern,\ from photoblaster.db.models.imcmd import ImCmd from photoblaster.param import BadParamError from photoblaster.config import SERVER_HOST, SERVER_PORT, STATIC_FOLDER, \ - DEBUG, GALLERY_TAG_TRANS + GALLERY_TAG_TRANS # FIXME add remote_addr and this jsonp thing @@ -118,22 +118,37 @@ class Server(object): @self.app.route('/im/gallery', methods=['GET']) def gallery(): search_params = {} + qs = [] if request.args.get('tag'): - search_params['tag'] = GALLERY_TAG_TRANS[request.arg.get('tag')] + search_params['tag'] = GALLERY_TAG_TRANS[request.args['tag']] + qs.append("tag=" + request.args['tag']) if request.args.get('name'): - search_params['name'] = request.args.get('name') + search_params['name'] = request.args['name'] + qs.append("name=" + request.args['name']) if request.args.get('addr'): - search_params['remote_addr'] = request.args.get('remote_addr') + search_params['remote_addr'] = request.args['remote_addr'] + qs.append("addr=" + request.args['addr']) limit = request.args.get('limit') or 20 - offset = request.args.get('start') or 0 - if not request.args.get('random'): - results = ImCmd.search(**search_params) - else: + if limit > 100: + limit = 100 + offset = int(request.args.get('start', 0)) + if request.args.get('random'): results = ImCmd.search_random(**search_params) - return json.dumps([ - model.as_dict() for model in - results.limit(limit).offset(offset).all() - ]) + qs.append("random=" + request.args['random']) + else: + results = ImCmd.search(**search_params) + images = results.limit(limit).offset(offset).all() + older = offset + limit + newer = offset - limit + qs = "&".join(qs) + + return render_template( + 'gallery.html', + images=images, + older=older, + newer=newer, + qs=qs + ) def _find_class_by_name(self, pb_classname): pb_classname = self._classname_aliases.get(pb_classname, None) \ @@ -168,8 +183,8 @@ class Server(object): sys.stderr.write(dict(request_form)) return jsonify({'error': 'Problem with server-side processing'}) - def run(self, host=SERVER_HOST, port=SERVER_PORT, debug=DEBUG): - self.app.run(host=host, port=port) + def run(self, host=SERVER_HOST, port=SERVER_PORT): + self.app.run(host=host, port=port, debug=True) def run_wsgi(self, server_port=SERVER_PORT, host=SERVER_HOST): # http://fgimian.github.io/blog/2012/12/08/setting-up-a-rock-solid-python-development-web-server/ diff --git a/share/frontend/gallery/index.html b/photoblaster/templates/gallery.html index 4e56f76..11e7395 100644 --- a/share/frontend/gallery/index.html +++ b/photoblaster/templates/gallery.html @@ -1,30 +1,43 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> -<script type="text/javascript" src="js/jquery.js"></script> +<script type="text/javascript" src="/gallery-static/js/jquery.js"></script> <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>--> <meta http-equiv="cache-control" content="max-age=0" /> <meta http-equiv="cache-control" content="no-cache" /> <meta http-equiv="expires" content="0" /> <meta http-equiv="pragma" content="no-cache" /> -<link href="main.css" rel="stylesheet" type="text/css" /> +<link href="/gallery-static/main.css" rel="stylesheet" type="text/css" /> -<script type="text/javascript" src="js/querystring.js"></script> -<script type="text/javascript" src="js/title.js"> </script> -<script type="text/javascript" src="js/jquery.isotope.min.js"></script> -<script type="text/javascript" src="js/gallery_isotope_config.js?v=3"></script> -<script type="text/javascript" src="/js/ZeroClipboard.js"></script> +<script type="text/javascript"> +var imagedata = [ +{% for image in images %} +["http://i.asdf.us/im/{{ image.dir }}/{{ image.newfile }}"], +{% endfor %} +] + +</script> +<script type="text/javascript" src="/gallery-static/js/querystring.js"></script> +<script type="text/javascript" src="/gallery-static/js/title.js"> </script> +<script type="text/javascript" src="/gallery-static/js/main.js"> </script> +<script type="text/javascript" src="/gallery-static/js/jquery.isotope.min.js"></script> +<script type="text/javascript" src="/gallery-static/js/gallery_isotope_config.js?v=3"></script> +<script type="text/javascript" src="/gallery-static/js/ZeroClipboard.js"></script> <script type="text/javascript" src="http://asdf.us/js/pbembed.js"></script> -<script type="text/javascript" src="js/main.js"> </script> -<link href="style.css" type="text/css" rel="stylesheet" /> +<link href="/gallery-static/style.css" type="text/css" rel="stylesheet" /> </head> <body> <div id='nextpage'> <a href='/im/'>editor</a> | + {% if newer < 0 %} <a id="newer">← newer</a> | - <a href='?random=1'>random</a> | - <a id="older">older →</a> + {% else %} + <a id="newer" href="?start={{ newer }}{% if qs|length %}&{% endif %}{{ qs }}">← newer</a> | + {% endif %} + + <a href='?random=1{% if qs|length %}&{% endif %}{{ qs }}'>random</a> | + <a id="older" href="?start={{ older }}{% if qs|length %}&{% endif %}{{ qs }}">older →</a> </div> <div id="help"> <b>key controls</b> diff --git a/run_server.py b/run_server.py index f29af41..0dd92f6 100644 --- a/run_server.py +++ b/run_server.py @@ -2,8 +2,13 @@ """script used to run the webserver""" import sys from photoblaster.server import Server +from photoblaster.config import LOCAL + server = Server() if __name__ == "__main__": - server.run_wsgi() + if LOCAL: + server.run() + else: + server.run_wsgi() diff --git a/share/frontend/gallery/alternate.css b/share/frontend/gallery-static/alternate.css index baa2643..baa2643 100644 --- a/share/frontend/gallery/alternate.css +++ b/share/frontend/gallery-static/alternate.css diff --git a/share/frontend/gallery/gallery_style.css b/share/frontend/gallery-static/gallery_style.css index 2d78a0e..2d78a0e 100755 --- a/share/frontend/gallery/gallery_style.css +++ b/share/frontend/gallery-static/gallery_style.css diff --git a/share/frontend/gallery/js/ZeroClipboard.js b/share/frontend/gallery-static/js/ZeroClipboard.js index 648a5b6..648a5b6 100644 --- a/share/frontend/gallery/js/ZeroClipboard.js +++ b/share/frontend/gallery-static/js/ZeroClipboard.js diff --git a/share/frontend/gallery/js/gallery_isotope_config.js b/share/frontend/gallery-static/js/gallery_isotope_config.js index b2be5d4..b2be5d4 100644 --- a/share/frontend/gallery/js/gallery_isotope_config.js +++ b/share/frontend/gallery-static/js/gallery_isotope_config.js diff --git a/share/frontend/gallery/js/jquery.isotope.min.js b/share/frontend/gallery-static/js/jquery.isotope.min.js index ea4afad..ea4afad 100644 --- a/share/frontend/gallery/js/jquery.isotope.min.js +++ b/share/frontend/gallery-static/js/jquery.isotope.min.js diff --git a/share/frontend/gallery/js/jquery.js b/share/frontend/gallery-static/js/jquery.js index 16ad06c..16ad06c 100644 --- a/share/frontend/gallery/js/jquery.js +++ b/share/frontend/gallery-static/js/jquery.js diff --git a/share/frontend/gallery/js/main.js b/share/frontend/gallery-static/js/main.js index 28f053c..3db8785 100644 --- a/share/frontend/gallery/js/main.js +++ b/share/frontend/gallery-static/js/main.js @@ -1,4 +1,18 @@ $(function(){ + for (var i=0; i< (imagedata.length - 1); i++){ + var newDiv = document.createElement("div"); + var newImage = document.createElement("img"); + newImage.src = imagedata[i][0]; + newImage.className = "pb"; + newDiv.appendChild(newImage); +// consider calling something like isotope add here...and ONLY APPENDING the image to the parent div once it has loaded +// $(newImage).load(function(){ +// }) + $("#images").append(newDiv); + } +}); + +$(function(){ $("b").addClass("pulsate_and_grow"); $(".sorting-options").click(function(){ @@ -54,11 +68,9 @@ var Dump = { }, showNewer: function() { - window.location.href = '?"""+newer_QS+"""' }, showOlder: function() { - window.location.href = '?"""+back_QS+"""' } } @@ -78,7 +90,6 @@ var Main = editing: false, kp: function (event) { - console.log(event.keyCode); switch (event.keyCode) { // BS @@ -140,21 +151,6 @@ var Main = -$(function(){ -var imagedata = [ ] //needs a synchronous call here - for (var i=0; i< (imagedata.length - 1); i++){ - var newDiv = document.createElement("div"); - var newImage = document.createElement("img"); - newImage.src = imagedata[i][0]; - newImage.className = "pb"; - newDiv.appendChild(newImage); -// consider calling something like isotope add here...and ONLY APPENDING the image to the parent div once it has loaded -// $(newImage).load(function(){ -// console.log("like a true playa"); -// }) - $("#images").append(newDiv); - } -}); $(function(){ //get params from the query string, and create diff --git a/share/frontend/gallery/js/pbembed.js b/share/frontend/gallery-static/js/pbembed.js index 97fa667..97fa667 100644 --- a/share/frontend/gallery/js/pbembed.js +++ b/share/frontend/gallery-static/js/pbembed.js diff --git a/share/frontend/gallery/js/querystring.js b/share/frontend/gallery-static/js/querystring.js index 79c2a4d..79c2a4d 100644 --- a/share/frontend/gallery/js/querystring.js +++ b/share/frontend/gallery-static/js/querystring.js diff --git a/share/frontend/gallery/js/title.js b/share/frontend/gallery-static/js/title.js index a9ac584..a9ac584 100644 --- a/share/frontend/gallery/js/title.js +++ b/share/frontend/gallery-static/js/title.js diff --git a/share/frontend/gallery/main.css b/share/frontend/gallery-static/main.css index b5a1af7..1201689 100644 --- a/share/frontend/gallery/main.css +++ b/share/frontend/gallery-static/main.css @@ -16,7 +16,7 @@ div img { } #images img { cursor: pointer; - display: none; +// display: none; } #dump { position: fixed; diff --git a/share/frontend/gallery/style.css b/share/frontend/gallery-static/style.css index 2d78a0e..2d78a0e 100644 --- a/share/frontend/gallery/style.css +++ b/share/frontend/gallery-static/style.css diff --git a/test_gallery.py b/test_gallery.py deleted file mode 100644 index 5c20903..0000000 --- a/test_gallery.py +++ /dev/null @@ -1 +0,0 @@ -from photoblaster.db.models |
