summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--photoblaster/_file.py3
-rw-r--r--photoblaster/modules/__init__.py14
-rwxr-xr-xphotoblaster/modules/pbgenerate/__init__.py5
-rwxr-xr-xphotoblaster/modules/pbgrid/__init__.py17
-rw-r--r--photoblaster/param/color.py11
-rw-r--r--photoblaster/server.py3
-rw-r--r--run_server.py8
-rw-r--r--share/frontend/gallery-static/js/gallery_isotope_config.js2
-rw-r--r--share/frontend/gallery-static/js/main.js5
9 files changed, 44 insertions, 24 deletions
diff --git a/photoblaster/_file.py b/photoblaster/_file.py
index a5a04ef..9fb0de2 100644
--- a/photoblaster/_file.py
+++ b/photoblaster/_file.py
@@ -143,8 +143,9 @@ class File(object):
def as_dict(self):
url = "%s/im/%s/%s" % (BASE_URL, self._hashdir, self.get_filename())
if self.get_storage() == "local":
- url = "http://%s/im/cache/%s" % (
+ url = "http://%s:%s/im/cache/%s" % (
SERVER_HOST,
+ SERVER_PORT,
self.get_filename()
)
dimensions = self.get_dimensions()
diff --git a/photoblaster/modules/__init__.py b/photoblaster/modules/__init__.py
index 0501fca..a752281 100644
--- a/photoblaster/modules/__init__.py
+++ b/photoblaster/modules/__init__.py
@@ -5,6 +5,7 @@ from subprocess import call
from photoblaster.params import Params
import simplejson as json
from photoblaster.db.models.imcmd import ImCmd
+from photoblaster.config import BIN_CONVERT
PLUGIN_FOLDER = "photoblaster/modules"
@@ -51,6 +52,19 @@ class ModuleBase(object):
self.width = None
self.height = None
+ def _make_canvas(self, width, height, color, filepath):
+ """
+ makes a canvas
+ """
+ dimensions = "{}x{}".format(width, height)
+ bgcolor = "xc:{}".format(color)
+ cmd = [
+ BIN_CONVERT,
+ "-size", dimensions, bgcolor,
+ filepath
+ ]
+ self._call_cmd(cmd)
+
def _call_cmd(self, cmd):
try:
cmd = map(lambda i: str(i), cmd)
diff --git a/photoblaster/modules/pbgenerate/__init__.py b/photoblaster/modules/pbgenerate/__init__.py
index a2aa2f8..419928b 100755
--- a/photoblaster/modules/pbgenerate/__init__.py
+++ b/photoblaster/modules/pbgenerate/__init__.py
@@ -194,6 +194,11 @@ class PbGenerate(ModuleBase):
cmd += [self.get_output_file().get_filepath()]
self._call_cmd(cmd)
+ def add_white_bg(self):
+ if not self.params.format == "jpg":
+ return
+
+
def create(self):
self._convert()
if self.params.background:
diff --git a/photoblaster/modules/pbgrid/__init__.py b/photoblaster/modules/pbgrid/__init__.py
index 38504bc..fbc027c 100755
--- a/photoblaster/modules/pbgrid/__init__.py
+++ b/photoblaster/modules/pbgrid/__init__.py
@@ -101,18 +101,12 @@ class PbGrid(ModuleBase):
#makes a canvas file...step 1 (if not bgimage)
def _make_canvas(self):
- dimensions = "{}x{}".format(
+ super(ModuleBase, self)._make_canvas(
self.params.width or DEFAULT_WIDTH,
- self.params.height or DEFAULT_HEIGHT
+ self.params.height or DEFAULT_HEIGHT,
+ self.params.bgcolor or 'transparent',
+ self.get_output_file().get_filepath()
)
- if self.params.bgimage:
- return
- bgcolor = "xc:{}".format(self.params.bgcolor or 'transparent')
- cmd = [
- BIN_CONVERT,
- "-size", dimensions, bgcolor,
- self.get_output_file().get_filepath()]
- self._call_cmd(cmd)
#2nd step-- run grid
def _grid_command(self):
@@ -215,7 +209,8 @@ class PbGrid(ModuleBase):
elif self.params.imageinstead:
self._prepare_gridimage(self.params.imageinstead)
else:
- self._make_canvas()
+ if not self.params.bgimage:
+ self._make_canvas()
self._grid_command()
if self.params.shadow:
self._shadow_cmd()
diff --git a/photoblaster/param/color.py b/photoblaster/param/color.py
index 64366e5..80a4642 100644
--- a/photoblaster/param/color.py
+++ b/photoblaster/param/color.py
@@ -1,6 +1,8 @@
"""Defines the color param type"""
from photoblaster.param import Param
import re
+
+
class Color(Param):
"""Defines the color param type
Args:
@@ -16,11 +18,16 @@ class Color(Param):
self.err_warn("Unable to sanitize the color: %s" % str(value))
self.err_warn(str(e))
-
def _color_sanitize(self, s):
if s == "":
return "transparent"
- if re.match('(rgba?\([0-9]+,[0-9]+,[0-9]+\))|([a-zA-Z]+)|(\#[A-Ha-h0-9]+)', s):
+ if re.match(
+ (
+ r'(rgba?\([0-9]+,[0-9]+,[0-9]+([0-9]\.[0-9])?\))|'
+ r'([a-zA-Z]+)|'
+ r'(\#[A-Ha-h0-9]+)'
+ ), s
+ ):
return s.replace(' ', '')
else:
self.err_warn("Not a color: {}\n".format(s))
diff --git a/photoblaster/server.py b/photoblaster/server.py
index b553a99..5732714 100644
--- a/photoblaster/server.py
+++ b/photoblaster/server.py
@@ -217,8 +217,9 @@ class Server(object):
results = ImCmd.search(**search_params)
images = results.limit(limit).offset(offset).all()
if LOCAL:
- images = ["http://%s/im/cache/%s" % (
+ images = ["http://%s:%s/im/cache/%s" % (
SERVER_HOST,
+ SERVER_PORT,
image.newfile
) for image in images]
else:
diff --git a/run_server.py b/run_server.py
index a380241..4f73404 100644
--- a/run_server.py
+++ b/run_server.py
@@ -16,14 +16,6 @@ if __name__ == "__main__":
"PB_PRODUCTION=1...ie\n"
"$>export PB_PRODUCTION=1\n"
)
- #test if nginx is running
- test = Popen(['pgrep', 'nginx'])
- test.communicate()
- if test.returncode:
- sys.stderr.write(
- "ERROR:\n"
- "you must start nginx to serve static content\n")
- sys.exit(1)
server.run(threaded=True, processes=4)
else:
server.run_wsgi()
diff --git a/share/frontend/gallery-static/js/gallery_isotope_config.js b/share/frontend/gallery-static/js/gallery_isotope_config.js
index b2be5d4..33f7ca8 100644
--- a/share/frontend/gallery-static/js/gallery_isotope_config.js
+++ b/share/frontend/gallery-static/js/gallery_isotope_config.js
@@ -120,7 +120,7 @@ $(function(){
}
}
});
- var sorter = {
+ window.sorter = {
date: function(){$container.isotope({sortBy: "date"})},
username: function(){$container.isotope({sortBy: "username"})},
height: function(){$container.isotope({sortBy: "height"})},
diff --git a/share/frontend/gallery-static/js/main.js b/share/frontend/gallery-static/js/main.js
index af22fa6..7d92b93 100644
--- a/share/frontend/gallery-static/js/main.js
+++ b/share/frontend/gallery-static/js/main.js
@@ -124,7 +124,12 @@ var Main =
if (! Main.editing)
Dump.showOlder()
break
+ case 83:
+ if (! Main.editing)
+ window.sorter.shuffle()
+ break
}
+ // S key
return true
},
poll: function ()