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,8 +1,5 @@
(defproject (defproject ldview "1"
ldview :dependencies [[org.clojure/clojure "1.5.1"]
"0.1.0-SNAPSHOT"
:dependencies
[[org.clojure/clojure "1.5.1"]
[lib-noir "0.7.0"] [lib-noir "0.7.0"]
[compojure "1.1.5"] [compojure "1.1.5"]
[ring-server "0.3.0"] [ring-server "0.3.0"]
@ -10,33 +7,28 @@
[com.taoensso/timbre "2.6.2"] [com.taoensso/timbre "2.6.2"]
[com.postspectacular/rotor "0.1.0"] [com.postspectacular/rotor "0.1.0"]
[com.taoensso/tower "1.7.1"] [com.taoensso/tower "1.7.1"]
; [com.h2database/h2 "1.3.172"] [log4j "1.2.17" :exclusions [javax.mail/mail
[sqlitejdbc "0.5.6"]
[korma "0.3.0-RC5"]
[log4j
"1.2.17"
:exclusions
[javax.mail/mail
javax.jms/jms javax.jms/jms
com.sun.jdmk/jmxtools com.sun.jdmk/jmxtools
com.sun.jmx/jmxri]] com.sun.jmx/jmxri]]
[sqlitejdbc "0.5.6"]
[korma "0.3.0-RC5"]
[clj-http "0.7.7"] [clj-http "0.7.7"]
[image-resizer "0.1.6"] [image-resizer "0.1.6"]
[enlive "1.1.1"] [enlive "1.1.1"]
[me.raynes/fs "1.4.5"]] [me.raynes/fs "1.4.5"]]
:ring
{:handler ldview.handler/war-handler, :plugins [[lein-ring "0.8.7"]]
:init ldview.handler/init, :ring {:handler ldview.handler/war-handler
:init ldview.handler/init
:destroy ldview.handler/destroy} :destroy ldview.handler/destroy}
:profiles :profiles {
{:production :production {:ring {:open-browser? false
{:ring :stacktraces? false
{:open-browser? false, :stacktraces? false, :auto-reload? false}}, :auto-reload? false}}
:dev :dev {:dependencies [[ring-mock "0.1.5"]
{:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.2.0"]]}} [ring/ring-devel "1.2.0"]]}}
:url "http://ldview.clojurecup.com/" :url "http://ldview.clojurecup.com/"
:plugins :description "An alternative Ludum Dare entries viewer"
[[lein-ring "0.8.7"]]
:description
"An alternative Ludum Dare entries viewer"
:min-lein-version "2.0.0") :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] [compojure.route :as route]
[taoensso.timbre :as timbre] [taoensso.timbre :as timbre]
[com.postspectacular.rotor :as rotor] [com.postspectacular.rotor :as rotor]
[ldview.models.schema :as schema])) [ldview.models.schema :as schema])
(:use ldview.util))
(defroutes app-routes (defroutes app-routes
(route/resources "/") (route/resources "/")
@ -29,7 +30,7 @@
[:shared-appender-config :rotor] [:shared-appender-config :rotor]
{:path "ldview.log" :max-size (* 512 1024) :backlog 10}) {: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")) (timbre/info "ldview started successfully"))

View file

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

View file

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

View file

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

View file

@ -2,13 +2,14 @@
(:require [net.cgrand.enlive-html :as html] (:require [net.cgrand.enlive-html :as html]
[clj-http.client :as http] [clj-http.client :as http]
[clojure.java.io :as io]) [clojure.java.io :as io])
(:use [clojure.string :only (split)] (:use [clojure.string :only (split)]))
[ldview.util]))
; Some helper functions to construct proper urls. If the Ludum Date Website ; Some helper functions to construct proper urls. If the Ludum Date Website
; changes some URL stuff, this is the place to crank. ; changes some URL stuff, this is the place to crank.
(def competition 27)
(defn url-action [action] (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] (defn url-page [page]
(str (url-action "preview") "&start=" page)) (str (url-action "preview") "&start=" page))

View file

@ -1,7 +1 @@
(ns ldview.util) (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)