forked from eprunier/ariane
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eaad826
Showing
15 changed files
with
417 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/target | ||
/lib | ||
/classes | ||
/checkouts | ||
pom.xml | ||
*.jar | ||
*.class | ||
.lein-deps-sum | ||
.lein-failures | ||
.lein-plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Ariane | ||
|
||
Atom & RSS parser for Clojure | ||
|
||
## Usage | ||
|
||
FIXME | ||
|
||
## License | ||
|
||
Copyright © 2013 FIXME | ||
|
||
Distributed under the Eclipse Public License, the same as Clojure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!DOCTYPE html> | ||
<html><head><link href="css/default.css" rel="stylesheet" type="text/css"><script src="js/jquery.min.js" type="text/javascript"></script><script src="js/page_effects.js" type="text/javascript"></script><title>ariane.atom documentation</title></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html">Ariane 0.1.0-SNAPSHOT API documentation</a></h1></div><div class="sidebar" id="namespaces"><h3><span>Namespaces</span></h3><ul><li class="current"><a href="ariane.atom.html"><span>ariane.atom</span></a></li><li><a href="ariane.core.html"><span>ariane.core</span></a></li><li><a href="ariane.rss.html"><span>ariane.rss</span></a></li></ul></div><div class="sidebar" id="vars"><h3>Public Vars</h3><ul><li><a href="ariane.atom.html#var-parse-atom"><span>parse-atom</span></a></li></ul></div><div class="namespace-docs" id="content"><h2>ariane.atom documentation</h2><pre class="doc">Namespace for parsing Atom feeds. | ||
</pre><div class="public" id="var-parse-atom"><h3>parse-atom</h3><div class="usage"><code>(parse-atom feed)</code></div><pre class="doc">Parse Atom feed generated by ariane.core/parse | ||
</pre></div></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!DOCTYPE html> | ||
<html><head><link href="css/default.css" rel="stylesheet" type="text/css"><script src="js/jquery.min.js" type="text/javascript"></script><script src="js/page_effects.js" type="text/javascript"></script><title>ariane.core documentation</title></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html">Ariane 0.1.0-SNAPSHOT API documentation</a></h1></div><div class="sidebar" id="namespaces"><h3><span>Namespaces</span></h3><ul><li><a href="ariane.atom.html"><span>ariane.atom</span></a></li><li class="current"><a href="ariane.core.html"><span>ariane.core</span></a></li><li><a href="ariane.rss.html"><span>ariane.rss</span></a></li></ul></div><div class="sidebar" id="vars"><h3>Public Vars</h3><ul><li><a href="ariane.core.html#var-infos"><span>infos</span></a></li><li><a href="ariane.core.html#var-items"><span>items</span></a></li><li><a href="ariane.core.html#var-parse"><span>parse</span></a></li></ul></div><div class="namespace-docs" id="content"><h2>ariane.core documentation</h2><pre class="doc">Generic namespace for feed type autodetection and parsing. | ||
</pre><div class="public" id="var-infos"><h3>infos</h3><div class="usage"><code>(infos data)</code></div><pre class="doc">Returns feed informations. | ||
</pre></div><div class="public" id="var-items"><h3>items</h3><div class="usage"><code>(items data)</code></div><pre class="doc">Returns feed items. | ||
</pre></div><div class="public" id="var-parse"><h3>parse</h3><div class="usage"><code>(parse source)</code></div><pre class="doc">Detects the feed type and calls the appropriate parser. | ||
</pre></div></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<!DOCTYPE html> | ||
<html><head><link href="css/default.css" rel="stylesheet" type="text/css"><script src="js/jquery.min.js" type="text/javascript"></script><script src="js/page_effects.js" type="text/javascript"></script><title>ariane.rss documentation</title></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html">Ariane 0.1.0-SNAPSHOT API documentation</a></h1></div><div class="sidebar" id="namespaces"><h3><span>Namespaces</span></h3><ul><li><a href="ariane.atom.html"><span>ariane.atom</span></a></li><li><a href="ariane.core.html"><span>ariane.core</span></a></li><li class="current"><a href="ariane.rss.html"><span>ariane.rss</span></a></li></ul></div><div class="sidebar" id="vars"><h3>Public Vars</h3><ul><li><a href="ariane.rss.html#var-parse-rss"><span>parse-rss</span></a></li></ul></div><div class="namespace-docs" id="content"><h2>ariane.rss documentation</h2><pre class="doc">Namespace for parsing RSS feeds. | ||
</pre><div class="public" id="var-parse-rss"><h3>parse-rss</h3><div class="usage"><code>(parse-rss feed)</code></div><pre class="doc">Parse RSS feed generated by ariane.core/parse | ||
</pre></div></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
body { | ||
font-family: sans-serif; | ||
font-size: 11pt; | ||
} | ||
|
||
pre, code { | ||
font-family: Monaco, DejaVu Sans Mono, Consolas, monospace; | ||
font-size: 9pt; | ||
} | ||
|
||
h2 { | ||
font-weight: normal; | ||
font-size: 18pt; | ||
margin: 10px 0 0.4em 0; | ||
} | ||
|
||
#header, #content, .sidebar { | ||
position: fixed; | ||
} | ||
|
||
#header { | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
height: 20px; | ||
background: #444; | ||
color: #fff; | ||
padding: 5px; | ||
} | ||
|
||
#content { | ||
top: 30px; | ||
right: 0; | ||
bottom: 0; | ||
overflow: auto; | ||
background: #fff; | ||
color: #333; | ||
padding: 0 1em; | ||
} | ||
|
||
.sidebar { | ||
position: fixed; | ||
top: 30px; | ||
bottom: 0; | ||
overflow: auto; | ||
} | ||
|
||
#namespaces { | ||
background: #e6e6e6; | ||
border-right: solid 1px #bbb; | ||
left: 0; | ||
width: 250px; | ||
} | ||
|
||
#vars { | ||
background: #eeeeee; | ||
border-right: solid 1px #ccc; | ||
left: 251px; | ||
width: 200px; | ||
} | ||
|
||
.namespace-index { | ||
left: 251px; | ||
} | ||
|
||
.namespace-docs { | ||
left: 452px; | ||
} | ||
|
||
#header { | ||
background: -moz-linear-gradient(top, #555 0%, #222 100%); | ||
background: -webkit-linear-gradient(top, #555 0%, #333 100%); | ||
background: -o-linear-gradient(top, #555 0%, #222 100%); | ||
background: -ms-linear-gradient(top, #555 0%, #222 100%); | ||
background: linear-gradient(top, #555 0%, #222 100%); | ||
box-shadow: 0 0 10px #555; | ||
z-index: 100; | ||
} | ||
|
||
#header h1 { | ||
margin: 0; | ||
padding: 0; | ||
font-size: 12pt; | ||
font-weight: normal; | ||
text-shadow: -1px -1px 0px #333; | ||
} | ||
|
||
#header a, .sidebar a { | ||
display: block; | ||
text-decoration: none; | ||
} | ||
|
||
#header a { | ||
color: #fff; | ||
} | ||
|
||
.sidebar a { | ||
color: #333; | ||
} | ||
|
||
#header h2 { | ||
float: right; | ||
font-size: 9pt; | ||
font-weight: normal; | ||
width: 10em; | ||
margin: 3px 0; | ||
color: #bbb; | ||
} | ||
|
||
#header h2 a { | ||
display: inline; | ||
} | ||
|
||
.sidebar h3 { | ||
margin: 0; | ||
padding: 10px 0.5em 0 0.5em; | ||
font-size: 14pt; | ||
font-weight: normal | ||
} | ||
|
||
.sidebar ul { | ||
padding: 0.5em 0em; | ||
margin: 0; | ||
} | ||
|
||
.sidebar li { | ||
display: block; | ||
} | ||
|
||
.sidebar li a { | ||
padding: 7px 10px; | ||
} | ||
|
||
#namespaces li.current a { | ||
border-left: 3px solid #a33; | ||
padding-left: 7px; | ||
color: #a33; | ||
} | ||
|
||
#vars li.current a { | ||
border-left: 3px solid #33a; | ||
padding-left: 7px; | ||
color: #33a; | ||
} | ||
|
||
#content h3 { | ||
margin-bottom: 0.5em; | ||
font-size: 13pt; | ||
font-weight: bold; | ||
} | ||
|
||
.public h3, h4.macro { | ||
margin: 0; | ||
float: left; | ||
} | ||
|
||
.usage { | ||
clear: both; | ||
} | ||
|
||
h4.macro { | ||
font-variant: small-caps; | ||
font-size: 13px; | ||
font-weight: bold; | ||
color: #717171; | ||
margin-top: 3px; | ||
margin-left: 10px; | ||
} | ||
|
||
.public { | ||
margin-top: 1.5em; | ||
margin-bottom: 2.0em; | ||
} | ||
|
||
.public:last-child { | ||
margin-bottom: 20%; | ||
} | ||
|
||
.namespace:last-child { | ||
margin-bottom: 10%; | ||
} | ||
|
||
.index { | ||
padding: 0; | ||
} | ||
|
||
.index * { | ||
display: inline; | ||
} | ||
|
||
.index li { | ||
padding: 0 .5em; | ||
} | ||
|
||
.index ul { | ||
padding-left: 0; | ||
} | ||
|
||
.usage code { | ||
display: block; | ||
color: #008; | ||
} | ||
|
||
.doc { | ||
margin-bottom: .5em; | ||
} | ||
|
||
.src-link a { | ||
font-size: 9pt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!DOCTYPE html> | ||
<html><head><link href="css/default.css" rel="stylesheet" type="text/css"><script src="js/jquery.min.js" type="text/javascript"></script><script src="js/page_effects.js" type="text/javascript"></script><title>Ariane 0.1.0-SNAPSHOT API documentation</title></head><body><div id="header"><h2>Generated by <a href="https://github.com/weavejester/codox">Codox</a></h2><h1><a href="index.html">Ariane 0.1.0-SNAPSHOT API documentation</a></h1></div><div class="sidebar" id="namespaces"><h3><span>Namespaces</span></h3><ul><li><a href="ariane.atom.html"><span>ariane.atom</span></a></li><li><a href="ariane.core.html"><span>ariane.core</span></a></li><li><a href="ariane.rss.html"><span>ariane.rss</span></a></li></ul></div><div class="namespace-index" id="content"><h2>Ariane 0.1.0-SNAPSHOT API documentation</h2><div class="doc">Atom & RSS parser for Clojure</div><div class="namespace"><h3><a href="ariane.atom.html"><span>ariane.atom</span></a></h3><pre class="doc">Namespace for parsing Atom feeds. | ||
</pre><div class="index"><p>Public variables and functions:</p><ul><li><a href="ariane.atom.html#var-parse-atom"><span>parse-atom</span></a></li></ul></div></div><div class="namespace"><h3><a href="ariane.core.html"><span>ariane.core</span></a></h3><pre class="doc">Generic namespace for feed type autodetection and parsing. | ||
</pre><div class="index"><p>Public variables and functions:</p><ul><li><a href="ariane.core.html#var-infos"><span>infos</span></a></li><li><a href="ariane.core.html#var-items"><span>items</span></a></li><li><a href="ariane.core.html#var-parse"><span>parse</span></a></li></ul></div></div><div class="namespace"><h3><a href="ariane.rss.html"><span>ariane.rss</span></a></h3><pre class="doc">Namespace for parsing RSS feeds. | ||
</pre><div class="index"><p>Public variables and functions:</p><ul><li><a href="ariane.rss.html#var-parse-rss"><span>parse-rss</span></a></li></ul></div></div></div></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Introduction to ariane | ||
|
||
TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
function visibleInParent(element) { | ||
var position = $(element).position().top | ||
return position > -50 && position < ($(element).offsetParent().height() - 50) | ||
} | ||
|
||
function hasFragment(link, fragment) { | ||
return $(link).attr("href").indexOf("#" + fragment) != -1 | ||
} | ||
|
||
function findLinkByFragment(elements, fragment) { | ||
return $(elements).filter(function(i, e) { return hasFragment(e, fragment)}).first() | ||
} | ||
|
||
function setCurrentVarLink() { | ||
$('#vars li').removeClass('current') | ||
$('.public'). | ||
filter(function(index) { return visibleInParent(this) }). | ||
each(function(index, element) { | ||
findLinkByFragment("#vars a", element.id). | ||
parent(). | ||
addClass('current') | ||
}) | ||
} | ||
|
||
var hasStorage = (function() { try { return localStorage.getItem } catch(e) {} }()) | ||
|
||
function scrollPositionId(element) { | ||
var directory = window.location.href.replace(/[^\/]+\.html$/, '') | ||
return 'scroll::' + $(element).attr('id') + '::' + directory | ||
} | ||
|
||
function storeScrollPosition(element) { | ||
if (!hasStorage) return; | ||
localStorage.setItem(scrollPositionId(element) + "::x", $(element).scrollLeft()) | ||
localStorage.setItem(scrollPositionId(element) + "::y", $(element).scrollTop()) | ||
} | ||
|
||
function recallScrollPosition(element) { | ||
if (!hasStorage) return; | ||
$(element).scrollLeft(localStorage.getItem(scrollPositionId(element) + "::x")) | ||
$(element).scrollTop(localStorage.getItem(scrollPositionId(element) + "::y")) | ||
} | ||
|
||
function persistScrollPosition(element) { | ||
recallScrollPosition(element) | ||
$(element).scroll(function() { storeScrollPosition(element) }) | ||
} | ||
|
||
function sidebarContentWidth(element) { | ||
var widths = $(element).find('span').map(function() { return $(this).width() }) | ||
return Math.max.apply(Math, widths) | ||
} | ||
|
||
function resizeNamespaces() { | ||
var width = sidebarContentWidth('#namespaces') + 40 | ||
$('#namespaces').css('width', width) | ||
$('#vars, .namespace-index').css('left', width + 1) | ||
$('.namespace-docs').css('left', $('#vars').width() + width + 2) | ||
} | ||
|
||
$(window).ready(resizeNamespaces) | ||
$(window).ready(setCurrentVarLink) | ||
$(window).ready(function() { persistScrollPosition('#namespaces')}) | ||
$(window).ready(function() { | ||
$('#content').scroll(setCurrentVarLink) | ||
$(window).resize(setCurrentVarLink) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
(defproject ariane "0.1.0-SNAPSHOT" | ||
:description "Atom & RSS parser for Clojure" | ||
:url "http://github.com/eprunier/ariane" | ||
:license {:name "Eclipse Public License" | ||
:url "http://www.eclipse.org/legal/epl-v10.html"} | ||
:dependencies [[org.clojure/clojure "1.5.1"]]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
(ns ariane.atom | ||
"Namespace for parsing Atom feeds.") | ||
|
||
(defn parse-atom | ||
"Parse Atom feed generated by ariane.core/parse" | ||
[feed] | ||
(for [tag feed] | ||
(let [tag-name (:tag tag) | ||
tag-content (:content tag)] | ||
(cond | ||
(= tag-name :subtitle) [:description (first tag-content)] | ||
(= tag-name :summary) [:description (first tag-content)] | ||
(= tag-name :link) [:link (get-in tag [:attrs :href])] | ||
(= tag-name :author) [:author (parse-atom (:content tag))] | ||
(= tag-name :entry) [:item (parse-atom (:content tag))] | ||
:else [tag-name (first tag-content)])))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
(ns ariane.core | ||
"Generic namespace for feed type autodetection and parsing." | ||
(:require [clojure.xml :as xml] | ||
[ariane.rss :as rss] | ||
[ariane.atom :as atom])) | ||
|
||
(defn- rss? | ||
[feed] | ||
(-> feed :tag (= :rss))) | ||
|
||
(defn- atom? | ||
[feed] | ||
(-> feed :tag (= :feed))) | ||
|
||
(defn parse | ||
"Detects the feed type and calls the appropriate parser." | ||
[source] | ||
(let [feed (xml/parse source)] | ||
(cond | ||
(rss? feed) (rss/parse-rss (:content feed)) | ||
(atom? feed) (atom/parse-atom (:content feed)) | ||
:else (println "Unkown format")))) | ||
|
||
(defn infos | ||
"Returns feed informations." | ||
[data] | ||
(filter (fn [[name _]] | ||
(not= :item name)) | ||
data)) | ||
|
||
(defn items | ||
"Returns feed items." | ||
[data] | ||
(filter (fn [[name _]] | ||
(= :item name)) | ||
data)) |
Oops, something went wrong.