Clean up some stuff and make it uberwar compatible

This commit is contained in:
Aaron Mueller 2013-10-06 18:08:50 +02:00
parent 6ee246f0a6
commit 25126030f7
9 changed files with 58 additions and 64 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
.lein-repl-history
ldview.log
resources/public/site.db
resources/public/img/ld
target/

View file

@ -1,42 +1,34 @@
(defproject
ldview
"0.1.0-SNAPSHOT"
:dependencies
[[org.clojure/clojure "1.5.1"]
[lib-noir "0.7.0"]
[compojure "1.1.5"]
[ring-server "0.3.0"]
[selmer "0.4.2"]
[com.taoensso/timbre "2.6.2"]
[com.postspectacular/rotor "0.1.0"]
[com.taoensso/tower "1.7.1"]
; [com.h2database/h2 "1.3.172"]
[sqlitejdbc "0.5.6"]
[korma "0.3.0-RC5"]
[log4j
"1.2.17"
:exclusions
[javax.mail/mail
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[clj-http "0.7.7"]
[image-resizer "0.1.6"]
[enlive "1.1.1"]
[me.raynes/fs "1.4.5"]]
:ring
{:handler ldview.handler/war-handler,
:init ldview.handler/init,
:destroy ldview.handler/destroy}
:profiles
{:production
{:ring
{:open-browser? false, :stacktraces? false, :auto-reload? false}},
:dev
{:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.2.0"]]}}
(defproject ldview "1"
:dependencies [[org.clojure/clojure "1.5.1"]
[lib-noir "0.7.0"]
[compojure "1.1.5"]
[ring-server "0.3.0"]
[selmer "0.4.2"]
[com.taoensso/timbre "2.6.2"]
[com.postspectacular/rotor "0.1.0"]
[com.taoensso/tower "1.7.1"]
[log4j "1.2.17" :exclusions [javax.mail/mail
javax.jms/jms
com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]]
[sqlitejdbc "0.5.6"]
[korma "0.3.0-RC5"]
[clj-http "0.7.7"]
[image-resizer "0.1.6"]
[enlive "1.1.1"]
[me.raynes/fs "1.4.5"]]
:plugins [[lein-ring "0.8.7"]]
:ring {:handler ldview.handler/war-handler
:init ldview.handler/init
:destroy ldview.handler/destroy}
:profiles {
:production {:ring {:open-browser? false
:stacktraces? false
:auto-reload? false}}
:dev {:dependencies [[ring-mock "0.1.5"]
[ring/ring-devel "1.2.0"]]}}
:url "http://ldview.clojurecup.com/"
:plugins
[[lein-ring "0.8.7"]]
:description
"An alternative Ludum Dare entries viewer"
:description "An alternative Ludum Dare entries viewer"
:min-lein-version "2.0.0")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

View file

@ -5,7 +5,8 @@
[compojure.route :as route]
[taoensso.timbre :as timbre]
[com.postspectacular.rotor :as rotor]
[ldview.models.schema :as schema]))
[ldview.models.schema :as schema])
(:use ldview.util))
(defroutes app-routes
(route/resources "/")
@ -29,7 +30,7 @@
[:shared-appender-config :rotor]
{:path "ldview.log" :max-size (* 512 1024) :backlog 10})
(if-not (schema/initialized?) (schema/create-tables))
;(if-not (schema/initialized?) (schema/create-tables))
(timbre/info "ldview started successfully"))

View file

@ -1,11 +1,11 @@
(ns ldview.models.competition
(:use korma.core
[ldview.models.db]
[ldview.util]))
[ldview.tasks.scrape :as configuration :only [competition]]))
(defn latest []
(first (select competitions
(where {:number *competition*})
(where {:number configuration/competition}) ; FIXME: Make it dynamic
(limit 1))))
(defn exists? [number]

View file

@ -3,11 +3,13 @@
[image-resizer.util :as utils]
[image-resizer.format :refer :all]
[image-resizer.crop :refer :all]
[clojure.java.io :as io])
(:use [ldview.util]))
[clojure.java.io :as io]
[noir.io :as noir-io]))
(def base-path (str (noir-io/resource-path) "img/ld/"))
(defn image-name [folder entry-id number]
(str *image-base-path* "/" folder "/" entry-id "_" number ".png"))
(str base-path folder "/" entry-id "_" number ".png"))
(defn to-square [file new-size]
(let [[width height] (dimensions (utils/buffered-image file))]

View file

@ -4,15 +4,14 @@
[me.raynes.fs :as fs]
[ldview.models.entry :as entry]
[ldview.models.competition :as competition]
[ldview.models.schema :as schema])
(:use [ldview.util]))
[ldview.models.schema :as schema]))
(defn cleanup []
(if (fs/exists? *image-base-path*)
(fs/delete-dir *image-base-path*))
(fs/mkdirs (str *image-base-path* "/thumbs/"))
(fs/mkdirs (str *image-base-path* "/fullscreen/"))
(fs/mkdirs (str *image-base-path* "/raw/")))
(if (fs/exists? images/base-path)
(fs/delete-dir images/base-path))
(fs/mkdirs (str images/base-path "/thumbs/"))
(fs/mkdirs (str images/base-path "/fullscreen/"))
(fs/mkdirs (str images/base-path "/raw/")))
(defn save-entry [new-entry]
(entry/create! new-entry)
@ -36,7 +35,7 @@
(defn prepare []
(cleanup)
(schema/create-tables)
(competition/create! 27 "10 Seconds"))
(competition/create! 27 "10 Seconds")) ; FIXME: Make it dynamic (ldview.tasks.scrape#competition)
(defn start []
(fetch-all-content))

View file

@ -2,13 +2,14 @@
(:require [net.cgrand.enlive-html :as html]
[clj-http.client :as http]
[clojure.java.io :as io])
(:use [clojure.string :only (split)]
[ldview.util]))
(:use [clojure.string :only (split)]))
; Some helper functions to construct proper urls. If the Ludum Date Website
; changes some URL stuff, this is the place to crank.
(def competition 27)
(defn url-action [action]
(str *base-url* "/ludum-dare-" *competition* "/?action=" action))
(str "http://www.ludumdare.com/compo/ludum-dare-" competition "/?action=" action))
(defn url-page [page]
(str (url-action "preview") "&start=" page))

View file

@ -1,7 +1 @@
(ns ldview.util)
; Global stuff that does not change over time and needed everywhere
(def ^:dynamic *base-url* "http://www.ludumdare.com/compo/")
(def ^:dynamic *image-base-path* "resources/public/img/ld")
(def ^:dynamic *competition* 27)