Re: A website written using Clojure.

2009-06-26 Thread Jonathan Smith

On Jun 25, 3:59 pm, Berlin Brown  wrote:
> On Jun 25, 3:52 pm, Mike Hinchey  wrote:
>
>
>
> > Instead of eval in the doseq, you could use a macro with a do block,
> > something like:
> > user> (defmacro deftags [tags]
> >         `(do ~@(map (fn [tag]
> >                       `(defn ~(symbol (str tag "-with"))
> >                          [block#] (str ~tag block#)))
> >                     tags)))
> > #'user/deftags
>
> > user> (deftags ["html"])
> > #'user/html-with
>
> > user> (html-with [1])
> > "html[1]"
>
> > -Mike
>
> > On Thu, Jun 25, 2009 at 11:51 AM, CuppoJava 
> > wrote:
>
> > > Thanks for the reply.
>
> > > I use doseq instead of map because I need it to run immediately, and
> > > I'm not interested in the return values of the functions.
>
> > > I also would love to be able to simply the (eval ...) part, but I
> > > don't know of any other way to dynamically define a function in
> > > Clojure. If you know of a way it'd help me out a lot.
> > >   -Patrick
>
> I am not looking at the code, I hate when people nitpick every snippet
> they see.  I don't think that gets anyone anywhere.
>
> But does anyone have a problem with Lisp/S-Expressions to HTML/XHtml,
> especially for the entire document.  What is wrong with using some
> form of templating system.  I think that is what Lisp has (see Lisp's
> Html-template).
>
> I am not talking about this particular application, but just in
> general.  I love the ability to take sections of HTML or snippets of
> HTML and use that as the View and then break that off from the
> application code.
>
> But that is just me.

Don't sort of you get that for 'free' with an s-expr system anyway?

You have 'syntax quote' (perfect for making templates) and very robust
mapping functions in clojure.

All you would have to do after that is keep all of your "html" list
generating functions (snippets) in a separate file?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-26 Thread Emeka
Stuart Sierra,


I want to use StringTemplate, could you give me a lead?


Emeka
On Thu, Jun 25, 2009 at 9:31 PM, Stuart Sierra
wrote:

>
> On Jun 25, 3:59 pm, Berlin Brown  wrote:
> > But does anyone have a problem with Lisp/S-Expressions to HTML/XHtml,
> > especially for the entire document.  What is wrong with using some
> > form of templating system.
>
> Yes, I'm partial to StringTemplate, a Java template framework.  Very
> simple, like a functional language itself.
> http://www.stringtemplate.org/
>
> -SS
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread CuppoJava

That's a good point. Dimming the lines would be a good idea. I
originally tried to make the text actually line up with the lines, but
that was a nightmare, and it didn't contribute much to the final
effect.

Scheme is a great language. If I needed to work on a project that runs
natively (ie. not on a VM) scheme would be my first choice. I still
envy Scheme's first-class continuations, and wish Clojure had them.

 -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Nicolas Buduroi

> I'm not running off any server. All the pages are static html, which
> are generated by a Clojure script.

No kidding! I've done the exact same thing for my first website. It
was using Scheme though and leveraged Oleg's SXML library, it bring me
back fond memories. I'm looking at that old code right now and it was
kind of crazy, just using R5RS with srfi 1 and 19, Clojure is so much
better than this.

Your website looks good by the way. One thing is if you could dim the
background lines a little bit, it would make the text more readable,
some line look strikethrough.

> I looked at Compojure, and it seems very promising, but I decided it
> was overkill for my website.

Compojure is really great! ;-)

- budu
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Stuart Sierra

On Jun 25, 3:59 pm, Berlin Brown  wrote:
> But does anyone have a problem with Lisp/S-Expressions to HTML/XHtml,
> especially for the entire document.  What is wrong with using some
> form of templating system.

Yes, I'm partial to StringTemplate, a Java template framework.  Very
simple, like a functional language itself.
http://www.stringtemplate.org/

-SS
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Daniel Lyons


On Jun 25, 2009, at 1:59 PM, Berlin Brown wrote:
> But does anyone have a problem with Lisp/S-Expressions to HTML/XHtml,
> especially for the entire document.  What is wrong with using some
> form of templating system.  I think that is what Lisp has (see Lisp's
> Html-template).

http://weitz.de/html-template/

Of course, it's made by the same guy as CL-WHO, which uses the s-expr  
system instead:

