ajdavis / motor-blog

Blog based on Tornado, MongoDB, and Motor. To be used with MarsEdit.
148 stars 40 forks source link

Exception: unexpected token "attrs" in file base.jade on line 47 #36

Open versionzhang opened 8 years ago

versionzhang commented 8 years ago

Hello, I run the blog demo in my mac. But I visit localhost:8888/blog, I got some error.

The message error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 1445, in _execute
    result = yield result
  File "/usr/local/lib/python2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/usr/local/lib/python2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/usr/local/lib/python2.7/site-packages/tornado/gen.py", line 1014, in run
    yielded = self.gen.throw(*exc_info)
  File "/Users/fredzhang/tornado_blog_study/motor-blog-master/motor_blog/web/handlers.py", line 176, in get
    page_num=int(page_num))
  File "/usr/local/lib/python2.7/site-packages/tornado/gen.py", line 1008, in run
    value = future.result()
  File "/usr/local/lib/python2.7/site-packages/tornado/concurrent.py", line 232, in result
    raise_exc_info(self._exc_info)
  File "/usr/local/lib/python2.7/site-packages/tornado/gen.py", line 282, in wrapper
    yielded = next(result)
  File "/Users/fredzhang/tornado_blog_study/motor-blog-master/motor_blog/web/handlers.py", line 93, in render_async
    template_name, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/tornado/web.py", line 803, in render_string
    t = loader.load(template_name)
  File "/usr/local/lib/python2.7/site-packages/tornado/template.py", line 424, in load
    self.templates[name] = self._create_template(name)
  File "/usr/local/lib/python2.7/site-packages/tornado/template.py", line 452, in _create_template
    template = Template(f.read(), name=name, loader=self)
  File "/usr/local/lib/python2.7/site-packages/pyjade/ext/tornado/__init__.py", line 84, in __init__
    super(Template, self).__init__(template_string, name, *args,**kwargs)
  File "/usr/local/lib/python2.7/site-packages/tornado/template.py", line 304, in __init__
    self.code = self._generate_python(loader)
  File "/usr/local/lib/python2.7/site-packages/tornado/template.py", line 352, in _generate_python
    ancestors = self._get_ancestors(loader)
  File "/usr/local/lib/python2.7/site-packages/tornado/template.py", line 370, in _get_ancestors
    template = loader.load(chunk.name, self.name)
  File "/usr/local/lib/python2.7/site-packages/tornado/template.py", line 424, in load
    self.templates[name] = self._create_template(name)
  File "/usr/local/lib/python2.7/site-packages/tornado/template.py", line 452, in _create_template
    template = Template(f.read(), name=name, loader=self)
  File "/usr/local/lib/python2.7/site-packages/pyjade/ext/tornado/__init__.py", line 82, in __init__
    template_string = process(template_string,filename=name,compiler=Compiler)
  File "/usr/local/lib/python2.7/site-packages/pyjade/utils.py", line 228, in process
    block = _parser.parse()
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 46, in parse
    else: block.append(self.parseExpr())
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 84, in parseExpr
    return getattr(self,funcName)()
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 332, in parseTag
    block = self.block()
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 251, in block
    block.append(self.parseExpr())
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 84, in parseExpr
    return getattr(self,funcName)()
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 332, in parseTag
    block = self.block()
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 251, in block
    block.append(self.parseExpr())
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 84, in parseExpr
    return getattr(self,funcName)()
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 332, in parseTag
    block = self.block()
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 251, in block
    block.append(self.parseExpr())
  File "/usr/local/lib/python2.7/site-packages/pyjade/parser.py", line 87, in parseExpr
    (t, self.filename, self.line()))
Exception: unexpected token "attrs" in file base.jade on line 47
versionzhang commented 8 years ago

I have already fixed this problem. The newer jade syntax about javascript,should use . to write javascript code. line 50:

        script(type="text/javascript")
        script(type="text/javascript").

The other template should use the same syntax.

versionzhang commented 8 years ago

@ajdavis ,I am sorry to mention about you,But I find some syntax about jade templates which are different from newer version. I find another about the different syntax with it. base.jade line 37,

   div(class='backgroundplaceholder' + str(i))

The space between with background placeholder and str(i) should be removed.

I am a newbie about web developing and I study your project within these three days. Could I ask some questions about your code and themes.Thanks.

  1. I use the demo code to run, but I visit /about page,I get Page Not Found error. Should I add AboutHandler to handler.py? I found your blog has about page,I think whether my understanding is wrong.
  2. I find your theme divided the background image to six pieces, then load the image. I wanna ask why do it like this.
  3. photography in your blog, is this another web app or the code has already implement it.

Thanks.

ajdavis commented 8 years ago

Hi, thanks for investigating this problem, would you like to submit a pull request with the jade syntax fixes?

Other answers:

  1. There's a "/blog/about/" page on my site because I created a page with the slug "about" in MarsEdit. You don't need an "AboutHandler", it's just a page that you write in Markdown, not code.
  2. If you expand and contract the browser window, you'll see that I reveal and hide the background image in chunks so it's always clipped cleanly, instead of being overlapped by the text and partly hidden.
  3. The "photography" link goes to a static site generated from Flickr with https://github.com/ajdavis/Emptysquare-Slideshow , I don't recommend that you use that code, there are better solutions out there.
versionzhang commented 8 years ago

OK, But I modify some code files and I am not good at using git to manage my code, so maybe I will take some times to submit a pull request. I will do it after cleaning my code repo as soon as possible. :)

I almost have done to deploy to my vps.I use zc.buildout to setup all depending package and modify nginx.conf and supervisord.confto run the blog. I just copy your themes to display blog because I do not know how to modify these css and jade file. :) I found some little things can be modified:

  1. in README.md file, comand

    python server.py --debug --conf=motor\_blog.conf --ensure-indexes

    should be

    python server.py --debug --config=motor_blog.conf --ensure-indexes
  2. about config file for running supervisor. And if use supervisor to run tornado thread, should remove the file motor_blog.confabout the define port, otherwise only one thread will run.
  3. about disqus code. I build demo blog and write some test comments, if do not modify your name in the theme file about disqus code, the demo comments will show in your blog's disqus page. I think it could bother you to receive the comments.
ajdavis commented 8 years ago

Understood. Learning how to use git to contribute clean pull requests to a project you use is a very useful skill!

  1. Fixed, thanks.
  2. If you use the sample supervisord.conf it passes "--port" to server.py here, that overrides the port in motor_blog.conf, and allows you to run Motor-Blog processes on different ports
  3. Fixed in https://github.com/ajdavis/motor-blog/commit/adc1249698c21828498c96a4d2498fe59cc0e5f8