Re: what directs the program in my-website progream to execute the various files, welcome, users?
On Tuesday, June 11, 2013 5:32:46 AM UTC-7, jayvandal wrote: what statements makes the program execute. The main statement tells the program to execute server file what statements in the server file tell the program to run the welcome file ? the user file Is welcome.clj in src/my_website/views/? If so, it looks like the line '(server/load-views src/my_website/views/)' will execute welcome.clj, including the 'defpage /welcome' (see http://www.webnoir.org/autodoc/1.2.0/noir.server-api.html#noir.server/load-views). That defpage tells the server what to do when /welcome is accessed over the web - and it calls the layout function in common.clj, which calls login-form, which creates the login screen. -- -- 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
what directs the program in my-website progream to execute the various files, welcome, users?
what statements makes the program execute. The main statement tells the program to execute server file what statements in the server file tell the program to run the welcome file ? the user 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: what directs the program in my-website progream to execute the various files, welcome, users?
Without some code it would be impossible for us to speculate about how your program operates. Please provide the relevant source code and we can easily help you trace the flow of execution. On Tuesday, June 11, 2013 5:32:46 AM UTC-7, jayvandal wrote: what statements makes the program execute. The main statement tells the program to execute server file what statements in the server file tell the program to run the welcome file ? the user 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: what directs the program in my-website progream to execute the various files, welcome, users?
am using the my-website code. I then tried to create jimsweb and use the exact code I think the main calls the server file, but I don't understand how the logon screen is called? I can think in cobol but this?? * project.clj (defproject my-website 0.1.0-SNAPSHOT :description my Noir website :dependencies [[org.clojure/clojure 1.3.0] [noir 1.3.0-beta3] [org.clojure/java.jdbc 0.2.3] [mysql/mysql-connector-java 5.1.6]] :main my-website.server) **db.clj (ns my-website.models.db (:require [clojure.java.jdbc :as sql])) (def db {:classname com.mysql.jdbc.Driver :subprotocol mysql :subname //localhost:8080/world :user root :password pass}) (defn init-db [] (try (sql/with-connection db (sql/create-table :users [:id SERIAL] [:handle varchar(100)] [:pass varchar(100)])) (catch Exception ex (.getMessage (.getNextException ex) (defn db-read returns the result of running the supplied SQL query [query args] (sql/with-connection db (sql/with-query-results res (vec (cons query args)) (doall res (defn add-user [user] (sql/with-connection db (sql/insert-record :users user))) (defn get-user [handle] (first (db-read select * from users where handle=? handle))) **server.clj (ns my-website.server (:require [noir.server :as server]) (:gen-class)) (server/load-views src/my_website/views/) (defn -main [ m] (let [mode (keyword (or (first m) :dev)) port (Integer. (get (System/getenv) PORT 8080))] (server/start port {:mode mode :ns 'my-website}))) **welcome.clj ns my-website.views.welcome (:require [my-website.views.common :as common]) (:use [noir.core :only [defpage]] hiccup.core hiccup.form)) (defpage / [] (common/layout )) (defpage /welcome {:keys [greeting]} (common/layout (if greeting [:h2 greeting]) (form-to [:post /welcome] (label name name) (text-field name) (submit-button submit (defpage [:post /welcome] {:keys [name]} (noir.core/render /welcome {:greeting (str Welcome name)})) **common.clj (ns my-website.views.common (:use [noir.core :only [defpartial]] hiccup.element hiccup.form [hiccup.page :only [include-css html5]]) (:require [noir.session :as session])) (defn login-form [] (form-to [:post /login] (text-field {:placeholder user id} handle) (password-field {:placeholder password} pass) (submit-button login))) (defpartial layout [ content] (html5 [:head [:title my-website] (include-css /css/reset.css)] [:body (if-let [user (session/get :user)] [:h2 welcome user (form-to [:post /logout] (submit-button logout))] [:div.login (login-form) [:p or] (link-to /signup sign up)]) content])) **users.clj ns my-website.views.users (:use [noir.core] hiccup.core hiccup.form) (:require [my-website.views.common :as common] [my-website.models.db :as db] [noir.util.crypt :as crypt] [noir.session :as session] [noir.response :as resp])) (defpage /signup {:keys [handle error]} (common/layout [:div.error error] (form-to [:post /signup] (label user-id user id) (text-field handle handle) [:br] (label pass password) (password-field pass) [:br] (submit-button create account (defpage [:post /signup] user (try (db/add-user (update-in user [:pass] crypt/encrypt)) (resp/redirect /) (catch Exception ex (render /signup (assoc user :error (.getMessage ex)) (defpage [:post /login] {:keys [handle pass]} (render / (let [user (db/get-user handle)] (if (and user (crypt/compare pass (:pass user))) (session/put! :user handle) {:handle handle :error login failed} (defpage [:post /logout] [] (session/clear!) (resp/redirect /)) On Tuesday, June 11, 2013 6:32:46 AM UTC-6, jayvandal wrote: what statements makes the program execute. The main statement tells the program to execute server file what statements in the server file tell the program to run the welcome file ? the user 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: what directs the program in my-website progream to execute the various files, welcome, users?
I put the code in my reply hope you can tell me how clojure works On Tuesday, June 11, 2013 12:53:16 PM UTC-6, Michael-Keith Bernard wrote: Without some code it would be impossible for us to speculate about how your program operates. Please provide the relevant source code and we can easily help you trace the flow of execution. On Tuesday, June 11, 2013 5:32:46 AM UTC-7, jayvandal wrote: what statements makes the program execute. The main statement tells the program to execute server file what statements in the server file tell the program to run the welcome file ? the user 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: what directs the program in my-website progream to execute the various files, welcome, users?
Re-paste for formatting: ;; project.clj (defproject my-website 0.1.0-SNAPSHOT :description my Noir website :dependencies [[org.clojure/clojure 1.3.0] [noir 1.3.0-beta3] [org.clojure/java.jdbc 0.2.3] [mysql/mysql-connector-java 5.1.6]] :main my-website.server) ;; db.clj (ns my-website.models.db (:require [clojure.java.jdbc :as sql])) (def db {:classname com.mysql.jdbc.Driver :subprotocol mysql :subname //localhost:8080/world :user root :password pass}) (defn init-db [] (try (sql/with-connection db (sql/create-table :users [:id SERIAL] [:handle varchar(100)] [:pass varchar(100)])) (catch Exception ex (.getMessage (.getNextException ex) (defn db-read returns the result of running the supplied SQL query [query args] (sql/with-connection db (sql/with-query-results res (vec (cons query args)) (doall res (defn add-user [user] (sql/with-connection db (sql/insert-record :users user))) (defn get-user [handle] (first (db-read select * from users where handle=? handle))) ;; server.clj (ns my-website.server (:require [noir.server :as server]) (:gen-class)) (server/load-views src/my_website/views/) (defn -main [ m] (let [mode (keyword (or (first m) :dev)) port (Integer. (get (System/getenv) PORT 8080))] (server/start port {:mode mode :ns 'my-website}))) ;; welcome.clj ns my-website.views.welcome (:require [my-website.views.common :as common]) (:use [noir.core :only [defpage]] hiccup.core hiccup.form)) (defpage / [] (common/layout )) (defpage /welcome {:keys [greeting]} (common/layout (if greeting [:h2 greeting]) (form-to [:post /welcome] (label name name) (text-field name) (submit-button submit (defpage [:post /welcome] {:keys [name]} (noir.core/render /welcome {:greeting (str Welcome name)})) ;; common.clj (ns my-website.views.common (:use [noir.core :only [defpartial]] hiccup.element hiccup.form [hiccup.page :only [include-css html5]]) (:require [noir.session :as session])) (defn login-form [] (form-to [:post /login] (text-field {:placeholder user id} handle) (password-field {:placeholder password} pass) (submit-button login))) (defpartial layout [ content] (html5 [:head [:title my-website] (include-css /css/reset.css)] [:body (if-let [user (session/get :user)] [:h2 welcome user (form-to [:post /logout] (submit-button logout))] [:div.login (login-form) [:p or] (link-to /signup sign up)]) content])) ;; users.clj (ns my-website.views.users (:use [noir.core] hiccup.core hiccup.form) (:require [my-website.views.common :as common] [my-website.models.db :as db] [noir.util.crypt :as crypt] [noir.session :as session] [noir.response :as resp])) (defpage /signup {:keys [handle error]} (common/layout [:div.error error] (form-to [:post /signup] (label user-id user id) (text-field handle handle) [:br] (label pass password) (password-field pass) [:br] (submit-button create account (defpage [:post /signup] user (try (db/add-user (update-in user [:pass] crypt/encrypt)) (resp/redirect /) (catch Exception ex (render /signup (assoc user :error (.getMessage ex)) (defpage [:post /login] {:keys [handle pass]} (render / (let [user (db/get-user handle)] (if (and user (crypt/compare pass (:pass user))) (session/put! :user handle) {:handle handle :error login failed} (defpage [:post /logout] [] (session/clear!) (resp/redirect /)) On Tuesday, June 11, 2013 5:32:46 AM UTC-7, jayvandal wrote: what statements makes the program execute. The main statement tells the program to execute server file what statements in the server file tell the program to run the welcome file ? the user 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 --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.