http://weitz.de/cl-who/

> I am not talking about this particular application, but just in
> general.  I love the ability to take sections of HTML or snippets of
> HTML and use that as the View and then break that off from the
> application code.
>
> But that is just me.

Mixed bag for me, though I pretty much agree. On the one hand, I  
prefer the terseness of s-exp templating, and that you can't forget to  
close a tag. On the other hand, my business partner isn't going to  
learn Lisp anytime soon and needs to be able to modify the HTML that  
gets output. I know technically Lisp is simpler than XML, but it's  
still intimidating to the muggles. :)

The strength of something like PHP or embedded Ruby is that the text  
editors support it and you get the full power of the language inside  
the template. HTML-Template doesn't give you the full power of Lisp  
inside the template, but the advantage is that templates get compiled  
into something that executes really fast and it's easy enough that  
designers can probably handle it.

I kind of hate seeing HTML being manually printed out deep inside the  
code. I'd rather pass s-exps out, or something. Better not to do any  
formatting deep in the code and have a real separation of concerns.  
It's also nice if you can change the way it renders without  
recompiling. HTML-Template, when you load a file, it keeps track of  
that file and if it changes out from underneath it, it notices and  
recompiles the template (rather like JSP, I guess). CL-WHO, you'd have  
to recompile the function somehow, which means you need to have a REPL  
open somewhere you can get to. Which probably isn't impossible but  
seems to be a little more involved with Clojure than it is with Lisp.  
Another point for external HTML-style templates.

I've seen a couple templating systems (notably ZPT/TAL and Kid) that  
work by putting some XML from a different namespace into your  
document. Pro, your XML is always valid; con, it's a pain to work with  
and sometimes you just want to dump out some crap and don't really  
care if it's valid. Convenience versus correctness. I tend to side  
with convenience on templating.

I dunno. This problem has a lot of solutions and all of them seem to  
involve compromises.

—
Daniel Lyons


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread CuppoJava

Thanks Mike for that tip.
That seems a bit better, but then I have a left-over macro that I have
no use for.

As to why I didn't use a map. I needed destructuring so Clojure would
have internally turned the map into a seq anyway. Though a map would
save me from a layer of parenthesis. I'll keep that in mind for next
time.

This is the first time I used a s-expression to html approach. Before
this, I used templating engines in PHP and Ruby. Ultimately, they
turned out to be more hassle than they were worth to me. Or maybe I'm
just not very good with them.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Berlin Brown



On Jun 25, 3:52 pm, Mike Hinchey  wrote:
> Instead of eval in the doseq, you could use a macro with a do block,
> something like:
> user> (defmacro deftags [tags]
>         `(do ~@(map (fn [tag]
>                       `(defn ~(symbol (str tag "-with"))
>                          [block#] (str ~tag block#)))
>                     tags)))
> #'user/deftags
>
> user> (deftags ["html"])
> #'user/html-with
>
> user> (html-with [1])
> "html[1]"
>
> -Mike
>
> On Thu, Jun 25, 2009 at 11:51 AM, CuppoJava wrote:
>
>
>
> > Thanks for the reply.
>
> > I use doseq instead of map because I need it to run immediately, and
> > I'm not interested in the return values of the functions.
>
> > I also would love to be able to simply the (eval ...) part, but I
> > don't know of any other way to dynamically define a function in
> > Clojure. If you know of a way it'd help me out a lot.
> >   -Patrick

I am not looking at the code, I hate when people nitpick every snippet
they see.  I don't think that gets anyone anywhere.

But does anyone have a problem with Lisp/S-Expressions to HTML/XHtml,
especially for the entire document.  What is wrong with using some
form of templating system.  I think that is what Lisp has (see Lisp's
Html-template).

I am not talking about this particular application, but just in
general.  I love the ability to take sections of HTML or snippets of
HTML and use that as the View and then break that off from the
application code.

But that is just me.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Mike Hinchey
Instead of eval in the doseq, you could use a macro with a do block,
something like:
user> (defmacro deftags [tags]
`(do ~@(map (fn [tag]
  `(defn ~(symbol (str tag "-with"))
 [block#] (str ~tag block#)))
tags)))
#'user/deftags

user> (deftags ["html"])
#'user/html-with

user> (html-with [1])
"html[1]"

-Mike

On Thu, Jun 25, 2009 at 11:51 AM, CuppoJava wrote:

