# HG changeset patch # User julfers # Date 1393973925 18000 # Tue Mar 04 17:58:45 2014 -0500 # Node ID 0c1265d5fedbdb88d41ed1be1601bf8fad5163f0 # Parent 11893fcf29fc30ecec40d6034a1c4d02992b5aaf Script order diff --git a/dss.py b/dss.py --- a/dss.py +++ b/dss.py @@ -26,11 +26,6 @@ ''') -def _prune_dirs(dirs): - for dirname in dirs: - if dirname[0] == '.' or dirname =='_site': - dirs.remove(dirname) - def _normpath(p): return path.normcase(path.normpath(path.abspath(p))) @@ -108,15 +103,17 @@ continue script_path = path.join(root, script) relpath = path.relpath(script_path, self.source) - # TODO: in *.nix, files can have a backslash in their names... deal with that? - scripts.append(relpath.replace('\\', '/')) # for Windows + # In *.nix, paths may contain backslashes. Don't worry about psychos who do that. + scripts.insert(0, relpath.replace('\\', '/')) # for Windows return scripts def _walk_source(self): for root, dirs, files in os.walk(self.source): - for dirname in dirs: - if dirname[0] == '.' or dirname == '_site': - dirs.remove(dirname) + dirs.sort() + files.sort() + remove = [d for d in dirs if d[0] == '.' or d == '_site'] + for dirname in remove: + dirs.remove(dirname) yield root, dirs, [f for f in files if f[0] != '.' or f == '.htaccess'] def compile(self): @@ -159,6 +156,7 @@ def do_GET(request): # TODO: expire immediately + # TODO: race condition when reloading during a compile # TODO: tests for this site.compile() SimpleHTTPRequestHandler.do_GET(request) diff --git a/test.py b/test.py --- a/test.py +++ b/test.py @@ -43,16 +43,17 @@ page_contains(r'.*Becomes content.*') page_contains(r'') # TODO: html escape js paths + page_contains(r'') page_contains(r'') - page_contains(r'') page_contains(r'') def test_render_default_subdir(self): DeadSimpleSite('test').compile() page_contains = page_contain_assertion(self, 'test/_site/subdir/page.html') page_contains(r'') - page_contains(r'') - page_contains(r'') + # TODO: test for script alphabetical ordering + # Notice this tests script depth ordering: + page_contains(r'.*.*') # TODO: rst includes DeadSimpleSite('test').compile() not_page_contains = page_contain_assertion(self, 'test/_site/subdir/page.html', invert=True) @@ -63,8 +64,8 @@ DeadSimpleSite('test').compile() page_contains = page_contain_assertion(self, 'test/_site/custom.html') page_contains(r'') + page_contains(r'') page_contains(r'') - page_contains(r'') page_contains(r'Title From Content') page_contains(r'ReStructured Text content') page_contains(r'

Some html content

') diff --git a/test/js/foo.js b/test/js/first/foo.js rename from test/js/foo.js rename to test/js/first/foo.js diff --git a/tutorial.rst b/tutorial.rst --- a/tutorial.rst +++ b/tutorial.rst @@ -30,11 +30,16 @@ Make sure a blank line follows it. -When you reload the page, its source should appear: +When Dead Simple compiles a site, it links all files with a ``.js`` extension in output html, so +when you reload the page, its source should appear: .. image:: img/simple-world-with-source.png :alt: Hello world page displaying source screenshot :target: tutorial/2/index.html +So scripts can load in a well-defined order, Dead Simple sorts scripts by deepest nested first, then +alphabetically. If your JavaScript lives in the ``js`` folder, then, and depends on jQuery, put +jQuery in ``js/lib`` to ensure that it loads first. + .. _getting started: index.html#getting-started .. _dss.py: dss.py