Clean up some stuff and make it uberwar compatible
This commit is contained in:
parent
6ee246f0a6
commit
25126030f7
9 changed files with 58 additions and 64 deletions
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
.lein-repl-history
|
||||||
|
ldview.log
|
||||||
|
resources/public/site.db
|
||||||
|
resources/public/img/ld
|
||||||
|
target/
|
72
project.clj
72
project.clj
|
@ -1,42 +1,34 @@
|
||||||
(defproject
|
(defproject ldview "1"
|
||||||
ldview
|
:dependencies [[org.clojure/clojure "1.5.1"]
|
||||||
"0.1.0-SNAPSHOT"
|
[lib-noir "0.7.0"]
|
||||||
:dependencies
|
[compojure "1.1.5"]
|
||||||
[[org.clojure/clojure "1.5.1"]
|
[ring-server "0.3.0"]
|
||||||
[lib-noir "0.7.0"]
|
[selmer "0.4.2"]
|
||||||
[compojure "1.1.5"]
|
[com.taoensso/timbre "2.6.2"]
|
||||||
[ring-server "0.3.0"]
|
[com.postspectacular/rotor "0.1.0"]
|
||||||
[selmer "0.4.2"]
|
[com.taoensso/tower "1.7.1"]
|
||||||
[com.taoensso/timbre "2.6.2"]
|
[log4j "1.2.17" :exclusions [javax.mail/mail
|
||||||
[com.postspectacular/rotor "0.1.0"]
|
javax.jms/jms
|
||||||
[com.taoensso/tower "1.7.1"]
|
com.sun.jdmk/jmxtools
|
||||||
; [com.h2database/h2 "1.3.172"]
|
com.sun.jmx/jmxri]]
|
||||||
[sqlitejdbc "0.5.6"]
|
[sqlitejdbc "0.5.6"]
|
||||||
[korma "0.3.0-RC5"]
|
[korma "0.3.0-RC5"]
|
||||||
[log4j
|
[clj-http "0.7.7"]
|
||||||
"1.2.17"
|
[image-resizer "0.1.6"]
|
||||||
:exclusions
|
[enlive "1.1.1"]
|
||||||
[javax.mail/mail
|
[me.raynes/fs "1.4.5"]]
|
||||||
javax.jms/jms
|
|
||||||
com.sun.jdmk/jmxtools
|
:plugins [[lein-ring "0.8.7"]]
|
||||||
com.sun.jmx/jmxri]]
|
:ring {:handler ldview.handler/war-handler
|
||||||
[clj-http "0.7.7"]
|
:init ldview.handler/init
|
||||||
[image-resizer "0.1.6"]
|
:destroy ldview.handler/destroy}
|
||||||
[enlive "1.1.1"]
|
:profiles {
|
||||||
[me.raynes/fs "1.4.5"]]
|
:production {:ring {:open-browser? false
|
||||||
:ring
|
:stacktraces? false
|
||||||
{:handler ldview.handler/war-handler,
|
:auto-reload? false}}
|
||||||
:init ldview.handler/init,
|
:dev {:dependencies [[ring-mock "0.1.5"]
|
||||||
:destroy ldview.handler/destroy}
|
[ring/ring-devel "1.2.0"]]}}
|
||||||
: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/"
|
: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 |
|
@ -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"))
|
||||||
|
|
||||||
|
|
|
@ -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]
|
||||||
|
|
|
@ -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))]
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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))
|
||||||
|
|
|
@ -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)
|
|
||||||
|
|
Loading…
Reference in a new issue