Commit d5e6734a authored by Vlad Dumitru's avatar Vlad Dumitru
Browse files

first commit

parents
Pipeline #6552 failed with stages
in 0 seconds
/target
/lib
/classes
/checkouts
pom.xml
dev-config.edn
test-config.edn
*.jar
*.class
/.lein-*
profiles.clj
/.env
.nrepl-port
/node_modules
/log
FROM openjdk:8-alpine
COPY target/uberjar/tunein.jar /tunein/app.jar
EXPOSE 3000
CMD ["java", "-jar", "/tunein/app.jar"]
web: java -Dclojure.main.report=stderr -cp target/uberjar/tunein.jar clojure.main -m tunein.core
# tunein
generated using Luminus version "4.30"
FIXME
## Prerequisites
You will need [Leiningen][1] 2.0 or above installed.
[1]: https://github.com/technomancy/leiningen
## Running
To start a web server for the application, run:
lein run
## License
Copyright © 2022 FIXME
(ns tunein.dev-middleware
(:require
[ring.middleware.reload :refer [wrap-reload]]
[selmer.middleware :refer [wrap-error-page]]
[prone.middleware :refer [wrap-exceptions]]))
(defn wrap-dev [handler]
(-> handler
wrap-reload
wrap-error-page
(wrap-exceptions {:app-namespaces ['tunein]})))
(ns tunein.env
(:require
[selmer.parser :as parser]
[clojure.tools.logging :as log]
[tunein.dev-middleware :refer [wrap-dev]]))
(def defaults
{:init
(fn []
(parser/cache-off!)
(log/info "\n-=[tunein started successfully using the development profile]=-"))
:stop
(fn []
(log/info "\n-=[tunein has shut down successfully]=-"))
:middleware wrap-dev})
(ns user
"Userspace functions you can run by default in your local REPL."
(:require
[tunein.config :refer [env]]
[clojure.pprint]
[clojure.spec.alpha :as s]
[expound.alpha :as expound]
[mount.core :as mount]
[tunein.core :refer [start-app]]))
(alter-var-root #'s/*explain-out* (constantly expound/printer))
(add-tap (bound-fn* clojure.pprint/pprint))
(defn start
"Starts application.
You'll usually want to run this on startup."
[]
(mount/start-without #'tunein.core/repl-server))
(defn stop
"Stops application."
[]
(mount/stop-except #'tunein.core/repl-server))
(defn restart
"Restarts application."
[]
(stop)
(start))
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<charset>UTF-8</charset>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg %n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/tunein.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/tunein.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg %n</pattern>
</encoder>
</appender>
<logger name="org.apache.http" level="warn" />
<logger name="org.xnio.nio" level="warn" />
<logger name="io.undertow.websockets.core.request" level="warn" />
<logger name="io.undertow.request" level="warn" />
<logger name="io.undertow.session" level="warn" />
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
(ns tunein.env
(:require [clojure.tools.logging :as log]))
(def defaults
{:init
(fn []
(log/info "\n-=[tunein started successfully]=-"))
:stop
(fn []
(log/info "\n-=[tunein has shut down successfully]=-"))
:middleware identity})
{:prod true
:port 3000}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/tunein.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/tunein.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg %n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-5relative %-5level %logger{35} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.apache.http" level="warn" />
<logger name="org.xnio.nio" level="warn" />
<logger name="io.undertow.websockets.core.request" level="warn" />
<logger name="io.undertow.request" level="warn" />
<logger name="io.undertow.session" level="warn" />
<logger name="io.undertow.request" level="warn" />
<root level="INFO">
<appender-ref ref="FILE" />
<appender-ref ref="STDOUT" />
</root>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
<encoder>
<charset>UTF-8</charset>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg %n</pattern>
</encoder>
</appender>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>log/tunein.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/tunein.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!-- keep 30 days of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>%date{ISO8601} [%thread] %-5level %logger{36} - %msg %n</pattern>
</encoder>
</appender>
<logger name="org.apache.http" level="warn" />
<logger name="org.xnio.nio" level="warn" />
<logger name="io.undertow.websockets.core.request" level="warn" />
<logger name="io.undertow.request" level="warn" />
<logger name="io.undertow.session" level="warn" />
<root level="DEBUG">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
(defproject tunein "0.1.0-SNAPSHOT"
:description "Tune-In Sprachworkshop"
:url "https://tunein.spsc.tugraz.at"
:dependencies [[ch.qos.logback/logback-classic "1.2.7"]
[clojure.java-time "0.3.3"]
[cprop "0.1.19"]
[expound "0.8.10"]
[funcool/struct "1.4.0"]
[json-html "0.4.7"]
[luminus-transit "0.1.3"]
[luminus-undertow "0.1.14"]
[luminus/ring-ttl-session "0.3.3"]
[markdown-clj "1.10.7"]
[metosin/muuntaja "0.6.8"]
[metosin/reitit "0.5.15"]
[metosin/ring-http-response "0.9.3"]
[mount "0.1.16"]
[nrepl "0.9.0"]
[org.clojure/clojure "1.10.3"]
[org.clojure/tools.cli "1.0.206"]
[org.clojure/tools.logging "1.2.3"]
[org.webjars.npm/bulma "0.9.3"]
[org.webjars.npm/material-icons "1.0.0"]
[org.webjars/webjars-locator "0.42"]
[org.webjars/webjars-locator-jboss-vfs "0.1.0"]
[ring-webjars "0.2.0"]
[ring/ring-core "1.9.4"]
[ring/ring-defaults "0.3.3"]
[selmer "1.12.45"]
[org.clojure/java.jdbc "0.7.12"]
[org.xerial/sqlite-jdbc "3.36.0.3"]]
:min-lein-version "2.0.0"
:source-paths ["src/clj"]
:test-paths ["test/clj"]
:resource-paths ["resources"]
:target-path "target/%s/"
:main ^:skip-aot tunein.core
:plugins []
:profiles
{:uberjar {:omit-source true
:aot :all
:uberjar-name "tunein.jar"
:source-paths ["env/prod/clj" ]
:resource-paths ["env/prod/resources"]}
:dev [:project/dev :profiles/dev]
:test [:project/dev :project/test :profiles/test]
:project/dev {:jvm-opts ["-Dconf=dev-config.edn" ]
:dependencies [[org.clojure/tools.namespace "1.1.1"]
[pjstadig/humane-test-output "0.11.0"]
[prone "2021-04-23"]
[ring/ring-devel "1.9.4"]
[ring/ring-mock "0.4.0"]]
:plugins [[com.jakemccrary/lein-test-refresh "0.24.1"]
[jonase/eastwood "0.3.5"]
[cider/cider-nrepl "0.26.0"]]
:source-paths ["env/dev/clj" ]
:resource-paths ["env/dev/resources"]
:repl-options {:init-ns user
:timeout 120000}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]}
:project/test {:jvm-opts ["-Dconf=test-config.edn" ]
:resource-paths ["env/test/resources"] }
:profiles/dev {}
:profiles/test {}})
<h1 class="title">Congratulations, your <a class="alert-link" href="http://luminusweb.net">Luminus</a> site is ready!</h1>
This page will help guide you through the first steps of building your site.
<p class="title is-5">Why are you seeing this page?</p>
The `home-routes` handler in the `tunein.routes.home` namespace
defines the route that invokes the `home-page` function whenever an HTTP
request is made to the `/` URI using the `GET` method.
```
(defn home-routes []
[""
{:middleware [middleware/wrap-csrf
middleware/wrap-formats]}
["/" {:get home-page}]
["/about" {:get about-page}]])
```
The `home-page` function will in turn call the `tunein.layout/render` function
to render the HTML content:
```
(defn home-page [request]
(layout/render
request
"home.html" {:docs (-> "docs/docs.md" io/resource slurp)}))
```
The `render` function will render the `home.html` template found in the `resources/html`
folder using a parameter map containing the `:docs` key. This key points to the
contents of the `resources/docs/docs.md` file containing these instructions.
The HTML templates are written using [Selmer](https://github.com/yogthos/Selmer) templating engine.
```
<div class="content">
{{docs|markdown}}
</div>
```
<a class="level-item button" href="https://luminusweb.com/docs/html_templating.html">learn more about HTML templating »</a>
<p class="title is-5">Organizing the routes</p>
The routes are aggregated and wrapped with middleware in the `tunein.handler` namespace:
```
(mount/defstate app-routes
:start
(ring/ring-handler
(ring/router
[(home-routes)])
(ring/routes
(ring/create-resource-handler
{:path "/"})
(wrap-content-type
(wrap-webjars (constantly nil)))
(ring/create-default-handler
{:not-found
(constantly (error-page {:status 404, :title "404 - Page not found"}))
:method-not-allowed
(constantly (error-page {:status 405, :title "405 - Not allowed"}))
:not-acceptable
(constantly (error-page {:status 406, :title "406 - Not acceptable"}))}))))
```
The `app` definition groups all the routes in the application into a single handler.
A default route group is added to handle the `404` case.
<a class="level-item button" href="https://luminusweb.com/docs/routes.html">learn more about routing »</a>
The `home-routes` are wrapped with two middleware functions. The first enables CSRF protection.
The second takes care of serializing and deserializing various encoding formats, such as JSON.
<p class="title is-5">Managing your middleware</p>
Request middleware functions are located under the `tunein.middleware` namespace.
This namespace is reserved for any custom middleware for the application. Some default middleware is
already defined here. The middleware is assembled in the `wrap-base` function.
Middleware used for development is placed in the `tunein.dev-middleware` namespace found in
the `env/dev/clj/` source path.
<a class="level-item button" href="https://luminusweb.com/docs/middleware.html">learn more about middleware »</a>
<p class="title is-5">Need some help?</p>
Visit the [official documentation](https://luminusweb.com/docs/guestbook) for examples
on how to accomplish common tasks with Luminus. The `#luminus` channel on the [Clojurians Slack](http://clojurians.net/) and [Google Group](https://groups.google.com/forum/#!forum/luminusweb) are both great places to seek help and discuss projects with other users.
{% extends "base.html" %}
{% block content %}
<img src="/img/warning_clojure.png"></img>
{% endblock %}
<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Tune-in Sprachworkshop</title>
{% style """/css/fonts.css" %}
{% style """/css/style.css" %}
{% block extracss %}{% endblock %}
{% block extrajs %}{% endblock %}
</head>
<body>
<header>
<div class="lhs">
<img src="/img/TU_Graz.png">
<div class="logo">
<div class="first">
<span>T</span><span>U</span><span>N</span><span>E</span><span>-</span><span>I</span><span>N</span>
</div>
<div class="second">
<span>S</span><span>P</span><span>R</span><span>A</span><span>C</span><span>H</span><span>W</span><span>O</span><span>R</span><span>K</span><span>S</span><span>H</span><span>O</span><span>P</span>
</div>
</div>
</div>
<h2 class="rhs">{{ title }}</h2>
</header>
<main id="main">{% block content %}{% endblock %}</main>
<button class="scroller" id="scroll-up">&uarr;</button>
<button class="scroller" id="scroll-down">&darr;</button>
<script>
window.addEventListener('load', () => {
const up = document.getElementById('scroll-up')
const down = document.getElementById('scroll-down')
const main = document.getElementById('main')
up.addEventListener('click', () =>
main.scrollBy(0, -main.clientHeight))
down.addEventListener('click', () =>
main.scrollBy(0, main.clientHeight))
const updateScrollers = () => {
down.disabled = main.scrollTop === main.scrollTopMax
up.disabled = main.scrollTop === 0
}
main.addEventListener('scroll', updateScrollers)
updateScrollers()
})
</script>
{% block page-scripts %}{% endblock %}
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Something Bad Happened</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% style """/assets/bulma/css/bulma.min.css" %}
<style type="text/css">
html {
height: 100%;
min-height: 100%;
min-width: 100%;
overflow: hidden;
width: 100%;
}
html body {
height: 100%;
margin: 0;
padding: 0;
width: 100%;
}
html .container-fluid {
display: table;
height: 100%;
padding: 0;
width: 100%;
}
html .row-fluid {
display: table-cell;
height: 100%;
vertical-align: middle;
}
</style>
</head>
<body>
<div class="container is-fluid">
<div class="has-text-centered">
<h1><span class="is-size-4 has-text-danger">Error: {{status}}</span></h1>
<hr>
{% if title %}
<h2 class="without-margin">{{title}}</h2>
{% endif %}
{% if message %}
<h4 class="text-danger">{{message}}</h4>
{% endif %}
</div>
</div>
</body>
</html>
{% extends "base.html" %}
{% block content %}
{% endblock %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment