Bring the project up to date and rearrange the files

This commit is contained in:
Aaron Mueller 2014-04-23 23:23:44 +02:00
parent cd8d113e79
commit 7cce88f523
25 changed files with 32 additions and 86 deletions

View file

@ -1,19 +1,18 @@
(defproject ldview "2" (defproject ldview "2"
:dependencies [[org.clojure/clojure "1.5.1"] :dependencies [[org.clojure/clojure "1.5.1"]
[lib-noir "0.7.9"] [lib-noir "0.8.2"]
[compojure "1.1.6"] [compojure "1.1.6"]
[ring-server "0.3.1"] [ring-server "0.3.1"]
[selmer "0.5.9"] [com.taoensso/timbre "3.1.6"]
[com.taoensso/timbre "3.0.0-RC4"]
[com.postspectacular/rotor "0.1.0"] [com.postspectacular/rotor "0.1.0"]
[com.taoensso/tower "2.0.1"] [com.taoensso/tower "2.1.0-RC1"]
[log4j "1.2.17" :exclusions [javax.mail/mail [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"] [sqlitejdbc "0.5.6"]
[korma "0.3.0-RC6"] [korma "0.3.0-RC6"]
[clj-http "0.7.8"] [clj-http "0.9.1"]
[image-resizer "0.1.6"] [image-resizer "0.1.6"]
[enlive "1.1.5"] [enlive "1.1.5"]
[me.raynes/fs "1.4.5"]] [me.raynes/fs "1.4.5"]]

View file

@ -2,6 +2,5 @@
(:require [ldview.tasks.runner :as runner]) (:require [ldview.tasks.runner :as runner])
(:gen-class)) (:gen-class))
;; TODO: Grab the title from the page
(defn -main [competition-id] (defn -main [competition-id]
(runner/load-competition competition-id "some title")) (runner/load-competition competition-id))

View file

@ -1,4 +1,4 @@
(ns ldview.models.db (ns ldview.db
(:use korma.core (:use korma.core
[korma.db :only (defdb)]) [korma.db :only (defdb)])
(:require [ldview.models.schema :as schema])) (:require [ldview.models.schema :as schema]))

View file

@ -1,12 +1,11 @@
(ns ldview.handler (ns ldview.handler
(:require [compojure.core :refer [defroutes]] (:require [compojure.core :refer [defroutes]]
[ldview.routes.home :refer [home-routes]] [ldview.routes :refer [all-routes]]
[noir.util.middleware :as middleware] [noir.util.middleware :as middleware]
[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 "/")
@ -33,7 +32,7 @@
(def app (middleware/app-handler (def app (middleware/app-handler
;; add your application routes here ;; add your application routes here
[home-routes app-routes] [all-routes app-routes]
;; add custom middleware here ;; add custom middleware here
:middleware [] :middleware []
;; add access rules here ;; add access rules here

View file

@ -1,6 +1,6 @@
(ns ldview.models.competition (ns ldview.models.competition
(:use korma.core (:use korma.core
[ldview.models.db])) [ldview.db]))
(defn latest [] (defn latest []
(first (select competitions (first (select competitions

View file

@ -1,6 +1,6 @@
(ns ldview.models.entry (ns ldview.models.entry
(:use korma.core (:use korma.core
[ldview.models.db]) [ldview.db])
(:require [ldview.models.user :as user] (:require [ldview.models.user :as user]
[ldview.models.competition :as competition] [ldview.models.competition :as competition]
[ldview.models.source :as source])) [ldview.models.source :as source]))

View file

@ -1,6 +1,6 @@
(ns ldview.models.source (ns ldview.models.source
(:use korma.core (:use korma.core
[ldview.models.db])) [ldview.db]))
(defn create! [entry_id uri title] (defn create! [entry_id uri title]
; (if (empty? (select sources (where {:entry_id entry_id :type title}))) ; (if (empty? (select sources (where {:entry_id entry_id :type title})))

View file

@ -1,6 +1,6 @@
(ns ldview.models.user (ns ldview.models.user
(:use korma.core (:use korma.core
[ldview.models.db])) [ldview.db]))
(defn user-id [username] (defn user-id [username]
(first (select users (first (select users

13
src/ldview/routes.clj Normal file
View file

@ -0,0 +1,13 @@
(ns ldview.routes
(:use compojure.core)
(:require [ldview.models.entry :as entry]
[ldview.templates :as templates]))
; TODO: Replace with enlive template stuff
(defn entries-page []
"bla")
; (layout/render "entries.html" {:entries (entry/all) :competition-id 28}))
(defroutes all-routes
(GET "/" [] (entries-page)))

View file

@ -1,13 +0,0 @@
(ns ldview.routes.home
(:use compojure.core)
(:require [ldview.views.layout :as layout]
[ldview.util :as util]
[ldview.models.entry :as entry]))
; TODO: Make dropdown or something to choose the competition-id
(defn entries-page []
(layout/render "entries.html" {:entries (entry/all)
:competition-id 28}))
(defroutes home-routes
(GET "/" [] (entries-page)))

6
src/ldview/templates.clj Normal file
View file

@ -0,0 +1,6 @@
(ns ldview.templates
(:require [net.cgrand.enlive-html :as html]))
(html/deftemplate home-template "../resources/views/layout.html"
[]
[:body] (html/content "test"))

View file

@ -1 +0,0 @@
(ns ldview.util)

View file

@ -1,19 +0,0 @@
(ns ldview.views.layout
(:require [selmer.parser :as parser]
[ring.util.response :refer [content-type response]])
(:import compojure.response.Renderable))
(def template-path "ldview/views/templates/")
(deftype RenderableTemplate [template params]
Renderable
(render [this request]
(content-type
(->> (assoc params :servlet-context (:context request))
(parser/render-file (str template-path template))
response)
"text/html; charset=utf-8")))
(defn render [template & [params]]
(RenderableTemplate. template params))

View file

@ -1,16 +0,0 @@
{% extends "ldview/views/templates/layout.html" %}
{% block content %}
<div id="entries">
{% for entry in entries %}
<div class="entry">
<div class="shadow">
<p>{{entry.title}}</p>
<em>{{entry.author.name}}</em>
</div>
<div class="details"></div>
<a href="http://www.ludumdare.com/compo/ludum-dare-27/?action=preview&uid={{entry.ld_uid}}"><img src="{{servlet-context}}/img/ld{{competition-id}}/thumbs/{{entry.ld_uid}}_0.png" alt="{{entry.title}}" /></a>
</div>
{% endfor %}
</div>
<br style="clear: both" />
{% endblock %}

View file

@ -1,21 +0,0 @@
<!DOCTYPE html PUBLIC "">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ldview -- an alternative Ludum Dare entry viewer</title>
<link href="{{servlet-context}}/css/screen.css" rel="stylesheet" type="text/css">
<script type="text/javascript">var context = "{{servlet-context}}";</script>
<script src="//code.jquery.com/jquery-1.10.1.min.js" type="text/javascript"></script>
<script src="{{servlet-context}}/js/content-browser.js" type="text/javascript"></script>
</head>
<body>
<h1>Ludum Dare submissions viewer</h1>
<div id="container">
{% block content %}
{% endblock %}
</div>
</body>
</html>