Compojure

2010-09-13 Thread Bahman Movaqar
 Hi list,

I'm trying to get a simple hello world Compojure application
running.   I attach both the clj file and maven pom.xml (using
NetBeans+Enclojure).  When I run (guestbook.core/-main), I get a blank
page in browser, no matter the URL.  What am I missing?

BTW, by blank I really mean blank.  If I view the page source in
Firefox, it's empty.

TIA,

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation  Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)

?xml version=1.0 encoding=UTF-8?
project xmlns=http://maven.apache.org/POM/4.0.0; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
  xsi:schemaLocation=http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd;
properties
clojure.version1.2.0/clojure.version
project.build.sourceEncodingUTF-8/project.build.sourceEncoding
/properties
modelVersion4.0.0/modelVersion
version0.0.1/version
nameGuestBook/name
descriptionGuestBook/description
build
sourceDirectorysrc/main/clojure/sourceDirectory
testSourceDirectorysrc/test/clojure/testSourceDirectory
resources
resource
directorysrc/main/clojure/directory
/resource
resource
directorysrc/main/resources/directory
/resource
/resources
testResources
testResource
directorysrc/test/clojure/directory
/testResource
/testResources
plugins
plugin
groupIdcom.theoryinpractise/groupId
artifactIdclojure-maven-plugin/artifactId
version1.3.2/version
configuration
sourceDirectories
sourceDirectorysrc/main/clojure/sourceDirectory
/sourceDirectories
clojureOptions-Xmx1G/clojureOptions
/configuration
executions
execution
idcompile-clojure/id
phasecompile/phase
goals
goalcompile/goal
/goals
/execution
/executions
/plugin
plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-compiler-plugin/artifactId
configuration
source1.6/source
target1.6/target
encoding${project.build.sourceEncoding}/encoding
showDeprecationtrue/showDeprecation
/configuration
/plugin
plugin
groupIdorg.apache.maven.plugins/groupId
artifactIdmaven-resources-plugin/artifactId
version2.2/version
configuration
encoding${project.build.sourceEncoding}/encoding
/configuration
/plugin
/plugins
/build
repositories
repository
idcentral/id
urlhttp://repo1.maven.org/maven2/url
/repository
repository
idclojure-releases/id
urlhttp://build.clojure.org/releases/url
/repository
repository
idincanter/id
urlhttp://repo.incanter.org/url
/repository
repository
idclojure-snapshots/id
urlhttp://build.clojure.org/snapshots/url
/repository
repository
idclojars/id
urlhttp://clojars.org/repo//url
/repository
/repositories
dependencies
dependency
groupIdorg.clojure/groupId
artifactIdclojure/artifactId
version${clojure.version}/version
/dependency
dependency
groupIdorg.clojure/groupId
artifactIdclojure-contrib/artifactId
version${clojure.version}/version
/dependency
dependency
groupIdswank-clojure/groupId
artifactIdswank-clojure/artifactId
version1.2.1/version
exclusions
exclusion
groupIdorg.clojure/groupId
artifactIdclojure/artifactId
/exclusion
exclusion
groupIdorg.clojure/groupId
artifactIdclojure-contrib/artifactId
/exclusion
/exclusions
/dependency
dependency
groupIdcompojure/groupId
artifactIdcompojure/artifactId
version0.4.1/version
/dependency
dependency
groupIdring/groupId
artifactIdring-jetty-adapter/artifactId
version0.2.6/version
/dependency
/dependencies
groupIdguestbook/groupId
artifactIdguestbook/artifactId
/project
(ns guestbook.core
 (:gen-class)
 (:use compojure.core)
 (:require

Re: Compojure

2010-09-13 Thread Bahman Movaqar
 On 2010/9/13 17:11, Aaron Bedra wrote:
  Try the following instead (just modified your attached source)

 (ns guestbook.core
  (:use compojure.core)
  (:require [compojure.route :as route])
  (:require [ring.adapter.jetty :as jetty])

 (defroutes dispatcher
   (GET / [] h1Hello, world/h1)
   (route/not-found bRequested resource not found/b))

 (defn -main [ args]
   (jetty/run-jetty dispatcher {:port 8080}))

It works.  Strange gotcha.


 You don't need the gen class or the servlet stuff.  Also note that
 there is a compojure google group that you can join to ask more
 specific compojure based questions on.  If you want to see more
 examples I have some on github at http://github.com/abedra/clojure-web.


Oh, I didn't know about the Compojure group.Just joined it.
Also nice tutorials for a person like me.  Lately, I've been wandering
around Clojure corners with no fruit.  I plan to write a business suite
with Clojure and I think web programming is a good starting point for my
case.  The tutorials show me what I want to see:  how to build web apps
step by step.

Thank you for the assist and hints Aaron.  Much appreciated.


 On 9/12/10 8:53 PM, Bahman Movaqar wrote:
   Hi list,

 I'm trying to get a simple hello world Compojure application
 running.   I attach both the clj file and maven pom.xml (using
 NetBeans+Enclojure).  When I run (guestbook.core/-main), I get a blank
 page in browser, no matter the URL.  What am I missing?

 BTW, by blank I really mean blank.  If I view the page source in
 Firefox, it's empty.

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation  Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)




signature.asc
Description: OpenPGP digital signature


Leiningen-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 Hi List,

Today, trying to setup Clojure I downloaded 'leiningen.bat' from
(http://github.com/technomancy/leiningen/raw/master/bin/lein.bat) and
'self-install' fails:
  C:\Users\Bahmanlein self-install
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
  --2010-09-10 18:56:58-- 
http://github.com/downloads/technomancy/leiningen/leiningen-1.4.0-SNAPSHOT-standalone.jar
  Resolving github.com... 207.97.227.239
  Connecting to github.com|207.97.227.239|:80... connected.
  HTTP request sent, awaiting response... 404 Not Found
  2010-09-10 18:56:59 ERROR 404: Not Found.
  *** DOWNLOAD FAILED! Check URL/Version. ***


Also another strange thing is that when I open a command prompt and
enter 'lein self-install' it fails; I figured out I have to issue a
dummy 'lein new' first for 'self-install' to start.
  C:\Users\Bahmanlein self-install
  The syntax of the command is incorrect.

  C:\Users\Bahmanlein new t
  C:\Applications\Leiningen\leiningen-1.4.0-SNAPSHOT-standalone.jar
can not be found.
  You can try running lein self-install
  or change LEIN_JAR environment variable
  or edit lein.bat to set appropriate LEIN_JAR path.

  C:\Users\Bahmanlein self-install
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
  ...

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation  Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)




signature.asc
Description: OpenPGP digital signature


Re: Leiningen-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 On 2010/9/10 19:07, Bahman Movaqar wrote:
  Hi List,

 Today, trying to setup Clojure I downloaded 'leiningen.bat' from
 (http://github.com/technomancy/leiningen/raw/master/bin/lein.bat) and
 'self-install' fails:
   C:\Users\Bahmanlein self-install
   SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
   syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
   --2010-09-10 18:56:58-- 
 http://github.com/downloads/technomancy/leiningen/leiningen-1.4.0-SNAPSHOT-standalone.jar
   Resolving github.com... 207.97.227.239
   Connecting to github.com|207.97.227.239|:80... connected.
   HTTP request sent, awaiting response... 404 Not Found
   2010-09-10 18:56:59 ERROR 404: Not Found.
   *** DOWNLOAD FAILED! Check URL/Version. ***


 Also another strange thing is that when I open a command prompt and
 enter 'lein self-install' it fails; I figured out I have to issue a
 dummy 'lein new' first for 'self-install' to start.
   C:\Users\Bahmanlein self-install
   The syntax of the command is incorrect.

   C:\Users\Bahmanlein new t
   C:\Applications\Leiningen\leiningen-1.4.0-SNAPSHOT-standalone.jar
 can not be found.
   You can try running lein self-install
   or change LEIN_JAR environment variable
   or edit lein.bat to set appropriate LEIN_JAR path.

   C:\Users\Bahmanlein self-install
   SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
   syswgetrc = C:\Program Files\GnuWin32/etc/wgetrc
   ...


Forgot to add that with some help on IRC I changed LEIN_VERSION to 1.3.1
and it worked.

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation  Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)




signature.asc
Description: OpenPGP digital signature


Re: Leiningen-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 On 2010/9/10 21:42, Phil Hagelberg wrote:
 On Fri, Sep 10, 2010 at 7:37 AM, Bahman Movaqar b.mova...@gmail.com wrote:
 Also another strange thing is that when I open a command prompt and
 enter 'lein self-install' it fails; I figured out I have to issue a
 dummy 'lein new' first for 'self-install' to start.
  C:\Users\Bahmanlein self-install
  The syntax of the command is incorrect.
 I don't have Windows to test on, but the documentation for the Windows
 installation was out of date; I just got a patch to fix it. Do the
 current instructions work for you?



No.  I changed the file a bit to make it work and also remove the
trivial bug I earlier mentioned and it works for me.
I attach the file.

Thanks,

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation  Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)

@echo off

set LEIN_VERSION=1.3.1

rem it is possible to set LEIN_JAR variable manually
rem so we don't overwrite them
if x%LEIN_JAR% neq x goto LEIN_JAR_SET

set LEIN_DIR=%~dp0
set LEIN_JAR=%LEIN_DIR%leiningen-%LEIN_VERSION%-standalone.jar


:LEIN_JAR_SET
if x%1 == xself-install goto SELF_INSTALL
if x%1 == xupgrade  goto NO_UPGRADE

rem If the command is not 'self-install' or 'upgrade' then check for LEIN_JAR 
first.
if not exist %LEIN_JAR% goto NO_LEIN_JAR


rem ##
rem count number of command line arguments
rem
set ARGCOUNT=0
for %%a in (%*) do set /a ARGCOUNT+=1
rem ##


rem ##
rem add jars found under lib directory to CLASSPATH
rem

call :FIND_DIR_CONTAINING_UPWARDS project.clj

if %DIR_CONTAINING% neq  cd %DIR_CONTAINING%

setLocal EnableDelayedExpansion
set CP=
for /R ./lib %%a in (*.jar) do (
   set CP=!CP!;%%a
)
set CP=!CP!

set CLASSPATH=%LEIN_JAR%;%CP%;%CLASSPATH%
if x%DEBUG% == x goto RUN
echo CLASSPATH=%CLASSPATH%
rem ##

:RUN
if x%1 == xrepl goto RUN_REPL
if %ARGCOUNT% == 2 goto RUN_ARG2
if %ARGCOUNT% == 3 goto RUN_ARG3
java -client -cp %CLASSPATH% clojure.main -e (use 'leiningen.core) (-main 
\%1\)
goto EOF

:RUN_ARG2
java -client -cp %CLASSPATH% clojure.main -e (use 'leiningen.core) (-main 
\%1\ \%2\)
goto EOF

:RUN_ARG3
java -client -cp %CLASSPATH% clojure.main -e (use 'leiningen.core) (-main 
\%1\ \%2\ \%3\)
goto EOF

:RUN_REPL
%RLWRAP% java -client %JAVA_OPTS% -cp src;classes;%CLASSPATH% clojure.main %2 
%3 %4
goto EOF

:NO_LEIN_JAR
echo.
echo %LEIN_JAR% can not be found.
echo You can try running lein self-install
echo or change LEIN_JAR environment variable
echo or edit lein.bat to set appropriate LEIN_JAR path.
echo. 
goto EOF

:SELF_INSTALL
if exist %LEIN_JAR% (
echo 15
echo %LEIN_JAR% already exists. Delete and retry.
echo 17
goto EOF
)
set HTTP_CLIENT=wget -O
wgetnul 21
if ERRORLEVEL 9009 (
curlnul 21
if ERRORLEVEL 9009 goto NO_HTTP_CLIENT
set HTTP_CLIENT=curl -f -L -o
)
set LEIN_DIR=%~dp0
set LEIN_JAR=%LEIN_DIR%leiningen-%LEIN_VERSION%-standalone.jar
set 
LEIN_JAR_URL=http://github.com/downloads/technomancy/leiningen/leiningen-%LEIN_VERSION%-standalone.jar
%HTTP_CLIENT% %LEIN_JAR% %LEIN_JAR_URL%
if ERRORLEVEL 1 (
del %LEIN_JAR%nul 21
goto DOWNLOAD_FAILED
)
goto EOF

:DOWNLOAD_FAILED
echo.
echo *** DOWNLOAD FAILED! Check URL/Version. ***
echo.
goto EOF

:NO_HTTP_CLIENT
echo.
echo ERROR: Wget/Curl not found. Make sure at least either of Wget and Curl is
echoinstalled and is in PATH. You can get them from URLs below:
echo.
echo Wget: http://users.ugent.be/~bpuype/wget/;
echo Curl: http://curl.haxx.se/dlwiz/?type=binos=Win32flav=-ver=2000/XP;
echo.
goto EOF

:NO_UPGRADE
echo.
echo Upgrade feature is not available on Windows. Please edit the value of
echo variable LEIN_VERSION in file %~f0
echo then run lein self-install.
echo.
goto EOF


rem Find directory containing filename supplied in first argument
rem looking in current directory, and looking up the parent
rem chain until we find it, or run out
rem returns result in %DIR_CONTAINING%
rem empty string if we don't find it
:FIND_DIR_CONTAINING_UPWARDS
set DIR_CONTAINING=%CD%
set LAST_DIR=

:LOOK_AGAIN
if %DIR_CONTAINING% == %LAST_DIR% (
rem didn't find it
set DIR_CONTAINING=
goto :EOF
)

if EXIST %DIR_CONTAINING%\%1 (
rem found it - use result in DIR_CONTAINING
goto :EOF
)

set LAST_DIR=%DIR_CONTAINING%
call :GET_PARENT_PATH %DIR_CONTAINING%\..
set DIR_CONTAINING=%PARENT_PATH%
goto :LOOK_AGAIN

:GET_PARENT_PATH
set PARENT_PATH=%~f1
goto :EOF

:EOF


signature.asc
Description: OpenPGP digital signature


Re: Leiningen-1.4.0-SNAPSHOT missing

2010-09-10 Thread Bahman Movaqar
 On 2010/9/10 21:42, Phil Hagelberg wrote:
 On Fri, Sep 10, 2010 at 7:37 AM, Bahman Movaqar b.mova...@gmail.com wrote:
 Also another strange thing is that when I open a command prompt and
 enter 'lein self-install' it fails; I figured out I have to issue a
 dummy 'lein new' first for 'self-install' to start.
  C:\Users\Bahmanlein self-install
  The syntax of the command is incorrect.
 I don't have Windows to test on, but the documentation for the Windows
 installation was out of date; I just got a patch to fix it. Do the
 current instructions work for you?



Once again I forgot to add that: Yes, the download section is working as
expected.  Thank you.

-- 
Bahman Movaqar (http://BahmanM.com)
ERP Evaluation, Implementation  Deployment Consultant

PGP Key ID: 0x3750102D (keyserver2.pgp.com)




signature.asc
Description: OpenPGP digital signature