Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/hugovincent/hyde into merg…
Browse files Browse the repository at this point in the history
…ebranch
  • Loading branch information
timo committed Aug 5, 2010
2 parents 99b6be2 + ad5961d commit 115816a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ You also need to set the ``THUMBNAIL_MAX_WIDTH`` and ``THUMBNAIL_MAX_HEIGHT`` va

You can set the ``THUMBNAIL_FILENAME_POSTFIX`` to change the string that is appended to the filename of thumbnails. By default this is ``-thumb`` (i.e. the thumbnail of ``my-image.png`` will be called ``my-image-thumb.png``).

You can optionally set the ``THUMBNAIL_JPEG_QUALITY`` (between 0 and 100) to control the JPEG compression quality.

[PIL]: http://www.pythonware.com/products/pil/

### Content Processors
Expand Down
5 changes: 4 additions & 1 deletion hydeengine/media_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,7 @@ def process(resource):
postfix = "-thumb"
thumb_path = "%s%s.%s" % (orig_path, postfix, orig_extension)

i.save(thumb_path)
if i.format == "JPEG" and "THUMBNAIL_JPEG_QUALITY" in dir(settings):
i.save(thumb_path, quality = settings.THUMBNAIL_JPEG_QUALITY, optimize = True)
else:
i.save(thumb_path)
29 changes: 29 additions & 0 deletions hydeengine/site_post_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@
import commands
import codecs

class YUICompressor:

@staticmethod
def process(folder, params):
class Compressor:
def visit_file(self, thefile):
if settings.YUI_COMPRESSOR == None:
return
compress = settings.YUI_COMPRESSOR
if not os.path.exists(compress):
compress = os.path.join(
os.path.dirname(
os.path.abspath(__file__)), "..", compress)

if not compress or not os.path.exists(compress):
raise ValueError(
"YUI Compressor cannot be found at [%s]" % compress)

tmp_file = File(thefile.path + ".z-tmp")
status, output = commands.getstatusoutput(
u"java -jar %s %s > %s" % (compress, thefile.path, tmp_file.path))
if status > 0:
print output
else:
thefile.delete()
tmp_file.move_to(thefile.path)

folder.walk(Compressor(), "*.css")

class FolderFlattener:

@staticmethod
Expand Down
10 changes: 3 additions & 7 deletions hydeengine/templatetags/hydetags.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def excerpt(parser, token):
return BracketNode("Excerpt", nodelist)

@register.tag(name="article")
def excerpt(parser, token):
def article(parser, token):
nodelist = parser.parse(('endarticle',))
parser.delete_first_token()
return BracketNode("Article", nodelist)
Expand All @@ -59,8 +59,6 @@ def __init__(self, path, words = 50):

def render(self, context):
sitemap_node = None
if not self.words == 50:
self.words = self.words.render(context)
self.path = self.path.render(context).strip('"')
sitemap_node = context["site"].find_node(Folder(self.path))
if not sitemap_node:
Expand Down Expand Up @@ -149,7 +147,7 @@ def latest_excerpt(parser, token):
if len(tokens) > 1:
path = Template(tokens[1])
if len(tokens) > 2:
words = Template(tokens[2])
words = int(tokens[2])
return LatestExcerptNode(path, words)

@register.tag(name="render_excerpt")
Expand All @@ -160,7 +158,7 @@ def render_excerpt(parser, token):
if len(tokens) > 1:
path = parser.compile_filter(tokens[1])
if len(tokens) > 2:
words = Template(tokens[2])
words = int(tokens[2])
return RenderExcerptNode(path, words)

@register.tag(name="render_article")
Expand All @@ -177,8 +175,6 @@ def __init__(self, page, words = 50):
self.words = words

def render(self, context):
if not self.words == 50:
self.words = self.words.render(context)
page = self.page.resolve(context)
context["excerpt_url"] = page.url
context["excerpt_title"] = page.title
Expand Down
Binary file renamed lib/yuicompressor-2.4.1.jar → lib/yuicompressor-2.4.2.jar
100644 → 100755
Binary file not shown.

0 comments on commit 115816a

Please sign in to comment.