>
> Thanks for the reply.
>
> I use doseq instead of map because I need it to run immediately, and
> I'm not interested in the return values of the functions.
>
> I also would love to be able to simply the (eval ...) part, but I
> don't know of any other way to dynamically define a function in
> Clojure. If you know of a way it'd help me out a lot.
>   -Patrick
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Emeka
CuppoJava,

I was referring to the map data structure {'html "html"..} and not the
other map.

Regards,
Emeka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Emeka
CuppoJava,

Did you try prxml? May be it can be of help.

Regards,
Emeka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread CuppoJava

Yeah. Speed and simplicity were my main reasons to use static HTML
instead of running off a server.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Daniel Lyons


On Jun 25, 2009, at 12:57 PM, CuppoJava wrote:

>
> I'm not running off any server. All the pages are static html, which
> are generated by a Clojure script.

Haha, that explains the speed. :) *slaps forehead*

—
Daniel Lyons


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread CuppoJava

I'm not running off any server. All the pages are static html, which
are generated by a Clojure script.

I looked at Compojure, and it seems very promising, but I decided it
was overkill for my website.
  -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread CuppoJava

Thanks for your opinions Daniel.
Yes I really need to adapt to using hyphens instead of underscores.
I've irked more than a few people already.

So far, defblockfn is serving me well, but it has bitten me a few
times now. If I come up with another alternative I will switch over.

-Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Vagif Verdi

What server are you running it on ? Tomcat ?

There's a compojure web framework that already has html combinator
library.
Check it out here: http://preview.compojure.org/docs

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread CuppoJava

Thanks for the reply.

I use doseq instead of map because I need it to run immediately, and
I'm not interested in the return values of the functions.

I also would love to be able to simply the (eval ...) part, but I
don't know of any other way to dynamically define a function in
Clojure. If you know of a way it'd help me out a lot.
  -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Daniel Lyons


On Jun 25, 2009, at 11:46 AM, CuppoJava wrote:

>
> Hey guys,
> I was a little tired of working on what I am supposed to be working
> on, and decided to take a break and create a website. I decided to use
> Clojure, and to my surprise, it only took a day and less than 3 pages
> of code.
>
> members.shaw.ca/patrickli
>
> It only has a single article right now, under Technical, that talks
> about how I programmed the website. It's still a rough work (I haven't
> written anything substantial for a long time), but it'd be nice to
> hear some thoughts.


Very impressive and cool! And fast too!

My comments are really things you've already heard on the list. You  
should use -'s instead of _'s, for consistency if not for readability,  
and I'm still leery of defblockfn. But part of the joy of Lisp is  
constructing an environment of your liking and taking flight.

—
Daniel Lyons


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



Re: A website written using Clojure.

2009-06-25 Thread Emeka
That's cool.

 (doseq [[name tag] [['html "html"]
['head "head"]
['style "style"]
['title "title"]
['body "body"]
['table "table"]
['row "tr"]
['col "td"]
['span "span"]
['h1 "h1"]]]

Why not use map here?

(eval `(defblockfn ~name [block#]
   (html_tag* ~tag nil block#)))
  (eval `(defblockfn ~(symbol (str name "_with")) [attributes# block#]
   (html_tag* ~tag attributes# block#



See if you can simplify the above code.



Regards,
Emeka
On Thu, Jun 25, 2009 at 5:46 PM, CuppoJava wrote:

>
> Hey guys,
> I was a little tired of working on what I am supposed to be working
> on, and decided to take a break and create a website. I decided to use
> Clojure, and to my surprise, it only took a day and less than 3 pages
> of code.
>
> members.shaw.ca/patrickli
>
> It only has a single article right now, under Technical, that talks
> about how I programmed the website. It's still a rough work (I haven't
> written anything substantial for a long time), but it'd be nice to
> hear some thoughts.
>
>  -Patrick
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---



A website written using Clojure.

2009-06-25 Thread CuppoJava

Hey guys,
I was a little tired of working on what I am supposed to be working
on, and decided to take a break and create a website. I decided to use
Clojure, and to my surprise, it only took a day and less than 3 pages
of code.

members.shaw.ca/patrickli

It only has a single article right now, under Technical, that talks
about how I programmed the website. It's still a rough work (I haven't
written anything substantial for a long time), but it'd be nice to
hear some thoughts.

 -Patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~--~~~~--~~--~--~---