Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit

Permalink
Init Clojure project
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlynux committed Jan 28, 2018
1 parent 2121547 commit db46e30
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

.gradle
build/
target/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

*~
*~

.lein-repl-history
.nrepl-port
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
language: java

jdk:
- oraclejdk8
language: clojure
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# library-monkey
Substitute for 'check-mediatheque' project

Currently rewrite the project with Clojure.

Previous project was for the library of the city "Lomme", this version is for the city of "Amiens".

3 changes: 3 additions & 0 deletions project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(defproject library-monkey "0.1.0"
:dependencies [[org.clojure/clojure "1.9.0"]
[http-kit "2.2.0"]])
33 changes: 33 additions & 0 deletions src/playground.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
(require '[org.httpkit.client :as http])

(defn find-auth [cookies]
(->>
(clojure.string/split cookies #"; (path=/,)?")
(filter #(clojure.string/includes? % "S_ARCHIMED_CRYSTAL_AUTH=EXPLOITATION"))
(first)))


(defn auth-cookie [name password]
(let [response
@(http/post "http://bibliotheques.amiens.fr/CDA/pages/logon.aspx?INSTANCE=EXPLOITATION"
{
:form-params {
:name name
:pwd password
}
:follow-redirects false
})]
((comp find-auth :set-cookie :headers) response)))

(defn get-borrowings [cookie]
(let [response
@(http/get "http://bibliotheques.amiens.fr/cda/default.aspx?INSTANCE=EXPLOITATION&PORTAL_ID=erm_portal_services.xml&PAGE=/clientBookline/recherche/dossier_lecteur.asp%3FINSTANCE%3DEXPLOITATION%26OUTPUT%3DCANVAS%26STRCODEDOCBASE%3DCAAM"
{
:headers {
"Accept" "application/json"
"Cookie" cookie
}
:follow-redirects false
})]
(println (:error response))
(println (:status response))))

0 comments on commit db46e30

Please sign in to comment.