Browse Source

Fixed deploy path changes so that they happen at the beginning and are not dependent on generation. Removed noise from hyde.server - moved them to debug level

main
Lakshmi Vyasarajan 13 years ago
parent
commit
2c8685a602
5 changed files with 30 additions and 17 deletions
  1. +11
    -5
      hyde/ext/plugins/less.py
  2. +1
    -1
      hyde/ext/plugins/sorter.py
  3. +11
    -5
      hyde/ext/plugins/stylus.py
  4. +2
    -2
      hyde/generator.py
  5. +5
    -4
      hyde/server.py

+ 11
- 5
hyde/ext/plugins/less.py View File

@@ -18,6 +18,16 @@ class LessCSSPlugin(CLTransformer):
def __init__(self, site): def __init__(self, site):
super(LessCSSPlugin, self).__init__(site) super(LessCSSPlugin, self).__init__(site)


def begin_site(self):
"""
Find all the less css files and set their relative deploy path.
"""
for resource in self.site.content.walk_resources():
if resource.source_file.kind == 'less':
new_name = resource.source_file.name_without_extension + ".css"
target_folder = File(resource.relative_deploy_path).parent
resource.relative_deploy_path = target_folder.child(new_name)

def begin_text_resource(self, resource, text): def begin_text_resource(self, resource, text):
""" """
Replace @import statements with {% include %} statements. Replace @import statements with {% include %} statements.
@@ -70,8 +80,4 @@ class LessCSSPlugin(CLTransformer):
raise self.template.exception_class( raise self.template.exception_class(
"Cannot process %s. Error occurred when " "Cannot process %s. Error occurred when "
"processing [%s]" % (self.app.name, resource.source_file)) "processing [%s]" % (self.app.name, resource.source_file))
out = target.read_all()
new_name = resource.source_file.name_without_extension + ".css"
target_folder = File(resource.relative_path).parent
resource.relative_deploy_path = target_folder.child(new_name)
return out
return target.read_all()

+ 1
- 1
hyde/ext/plugins/sorter.py View File

@@ -96,8 +96,8 @@ class SorterPlugin(Plugin):
return return


for name, settings in config.sorter.__dict__.items(): for name, settings in config.sorter.__dict__.items():
self.logger.info("Adding sort methods for [%s]" % name)
sort_method_name = 'walk_resources_sorted_by_%s' % name sort_method_name = 'walk_resources_sorted_by_%s' % name
self.logger.debug("Adding sort methods for [%s]" % name)
add_method(Node, sort_method_name, sort_method, settings=settings) add_method(Node, sort_method_name, sort_method, settings=settings)
match_method_name = 'is_%s' % name match_method_name = 'is_%s' % name
add_method(Resource, match_method_name, filter_method, settings) add_method(Resource, match_method_name, filter_method, settings)


+ 11
- 5
hyde/ext/plugins/stylus.py View File

@@ -18,6 +18,16 @@ class StylusPlugin(CLTransformer):
def __init__(self, site): def __init__(self, site):
super(StylusPlugin, self).__init__(site) super(StylusPlugin, self).__init__(site)


def begin_site(self):
"""
Find all the styl files and set their relative deploy path.
"""
for resource in self.site.content.walk_resources():
if resource.source_file.kind == 'styl':
new_name = resource.source_file.name_without_extension + ".css"
target_folder = File(resource.relative_deploy_path).parent
resource.relative_deploy_path = target_folder.child(new_name)

def begin_text_resource(self, resource, text): def begin_text_resource(self, resource, text):
""" """
Replace @import statements with {% include %} statements. Replace @import statements with {% include %} statements.
@@ -95,8 +105,4 @@ class StylusPlugin(CLTransformer):
raise self.template.exception_class( raise self.template.exception_class(
"Cannot process %s. Error occurred when " "Cannot process %s. Error occurred when "
"processing [%s]" % (stylus.name, resource.source_file)) "processing [%s]" % (stylus.name, resource.source_file))
out = target.read_all()
new_name = resource.source_file.name_without_extension + ".css"
target_folder = File(resource.relative_path).parent
resource.relative_deploy_path = target_folder.child(new_name)
return out
return target.read_all()

+ 2
- 2
hyde/generator.py View File

@@ -95,7 +95,7 @@ class Generator(object):
""" """
Start Generation. Perform setup tasks and inform plugins. Start Generation. Perform setup tasks and inform plugins.
""" """
logger.info("Begin Generation")
logger.debug("Begin Generation")
self.events.begin_generation() self.events.begin_generation()


def load_site_if_needed(self): def load_site_if_needed(self):
@@ -112,7 +112,7 @@ class Generator(object):
""" """
Generation complete. Inform plugins and cleanup. Generation complete. Inform plugins and cleanup.
""" """
logger.info("Generation Complete")
logger.debug("Generation Complete")
self.events.generation_complete() self.events.generation_complete()


def get_dependencies(self, resource): def get_dependencies(self, resource):


+ 5
- 4
hyde/server.py View File

@@ -34,7 +34,7 @@ class HydeRequestHandler(SimpleHTTPRequestHandler):
and serve. and serve.
""" """
self.server.request_time = datetime.now() self.server.request_time = datetime.now()
logger.info("Processing request: [%s]" % self.path)
logger.debug("Processing request: [%s]" % self.path)
result = urlparse.urlparse(self.path) result = urlparse.urlparse(self.path)
query = urlparse.parse_qs(result.query) query = urlparse.parse_qs(result.query)
if 'refresh' in query or result.query=='refresh': if 'refresh' in query or result.query=='refresh':
@@ -73,6 +73,7 @@ class HydeRequestHandler(SimpleHTTPRequestHandler):


if not res: if not res:
logger.error("Cannot load file: [%s]" % path) logger.error("Cannot load file: [%s]" % path)
print site.content.resource_deploy_map


return site.config.deploy_root_path.child(path) return site.config.deploy_root_path.child(path)
else: else:
@@ -188,7 +189,7 @@ class HydeWebServer(HTTPServer):
return self.regenerate() return self.regenerate()


try: try:
logger.info('Generating node [%s]' % node)
logger.debug('Serving node [%s]' % node)
self.generator.generate_node(node, incremental=True) self.generator.generate_node(node, incremental=True)
except Exception, exception: except Exception, exception:
logger.error( logger.error(
@@ -206,9 +207,9 @@ class HydeWebServer(HTTPServer):
if not dest.exists: if not dest.exists:
return self.generate_node(resource.node) return self.generate_node(resource.node)
try: try:
logger.info('Generating resource [%s]' % resource)
logger.debug('Serving resource [%s]' % resource)
self.generator.generate_resource(resource, incremental=True) self.generator.generate_resource(resource, incremental=True)
except Exception, exception: except Exception, exception:
logger.error( logger.error(
'Error [%s] occured when generating the resource [%s]'
'Error [%s] occured when serving the resource [%s]'
% (repr(exception), resource)) % (repr(exception), resource))

Loading…
Cancel
Save