(ns rss.data
(:require [clojure.xml :as xml])
(:import [java.io ByteArrayInputStream]))
(defrecord rss-root [channels])
(defrecord rss-channel [title description link lastbuilddate pubdate items])
(defrecord rss-item [title description link guid pubdate])
(defn create-rss-channel [map items]
(let [title (:title map)
pubDate (:pubDate map)
description (:description map)
link (:link map)
lastBuildDate (:lastBuildDate map)]
(rss-channel. title description link lastBuildDate pubDate items)))
(defn create-item [item-data]
(let [description (:description item-data)
pubDate (:pubDate item-data)
guid (:guid item-data)
link (:link item-data)
title (:title item-data)
]
(rss-item. title description link guid pubDate)))
(defn parse-item [item-data]
(create-item (zipmap (map :tag item-data) (map :content item-data))))
(defn parse-items [items-data]
(map parse-item items-data))
(defn parse-channel [channel-content]
(loop [x (:content channel-content)]
(create-rss-channel
(into {} (filter #(not (= :item (key %))) (zipmap (map :tag x) (map :content x))))
(parse-items (map :content (into [] (filter #(= :item (:tag %)) x)))))
))
(defn parse-rss [rss]
(let [rss-data (ByteArrayInputStream. (.getBytes rss "UTF-8"))]
(for [x (xml-seq (xml/parse rss-data))
:when (= :rss (:tag x))]
(map parse-channel (:content x)))))
Sunday, January 23, 2011
Test Entry to check Clojure code formatting
Saturday, December 11, 2010
How-To - IntelliJ Idea for Clojure/Compojure on Google App Engine
StrangeLoop conference really spiked my interest in learning Clojure. I wanted to find a way to do web development using Clojure. So this entry is primarily a how-to on setup of IntelliJ Idea to do Clojure using Compojure web framework, Leiningen build tool and Google App Engine deployment environment.
Step 1: Download Leiningen
Download Leiningen script file and follow instruction to put it in PATH.
Step 2: Install "La Clojure" and "Leiningen" plugin for IntelliJ Idea.
To do this go to Preferences -> Plugins. Go to "Available" Tab
Step 3: Setup Leiningen plugin properties
To setup Leiningen plugin properties in IntelliJ click on Preferences -> Leiningen and give the path to the executable.
Step 4: Create project template
Now with the installation complete, we are ready to create a new project. For now the project creation is done outside IntelliJ Idea using Lein on command line. This is the only step done outside the IntelliJ Idea. Choose the folder structure where your IntelliJ workspace is.
You can see that Lein created project folder structure. In the project root it created a project.clj file used by Leiningen. Under src folder, it also created default namespace by the name of the project and created a core.clj file under it.
Step 5: Create project IntelliJ
Let's create IntelliJ Project, even though project structure exists pick the same folder path that you selected in step 4.
Now basic setup for the project is done. You can browse the project files using IntelliJ. (Biggest benefit of La Clojure is it auto-inserts and matches brackets for very "brackety language" :-))
Step 6: Setup Leiningen to run from IntelliJ
To setup Leiningen from IntelliJ, click on Leiningen tool window. (Window -> Tool Windows -> Leiningen)
Step 7: Setup web development libraries
Setup the project to include Compojure and Ring libraries for development.
project.clj
core.clj
web.xml
From the Leiningen Tool window in Idea run following commands.
Step 10: Run locally
To locally run click on already create "Run Configuration"
Step 11: To upload application to appengine
Tools -> Upload Appengine application
Step 1: Download Leiningen
Download Leiningen script file and follow instruction to put it in PATH.
Step 2: Install "La Clojure" and "Leiningen" plugin for IntelliJ Idea.
To do this go to Preferences -> Plugins. Go to "Available" Tab
Step 3: Setup Leiningen plugin properties
To setup Leiningen plugin properties in IntelliJ click on Preferences -> Leiningen and give the path to the executable.
Step 4: Create project template
Now with the installation complete, we are ready to create a new project. For now the project creation is done outside IntelliJ Idea using Lein on command line. This is the only step done outside the IntelliJ Idea. Choose the folder structure where your IntelliJ workspace is.
$ lein new gae-cmpjr
Created new project in: gae-cmpjr
You can see that Lein created project folder structure. In the project root it created a project.clj file used by Leiningen. Under src folder, it also created default namespace by the name of the project and created a core.clj file under it.
Step 5: Create project IntelliJ
Let's create IntelliJ Project, even though project structure exists pick the same folder path that you selected in step 4.
- File -> Project New... and select project from scratch
- Select both GAE and Clojure. Provide the path to the appengine sdk
Now basic setup for the project is done. You can browse the project files using IntelliJ. (Biggest benefit of La Clojure is it auto-inserts and matches brackets for very "brackety language" :-))
Step 6: Setup Leiningen to run from IntelliJ
To setup Leiningen from IntelliJ, click on Leiningen tool window. (Window -> Tool Windows -> Leiningen)
Step 7: Setup web development libraries
Setup the project to include Compojure and Ring libraries for development.
project.clj
(defproject gae-cmpjr "1.0.0-SNAPSHOT"
:description "Example for Compojure on GAE using IntelliJ"
:namespaces [gae-cmpjr.core]
:dependencies [[compojure "0.4.0-SNAPSHOT"]
[ring/ring-servlet "0.2.1"]]
:dev-dependencies [[leiningen/lein-swank "1.2.0-SNAPSHOT"]]
:compile-path "web/WEB-INF/classes"
:library-path "web/WEB-INF/lib")
core.clj
Step 8: GAE setup
(ns gae-cmpjr.core
(:gen-class :extends javax.servlet.http.HttpServlet)
(:use compojure.core
ring.util.servlet)
(:require [compojure.route :as route]))
(defroutes hello
(GET "/" [] "<h1>Hello World Wide Web!</h1>")
(route/not-found "Page not found"))
(defservice hello)
web.xml
<?xml version="1.0" encoding="UTF-8"?>appengine-web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Compojure on GAE using IntelliJ</display-name>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>gae_cmpjr.core</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Step 9: Compile and Build war
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>compgae</application>
<version>v0-2</version>
</appengine-web-app>
From the Leiningen Tool window in Idea run following commands.
lein clean
lein deps
lein compile
Step 10: Run locally
To locally run click on already create "Run Configuration"
Step 11: To upload application to appengine
Tools -> Upload Appengine application
Blogged with the Flock Browser
How-To - IntelliJ Idea for Clojure/Compojure on Google App Engine
StrangeLoop conference really spiked my interest in learning Clojure. I wanted to find a way to do web development using Clojure. So this entry is primarily a how-to on setup of IntelliJ Idea to do Clojure using Compojure web framework, Leiningen build tool and Google App Engine deployment environment.
Step 1: Download Leiningen
Download Leiningen script file and follow instruction to put it in PATH.
Step 2: Install "La Clojure" and "Leiningen" plugin for IntelliJ Idea.
To do this go to Preferences -> Plugins. Go to "Available" Tab
Step 3: Setup Leiningen plugin properties
To setup Leiningen plugin properties in IntelliJ click on Preferences -> Leiningen and give the path to the executable.
Step 4: Create project template
Now with the installation complete, we are ready to create a new project. For now the project creation is done outside IntelliJ Idea using Lein on command line. This is the only step done outside the IntelliJ Idea. Choose the folder structure where your IntelliJ workspace is.
You can see that Lein created project folder structure. In the project root it created a project.clj file used by Leiningen. Under src folder, it also created default namespace by the name of the project and created a core.clj file under it.
Step 5: Create project IntelliJ
Let's create IntelliJ Project, even though project structure exists pick the same folder path that you selected in step 4.
Now basic setup for the project is done. You can browse the project files using IntelliJ. (Biggest benefit of La Clojure is it auto-inserts and matches brackets for very "brackety language" :-))
Step 6: Setup Leiningen to run from IntelliJ
To setup Leiningen from IntelliJ, click on Leiningen tool window. (Window -> Tool Windows -> Leiningen)
Step 7: Setup web development libraries
Setup the project to include Compojure and Ring libraries for development.
web.xml
From the Leiningen Tool window in Idea run following commands.
To locally run click on already create "Run Configuration"
Step 11: To upload application to appengine
Tools -> Upload Appengine application
Step 1: Download Leiningen
Download Leiningen script file and follow instruction to put it in PATH.
Step 2: Install "La Clojure" and "Leiningen" plugin for IntelliJ Idea.
To do this go to Preferences -> Plugins. Go to "Available" Tab
Step 3: Setup Leiningen plugin properties
To setup Leiningen plugin properties in IntelliJ click on Preferences -> Leiningen and give the path to the executable.
Step 4: Create project template
Now with the installation complete, we are ready to create a new project. For now the project creation is done outside IntelliJ Idea using Lein on command line. This is the only step done outside the IntelliJ Idea. Choose the folder structure where your IntelliJ workspace is.
$ lein new gae-cmpjr
Created new project in: gae-cmpjr
You can see that Lein created project folder structure. In the project root it created a project.clj file used by Leiningen. Under src folder, it also created default namespace by the name of the project and created a core.clj file under it.
Step 5: Create project IntelliJ
Let's create IntelliJ Project, even though project structure exists pick the same folder path that you selected in step 4.
- File -> Project New... and select project from scratch
- Select both GAE and Clojure. Provide the path to the appengine sdk
Now basic setup for the project is done. You can browse the project files using IntelliJ. (Biggest benefit of La Clojure is it auto-inserts and matches brackets for very "brackety language" :-))
Step 6: Setup Leiningen to run from IntelliJ
To setup Leiningen from IntelliJ, click on Leiningen tool window. (Window -> Tool Windows -> Leiningen)
Step 7: Setup web development libraries
Setup the project to include Compojure and Ring libraries for development.
project.clj
(defproject gae-cmpjr "1.0.0-SNAPSHOT"
:description "Example for Compojure on GAE using IntelliJ"
:namespaces [gae-cmpjr.core]
:dependencies [[compojure "0.4.0-SNAPSHOT"]
[ring/ring-servlet "0.2.1"]]
:dev-dependencies [[leiningen/lein-swank "1.2.0-SNAPSHOT"]]
:compile-path "web/WEB-INF/classes"
:library-path "web/WEB-INF/lib")
Step 8: GAE setup
core.clj
(ns gae-cmpjr.core
(:gen-class :extends javax.servlet.http.HttpServlet)
(:use compojure.core
ring.util.servlet)
(:require [compojure.route :as route]))
(defroutes hello
(GET "/" [] "<h1>Hello World Wide Web!</h1>")
(route/not-found "Page not found"))
(defservice hello)
web.xml
<?xml version="1.0" encoding="UTF-8"?>appengine-web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Compojure on GAE using IntelliJ</display-name>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>gae_cmpjr.core</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Step 9: Compile and Build war
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>compgae</application>
<version>v0-2</version>
</appengine-web-app>
From the Leiningen Tool window in Idea run following commands.
Step 10: Run locallyLein clean
Lein deps
Lein compile
To locally run click on already create "Run Configuration"
Step 11: To upload application to appengine
Tools -> Upload Appengine application
Blogged with the Flock Browser
How-To - IntelliJ Idea for Clojure/Compojure on Google App Engine
StrangeLoop conference really spiked my interest in learning Clojure. I wanted to find a way to do web development using Clojure. So this entry is primarily a how-to on setup of IntelliJ Idea to do Clojure using Compojure web framework, Leiningen build tool and Google App Engine deployment environment.
Step 1: Download Leiningen
Download Leiningen script file and follow instruction to put it in PATH.
Step 2: Install "La Clojure" and "Leiningen" plugin for IntelliJ Idea.
To do this go to Preferences -> Plugins. Go to "Available" Tab
Step 3: Setup Leiningen plugin properties
To setup Leiningen plugin properties in IntelliJ click on Preferences -> Leiningen and give the path to the executable.
Step 4: Create project template
Now with the installation complete, we are ready to create a new project. For now the project creation is done outside IntelliJ Idea using Lein on command line. This is the only step done outside the IntelliJ Idea. Choose the folder structure where your IntelliJ workspace is.
You can see that Lein created project folder structure. In the project root it created a project.clj file used by Leiningen. Under src folder, it also created default namespace by the name of the project and created a core.clj file under it.
Step 5: Create project IntelliJ
Let's create IntelliJ Project, even though project structure exists pick the same folder path that you selected in step 4.
Now basic setup for the project is done. You can browse the project files using IntelliJ. (Biggest benefit of La Clojure is it auto-inserts and matches brackets for very "brackety language" :-))
Step 6: Setup Leiningen to run from IntelliJ
To setup Leiningen from IntelliJ, click on Leiningen tool window. (Window -> Tool Windows -> Leiningen)
Step 7: Setup web development libraries
Setup the project to include Compojure and Ring libraries for development.
web.xml
From the Leiningen Tool window in Idea run following commands.
To locally run click on already create "Run Configuration"
Step 11: To upload application to appengine
Tools -> Upload Appengine application
Step 1: Download Leiningen
Download Leiningen script file and follow instruction to put it in PATH.
Step 2: Install "La Clojure" and "Leiningen" plugin for IntelliJ Idea.
To do this go to Preferences -> Plugins. Go to "Available" Tab
Step 3: Setup Leiningen plugin properties
To setup Leiningen plugin properties in IntelliJ click on Preferences -> Leiningen and give the path to the executable.
Step 4: Create project template
Now with the installation complete, we are ready to create a new project. For now the project creation is done outside IntelliJ Idea using Lein on command line. This is the only step done outside the IntelliJ Idea. Choose the folder structure where your IntelliJ workspace is.
$ lein new gae-cmpjr
Created new project in: gae-cmpjr
You can see that Lein created project folder structure. In the project root it created a project.clj file used by Leiningen. Under src folder, it also created default namespace by the name of the project and created a core.clj file under it.
Step 5: Create project IntelliJ
Let's create IntelliJ Project, even though project structure exists pick the same folder path that you selected in step 4.
- File -> Project New... and select project from scratch
- Select both GAE and Clojure. Provide the path to the appengine sdk
Now basic setup for the project is done. You can browse the project files using IntelliJ. (Biggest benefit of La Clojure is it auto-inserts and matches brackets for very "brackety language" :-))
Step 6: Setup Leiningen to run from IntelliJ
To setup Leiningen from IntelliJ, click on Leiningen tool window. (Window -> Tool Windows -> Leiningen)
Step 7: Setup web development libraries
Setup the project to include Compojure and Ring libraries for development.
project.clj
(defproject gae-cmpjr "1.0.0-SNAPSHOT"
:description "Example for Compojure on GAE using IntelliJ"
:namespaces [gae-cmpjr.core]
:dependencies [[compojure "0.4.0-SNAPSHOT"]
[ring/ring-servlet "0.2.1"]]
:dev-dependencies [[leiningen/lein-swank "1.2.0-SNAPSHOT"]]
:compile-path "web/WEB-INF/classes"
:library-path "web/WEB-INF/lib")
Step 8: GAE setup
core.clj
(ns gae-cmpjr.core
(:gen-class :extends javax.servlet.http.HttpServlet)
(:use compojure.core
ring.util.servlet)
(:require [compojure.route :as route]))
(defroutes hello
(GET "/" [] "<h1>Hello World Wide Web!</h1>")
(route/not-found "Page not found"))
(defservice hello)
web.xml
<?xml version="1.0" encoding="UTF-8"?>appengine-web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Compojure on GAE using IntelliJ</display-name>
<servlet>
<servlet-name>hello</servlet-name>
<servlet-class>gae_cmpjr.core</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Step 9: Compile and Build war
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>compgae</application>
<version>v0-2</version>
</appengine-web-app>
From the Leiningen Tool window in Idea run following commands.
Step 10: Run locallyLein clean
Lein deps
Lein compile
To locally run click on already create "Run Configuration"
Step 11: To upload application to appengine
Tools -> Upload Appengine application
Blogged with the Flock Browser
Tuesday, April 6, 2010
Test blog
This is test blog with iPad
this is bold
Italics
It is better to write and then do formatting
There is no list option so you have to type the text.
this is bold
Italics
It is better to write and then do formatting
There is no list option so you have to type the text.
public static void main (String[] args)
{
System.out.println("hello");
}
This is a test blog
topic entry
Typing this is just a test blog. Typing this is just a test blog. and just typing some more because this is a test blog. By now you know this is a test blog and I am typing to see if it show up correctly on this test blog. If you forgot, let me tell you this is test blog.
The main topic of this blog is
Typing this is just a test blog. Typing this is just a test blog. and just typing some more because this is a test blog. By now you know this is a test blog and I am typing to see if it show up correctly on this test blog. If you forgot, let me tell you this is test blog.
Let's see how this shows up. I think you know this is test blog. and I am just testing how this editor works. This is a test blog. and again this is a test blog. This blog entry is test blog entry.
public static void main(String[] args)
{
System.out.println("This is test blog");
}
The main topic of this blog is
- This is a test blog
- This is a test blog
- This is a test blog
Saturday, June 20, 2009
Test Blog from Flock
This is test block from flock
public static void main(String [] args)
{
System.out.pritln("Hello World");
}
Subscribe to:
Posts (Atom)