First commit
This commit is contained in:
commit
2ba2a42c2f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
target/
|
14
README.md
Normal file
14
README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# api2smtp
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
lein run
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
``` sh
|
||||
lein check-idiomatic
|
||||
lein check-format
|
||||
```
|
3
config.yaml
Normal file
3
config.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
domain: "http://localhost"
|
||||
debug: true
|
||||
port: 7404
|
42
project.clj
Normal file
42
project.clj
Normal file
@ -0,0 +1,42 @@
|
||||
(defproject api2smtp "0.1.0"
|
||||
:description "api2smtp"
|
||||
:url ""
|
||||
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
|
||||
:url "https://www.eclipse.org/legal/epl-2.0/"}
|
||||
:dependencies [;; Clojure
|
||||
[org.clojure/clojure "1.10.1"]
|
||||
;; Tadam core
|
||||
[tadam-core "0.3.2"]
|
||||
;; HTTP Server
|
||||
[ring "1.8.0"]
|
||||
;; Ring middleware that prevents CSRF attacks
|
||||
[ring/ring-defaults "0.3.2"]
|
||||
[ring/ring-anti-forgery "1.3.0"]
|
||||
;; Routing
|
||||
[compojure "1.6.1"]
|
||||
;; Cors
|
||||
[ring-cors "0.1.13"]
|
||||
;; Templates
|
||||
[selmer "1.12.12"]
|
||||
;; Validations
|
||||
[jkkramer/verily "0.6.0"]
|
||||
;; Yaml
|
||||
[clj-yaml "0.4.0"]
|
||||
;; JSON encoding
|
||||
[cheshire "5.9.0"]]
|
||||
:plugins [;; DEV TOOLS
|
||||
;;; Check idiomatic bug
|
||||
[lein-kibit "0.1.7"]
|
||||
;;; Check format
|
||||
[lein-cljfmt "0.6.4"]
|
||||
;;; Generate documentation
|
||||
[lein-codox "0.10.7"]]
|
||||
;; Map configuration for Ring
|
||||
:ring {:handler api2smtp.core.wrapped-handler}
|
||||
;; ALIAS
|
||||
:aliases {"check-idiomatic" ["kibit" "src"]
|
||||
"check-format" ["cljfmt" "check"]}
|
||||
;; LEIN
|
||||
:main ^:skip-aot api2smtp.core
|
||||
:aot [api2smtp.core]
|
||||
:repl-options {:init-ns api2smtp.core})
|
63
resources/public/css/main.css
Normal file
63
resources/public/css/main.css
Normal file
@ -0,0 +1,63 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Raleway);
|
||||
body {
|
||||
font-family: Raleway, arial;
|
||||
margin: 0;
|
||||
background: yellow;
|
||||
height: 100vh;
|
||||
margin-top: 8rem;
|
||||
}
|
||||
header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
background-color: #3fa46a;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
header > a {
|
||||
margin: 1rem;
|
||||
}
|
||||
header > a > img {
|
||||
height: 3rem;
|
||||
}
|
||||
header ul {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
header ul a {
|
||||
display: block;
|
||||
margin: 1rem;
|
||||
padding: 1rem;
|
||||
color: white;
|
||||
text-decoration: initial;
|
||||
}
|
||||
header ul a:hover {
|
||||
background-color: white;
|
||||
color: #3fa46a;
|
||||
}
|
||||
main {
|
||||
max-width: 800px;
|
||||
margin: 3rem auto;
|
||||
}
|
||||
footer {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.title-welcome {
|
||||
text-align: center;
|
||||
color: #3fa46a;
|
||||
}
|
||||
|
||||
.logo-welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.logo-welcome img {
|
||||
width: 20rem;
|
||||
margin: 4rem auto;
|
||||
}
|
82
resources/public/img/rabbit.svg
Normal file
82
resources/public/img/rabbit.svg
Normal file
@ -0,0 +1,82 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<g>
|
||||
<path style="fill:#F9D366;" d="M100.233,107.352c-4.331,0-7.843-3.511-7.843-7.843v-20.39c0-4.331,3.511-7.843,7.843-7.843
|
||||
s7.843,3.511,7.843,7.843v20.39C108.075,103.841,104.564,107.352,100.233,107.352z"/>
|
||||
<path style="fill:#F9D366;" d="M100.233,162.248c-4.331,0-7.843-3.511-7.843-7.843v-20.39c0-4.331,3.511-7.843,7.843-7.843
|
||||
s7.843,3.511,7.843,7.843v20.39C108.075,158.737,104.564,162.248,100.233,162.248z"/>
|
||||
<path style="fill:#F9D366;" d="M137.876,124.605h-20.39c-4.331,0-7.843-3.511-7.843-7.843s3.511-7.843,7.843-7.843h20.39
|
||||
c4.331,0,7.843,3.511,7.843,7.843S142.207,124.605,137.876,124.605z"/>
|
||||
<path style="fill:#F9D366;" d="M82.98,124.605h-20.39c-4.331,0-7.843-3.511-7.843-7.843s3.511-7.843,7.843-7.843h20.39
|
||||
c4.331,0,7.843,3.511,7.843,7.843S87.311,124.605,82.98,124.605z"/>
|
||||
</g>
|
||||
<path style="fill:#4E4F75;" d="M415.308,254.787v214.565c0,23.558-61.158,42.648-136.6,42.648c-21.666,0-42.16-1.578-60.355-4.383
|
||||
c-45.177-6.948-76.245-21.471-76.245-38.265V256.281l76.245,26.513L415.308,254.787z"/>
|
||||
<g>
|
||||
<path style="fill:#32314C;" d="M218.352,282.794v224.822c-45.177-6.948-76.245-21.471-76.245-38.265v-213.07L218.352,282.794z"/>
|
||||
<path style="fill:#32314C;" d="M415.308,281.715v28.604c-37.942,8.996-85.269,14.339-136.6,14.339s-98.658-5.343-136.6-14.339
|
||||
v-27.11l76.245-0.415L415.308,281.715z"/>
|
||||
</g>
|
||||
<ellipse style="fill:#4E4F75;" cx="278.702" cy="225.004" rx="226.071" ry="70.585"/>
|
||||
<path style="fill:#32314C;" d="M278.705,243.92c-44.946,0-89.031-4.551-124.134-12.815c-0.085-0.02-0.169-0.04-0.254-0.06
|
||||
c-6.355-1.501-6.355-10.573,0-12.075c0.085-0.02,0.169-0.04,0.254-0.06c35.103-8.264,79.187-12.815,124.134-12.815
|
||||
s89.03,4.551,124.134,12.815c0.085,0.02,0.169,0.04,0.254,0.06c6.355,1.501,6.355,10.573,0,12.075
|
||||
c-0.085,0.02-0.169,0.04-0.254,0.06C367.735,239.369,323.651,243.92,278.705,243.92z"/>
|
||||
<path style="fill:#EDE6F5;" d="M382.973,170.335c0,22.524-1.882,44.547-5.469,65.838c-8.533,1.433-17.411,2.687-26.55,3.733
|
||||
c-0.094,0.01-0.199,0.021-0.293,0.031c-5.145,0.596-10.363,1.119-15.654,1.579c-3.66,0.314-7.362,0.607-11.084,0.857
|
||||
c-4.172,0.293-8.376,0.544-12.601,0.742c-4.382-23.445-6.693-47.799-6.693-72.781c0-62.083,14.274-120.256,39.172-170.335
|
||||
C368.7,50.079,382.973,108.251,382.973,170.335z"/>
|
||||
<path style="fill:#CEC1E8;" d="M352.596,100.722c-13.197,39.507-6.034,108.816-1.935,139.215
|
||||
c-5.145,0.596-10.363,1.119-15.654,1.579c-4.329-31.842-11.565-103.044,2.719-145.771c1.37-4.11,5.814-6.327,9.924-4.957
|
||||
C351.759,92.168,353.976,96.613,352.596,100.722z"/>
|
||||
<path style="fill:#EDE6F5;" d="M253.128,170.335c0,24.982-2.311,49.347-6.703,72.792c-4.35-0.199-8.669-0.46-12.946-0.753
|
||||
c-3.608-0.251-7.184-0.523-10.739-0.826c-5.291-0.46-10.509-0.983-15.654-1.569c-0.209-0.021-0.429-0.052-0.638-0.073
|
||||
c-9.014-1.046-17.767-2.259-26.184-3.681c-3.597-21.301-5.479-43.344-5.479-65.89c0-62.083,14.263-120.256,39.162-170.335
|
||||
C238.844,50.079,253.128,108.251,253.128,170.335z"/>
|
||||
<path style="fill:#CEC1E8;" d="M222.74,241.547c-5.291-0.46-10.509-0.983-15.654-1.569c4.099-30.378,11.273-99.76-1.935-139.256
|
||||
c-1.37-4.11,0.847-8.554,4.957-9.934c4.11-1.37,8.554,0.847,9.924,4.957C234.316,138.493,227.059,209.727,222.74,241.547z"/>
|
||||
<g>
|
||||
<path style="fill:#F9D366;" d="M479.178,85.85l7.665-1.554c10.115-2.051,10.115-16.507,0-18.558l-7.665-1.554
|
||||
c-19.309-3.915-34.399-19.006-38.314-38.314l-1.554-7.665c-2.051-10.115-16.508-10.115-18.558,0l-1.554,7.665
|
||||
c-3.915,19.309-19.006,34.399-38.314,38.314l-7.665,1.554c-10.115,2.051-10.115,16.507,0,18.558l7.665,1.554
|
||||
c19.309,3.915,34.4,19.006,38.314,38.314l1.554,7.665c2.051,10.115,16.508,10.115,18.558,0l1.554-7.665
|
||||
C444.78,104.856,459.87,89.765,479.178,85.85z"/>
|
||||
<path style="fill:#F9D366;" d="M157.078,421.079l22.925-4.648c10.823-2.194,10.823-17.662,0-19.856l-22.925-4.648
|
||||
c-22.591-4.58-40.247-22.237-44.828-44.828l-4.648-22.925c-2.194-10.823-17.662-10.823-19.856,0l-4.648,22.925
|
||||
c-4.58,22.591-22.237,40.247-44.828,44.828l-22.925,4.648c-10.823,2.194-10.823,17.662,0,19.856l22.925,4.648
|
||||
c22.591,4.58,40.247,22.237,44.828,44.827l4.648,22.925c2.194,10.823,17.662,10.823,19.856,0l4.648-22.925
|
||||
C116.831,443.316,134.487,425.659,157.078,421.079z"/>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.5 KiB |
3
resources/public/js/main.js
Normal file
3
resources/public/js/main.js
Normal file
@ -0,0 +1,3 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
});
|
29
resources/templates/layouts/base.html
Normal file
29
resources/templates/layouts/base.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!doctype html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
<script src="/js/main.js"> </script>
|
||||
<title>{% block title %}{% endblock %} | Tadam Framework</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<a href="/">
|
||||
<img alt="brand" src="/img/rabbit.svg">
|
||||
</a>
|
||||
<nav>
|
||||
<ul>
|
||||
<li><a href="/">Welcome</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
<main>
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
<footer>
|
||||
2020 Tadam Framework
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
9
resources/templates/public/404.html
Normal file
9
resources/templates/public/404.html
Normal file
@ -0,0 +1,9 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block title %}
|
||||
404
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>404</h1>
|
||||
{% endblock %}
|
12
resources/templates/public/welcome.html
Normal file
12
resources/templates/public/welcome.html
Normal file
@ -0,0 +1,12 @@
|
||||
{% extends "layouts/base.html" %}
|
||||
|
||||
{% block title %}
|
||||
Welcome to Tadam
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="title-welcome">Welcome to Tadam Framework </h1>
|
||||
<p class="logo-welcome">
|
||||
<img class="logo-welcome" alt="rabbit" src="/img/rabbit.svg">
|
||||
</p>
|
||||
{% endblock %}
|
5
src/api2smtp/config.clj
Normal file
5
src/api2smtp/config.clj
Normal file
@ -0,0 +1,5 @@
|
||||
(ns api2smtp.config
|
||||
(:require
|
||||
[clj-yaml.core :as yaml]))
|
||||
|
||||
(def config (yaml/parse-string (slurp "config.yaml")))
|
24
src/api2smtp/core.clj
Normal file
24
src/api2smtp/core.clj
Normal file
@ -0,0 +1,24 @@
|
||||
(ns api2smtp.core
|
||||
(:require
|
||||
[api2smtp.config :refer [config]]
|
||||
[ring.middleware.defaults :refer [site-defaults wrap-defaults]]
|
||||
[ring.middleware.reload :refer [wrap-reload]]
|
||||
[ring.middleware.cors :refer [wrap-cors]]
|
||||
[api2smtp.urls :refer [all-routes]]
|
||||
[ring.adapter.jetty :refer [run-jetty]]) (:gen-class))
|
||||
|
||||
(def wrapped-handler
|
||||
;; Handler middlewares
|
||||
(-> all-routes
|
||||
(wrap-defaults (assoc-in site-defaults [:security :anti-forgery] false))
|
||||
(wrap-cors
|
||||
:access-control-allow-origin [(re-pattern (if (config :debug) ".*" (config :domain)))]
|
||||
:access-control-allow-methods [:get])
|
||||
(#(if (config :debug) (wrap-reload %) %))))
|
||||
|
||||
(defn -main [& args]
|
||||
;; Main
|
||||
;; Welcome
|
||||
(prn (str "Open " (config :domain) ":" (config :port)))
|
||||
;; Run web server
|
||||
(run-jetty wrapped-handler {:port (config :port)}))
|
20
src/api2smtp/urls.clj
Normal file
20
src/api2smtp/urls.clj
Normal file
@ -0,0 +1,20 @@
|
||||
(ns api2smtp.urls
|
||||
(:require
|
||||
[compojure.core :refer [defroutes GET]]
|
||||
[compojure.route :as route]
|
||||
[api2smtp.views.public :as view-public]))
|
||||
|
||||
(defroutes public
|
||||
;; Urls public pages
|
||||
(GET "/" [] view-public/index)
|
||||
(GET "/api" [] view-public/api))
|
||||
|
||||
|
||||
(defroutes resources-routes
|
||||
;; Resources (statics)
|
||||
(route/resources "/")
|
||||
(route/not-found view-public/page-404))
|
||||
|
||||
(def all-routes
|
||||
;; Wrap routers. "resources-routes" should always be the last.
|
||||
(compojure.core/routes public resources-routes))
|
20
src/api2smtp/views/public.clj
Normal file
20
src/api2smtp/views/public.clj
Normal file
@ -0,0 +1,20 @@
|
||||
;;;; Views public web
|
||||
(ns api2smtp.views.public
|
||||
(:require
|
||||
[tadam.templates :refer [render-HTML render-JSON render-404]]
|
||||
))
|
||||
|
||||
(defn index
|
||||
;; View HTML
|
||||
[req]
|
||||
(render-HTML req "public/welcome.html" {}))
|
||||
|
||||
(defn api
|
||||
;; View JSON
|
||||
[req]
|
||||
(render-JSON req {:result true}))
|
||||
|
||||
(defn page-404
|
||||
;; View page 404
|
||||
[req]
|
||||
(render-404 req "public/404.html" {}))
|
Loading…
Reference in New Issue
Block a user