Noob stumbles coming out of the gate

150 views
Skip to first unread message

Tom Maynard

unread,
Sep 29, 2012, 12:33:05 PM9/29/12
to clj-...@googlegroups.com
After recent discussion on the Clojure list I decided to give Noir a try.  While initially promising, I put a wheel in the ditch almost immediately.

Steps:

1. (Lein2 already installed)
2. lein new noir my-app
3. lein run
    ;; longish pause
4. Browse to localhost:8080
5. Edit src/my-app/views/welcome.clj
6. Append
    (defpage "/my-page" []
      (html
        [:h1 "This is my first page!"]))
7. Save file
8. Browse to localhost:8080/my-page

And <blammo!>
one of two things occur:

A. Messy errors from the JVM about "html" not being resolved
    java.lang.RuntimeException: Unable to resolve symbol: html in this context, compiling:(my_app/views/welcome.clj:11) - (class clojure.lang.Compiler$CompilerException)

B. A more polite error from Noir about "no such page"  

    We seem to have lost that one.

And there I am stalled.  I found another example using "html5" but that fails to work as well.  It can't be that broken out of the box, what am I doing completely wrong?

Tom.

Chris Granger

unread,
Sep 29, 2012, 12:54:56 PM9/29/12
to clj-...@googlegroups.com
You need to bring the html function into scope. In your NS declaration add (:use [hiccup.core :only [html]])

Cheers,
Chris.

Tom Maynard

unread,
Sep 29, 2012, 2:55:13 PM9/29/12
to clj-...@googlegroups.com
On 09/29/2012 11:54 AM, Chris Granger wrote:
You need to bring the html function into scope. In your NS declaration add (:use [hiccup.core :only [html]])


Of course that was exactly the solution I sought.  The "directions" I followed were flawed (from the http://localhost:8080 display):

  • (defpage "/my-page" []
      (html
        [:h1 "This is my first page!"]))
  • Time to get going with our first page. Let's open views/welcome.clj and use (defpage) to add a new page to our site. With that we can go to http://localhost:8080/my-page and see our handiwork.

  • (defpartial site-layout [& content]
      (html5
        [:head
          [:title "my site"]]
        [:body
          [:div#wrapper
            content]]))

I will be more than happy to update that content (or to reset the defaults in the welcome.clj file, if that's preferable) ... but naturally I have no idea how either of those tasks are done.

Thanks for your help.
Tom.

Simone Mosciatti

unread,
Sep 30, 2012, 4:04:32 AM9/30/12
to clj-...@googlegroups.com
Your problem is with hiccup and not with noir...

Anyway, you should give another look at the doc, that i found great for noir http://webnoir.org/
and to the hiccup one, good as well... https://github.com/weavejester/hiccup

If you have more specific question please ask...

I should not tell you, but in your example you can try something like:

(site-layout (html5 [:p "My content"]))

Tom Maynard

unread,
Sep 30, 2012, 6:01:18 AM9/30/12
to clj-...@googlegroups.com
On 09/30/2012 03:04 AM, Simone Mosciatti wrote:
Your problem is with hiccup and not with noir...


That may very well be true, but I was simply following the directions which appear on the very first webpage after starting Noir for the first time.  No such distinction is made on my "new home page" (i.e. localhost:8080).  Here is a snip from that very first screen:




give another look at the doc, that i found great for noir http://webnoir.org/

That's quite true, but for a first timer like myself, I found the instructions appearing on the startup page to be rather compelling (if incomplete).  It was a bit frustrating when they failed to work (as the above clip shows).

It seems a simple matter to alter the text appearing there to include the required changes at the top of the welcome.clj file as well as those at the bottom ... or to have "html" included from the start ... hence my offer to change the defaults myself.  One only needs to know where to look!



> and to the hiccup one, good as well... https://github.com/weavejester/hiccup


No doubt that's also true!  But I continue to call out that there is no mention of hiccup, or the possibility of finding doc there, on that very first page (above).  [Yes, hiccup is mentioned on the Noir git page, but that was long forgotten by the time I had my own Noir server running locally.]



If you have more specific question please ask...


Well, my more specific question is now, "How can I contribute to the Noir project by updating the default start page to include the single line that makes the tutorial/introduction work?"  The recent discussion on the Clojure list was as much about documentation issues as about Clojure web frameworks.  I tried the Noir "framework," found the documentation a bit lacking, and offered to help (especially while the experience is fresh in mind).

If asking first is the expected path to mastery, then that's also fine: but that first page should explain that, instead (e.g. "To add another page, simply ask for directions on the Noir Google group").

Tom.




Anthony Grimes

unread,
Sep 30, 2012, 6:40:44 AM9/30/12
to clj-...@googlegroups.com
I apologize for that guy. Not sure if it was perhaps well intentioned but lost in translation, so I'm witholding further judgement. Your questions were not unreasonable. To answer your final question (where how to contribute to this particular piece of documentation), you'll want to open a pull request and edit https://github.com/noir-clojure/noir/blob/master/src/noir/content/getting_started.clj

Simone Mosciatti

unread,
Sep 30, 2012, 7:28:20 AM9/30/12
to clj-...@googlegroups.com


On Sunday, September 30, 2012 12:01:21 PM UTC+2, Tom Maynard wrote:

On 09/30/2012 03:04 AM, Simone Mosciatti wrote:
Your problem is with hiccup and not with noir...

That may very well be true, but I was simply following the directions which appear on the very first webpage after starting Noir for the first time.  No such distinction is made on my "new home page" (i.e. localhost:8080).  Here is a snip from that very first screen:

Sorry, I can't understand you... You are not suppose to follow the very first page, that page is giving you just a "screenshoot" of how noir code look likes... If it is what you are looking for...
 



give another look at the doc, that i found great for noir http://webnoir.org/

That's quite true, but for a first timer like myself, I found the instructions appearing on the startup page to be rather compelling (if incomplete).  It was a bit frustrating when they failed to work (as the above clip shows).


As above, read the tutorial and take a look also at the tutorials...
  
> and to the hiccup one, good as well... https://github.com/weavejester/hiccup


No doubt that's also true!  But I continue to call out that there is no mention of hiccup, or the possibility of finding doc there, on that very first page (above).  [Yes, hiccup is mentioned on the Noir git page, but that was long forgotten by the time I had my own Noir server running locally.]

I don't know what are you talking about, from the webnoir.org home page:
Now let's make it do something. Noir uses Hiccup to generate HTML. Hiccup represents html elements as vectors where the first keyword is the name of the tag and everything else is the content. With Noir you can define functions that return HTML by using the (defpartial) macro. The code to the right, for example, shows how you could generate an unordered list of todos. 


You may also find usefull this tutorial that I wrote (full disclaimer) that may be in the doc...

Chris Granger

unread,
Sep 30, 2012, 12:16:18 PM9/30/12
to clj-...@googlegroups.com
Simone - You *are* supposed to be able to follow that page. This was an error made when transitioning to (:use .. :only []) in the template and forgetting to add html to the list. It is a completely valid complaint and should get fixed.

Tom - thanks for the report and sorry for the troubles.

Cheers,
Chris.

Tom Maynard

unread,
Sep 30, 2012, 12:26:34 PM9/30/12
to clj-...@googlegroups.com
On 09/30/2012 05:40 AM, Anthony Grimes wrote:
> Your questions were not unreasonable. To answer your final question
> (where how to contribute to this particular piece of documentation),
> you'll want to open a pull request and
> edit https://github.com/noir-clojure/noir/blob/master/src/noir/content/getting_started.clj
>
>

Thank you for that, Anthony. I did clone the project, and began editing
the getting_started file, but quickly realized that I simply don't know
enough about noir/hiccup to make the changes properly..

I will study the sources, however, and will certainly make a pull
request if I believe my changes are correct. Thanks for your help.

Tom.

Tom Maynard

unread,
Sep 30, 2012, 12:38:40 PM9/30/12
to clj-...@googlegroups.com
On 09/30/2012 11:16 AM, Chris Granger wrote:
> Tom - thanks for the report and sorry for the troubles.

I only hope my observations did not sound like a complaint: Noir was
ridiculously easy to get going, as claimed. Since it's built on
Compojure I presume all that goodness lies buried within as well.

From my brief exposure (and a needed boost onto the shoulders of
giants) I think Noir is indeed a splendid "Clojure web framework."

Which leads me to my next query: How would you get a Noir website to run
on, say, a free hosting service? Is it impossible (meaning: would it
require the hosting service to have Noir/Clojure installed and running)?

I'd really like to take it up a notch, and getting it off my laptop is
the first step.

Thanks,
Tom.

Simone Mosciatti

unread,
Sep 30, 2012, 12:52:01 PM9/30/12
to clj-...@googlegroups.com


On Sunday, September 30, 2012 6:16:23 PM UTC+2, Chris Granger wrote:
Simone - You *are* supposed to be able to follow that page.
I was really... Ok sorry, I guess I am not expecting enough from open source projects...
Just one question for you Chris, Anthony Grimes said this in another post in the clojure group "Chris has things he wanted to see done first, things I don't intend to do, so it's mostly waiting on that." What he is talking about ? Just documentation ? Or something more ?

Simone Mosciatti

unread,
Sep 30, 2012, 12:55:07 PM9/30/12
to clj-...@googlegroups.com
Sorry Tom,

I know that my English is horrible and surely you don't have understand, but allow me to quote my own previous message that was direct to you:

You may also find useful this tutorial that I wrote (full disclaimer) that may be in the doc...

Xavi Caballé

unread,
Sep 30, 2012, 1:04:53 PM9/30/12
to clj-...@googlegroups.com
you may want to try Heroku, it's probably the simplest way to host a Clojure/Noir website, and it's free...

Mark Rathwell

unread,
Sep 30, 2012, 1:22:40 PM9/30/12
to clj-...@googlegroups.com
> Which leads me to my next query: How would you get a Noir website to run on,
> say, a free hosting service? Is it impossible (meaning: would it require
> the hosting service to have Noir/Clojure installed and running)?

Heroku has been mentioned, which is probably the easiest to get
started. Google App Engine is another option. See Appengine Magic
[1] and the changes to standard Noir app for running on GAE [2]

[1] https://github.com/gcv/appengine-magic
[2] https://gist.github.com/2356565

Tom Maynard

unread,
Sep 30, 2012, 1:55:05 PM9/30/12
to clj-...@googlegroups.com
On 09/30/2012 11:55 AM, Simone Mosciatti wrote:
I know that my English is horrible and surely you don't have understand

Q: What do you call someone who speaks 3 or more languages?
A: A polyglot.
Q: What do you call someone who speaks 2 languages?
A: Bilingual.
Q: What do you call someone who speaks only 1 language?
A: An American!

You never need to apologize for your "horrible English" ... I certainly never apologize for my abominable French, or my despicable Spanish ... but perhaps I did misunderstand.



You may also find useful this tutorial that I wrote (full disclaimer) that may be in the doc...


I'm looking at that now, and it could be quite helpful, indeed.  Thank you (A) for pointing it out, and (B) for reminding me about (A)!

Feel free to consider me as a Worst Case Scenario": I'm entering this realm completely naively.  I can only report events that broke the "Law of Least Astonishment" when I encountered them.  I will continue to do so, in hopes that I will learn, and that my "discoveries" can assist the development effort.

Back to your tutorial!
Tom.

Simone Mosciatti

unread,
Sep 30, 2012, 3:32:13 PM9/30/12
to clj-...@googlegroups.com
LoL

Yeah, sorry I was being nasty...

Matan Safriel

unread,
Oct 2, 2012, 8:19:49 AM10/2/12
to clj-...@googlegroups.com
Similar type of experience on my side.

lein new noir myapp creates new project.
lein compile fails with 
"Compiling noir.server
Exception in thread "main" java.lang.RuntimeException: No such var: server/load-views-ns, compiling:(noir/server.clj:4)"

Lein version: Leiningen 2.0.0-preview10 on Java 1.6.0_35 Java HotSpot(TM) Client VM
Any ideas what could be wrong?
Must be simple
Reply all
Reply to author
Forward
0 new messages