Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jarppe/clj-webjars-tools
Clojure tool for serving WebJar resources
https://github.com/jarppe/clj-webjars-tools
Last synced: about 2 months ago
JSON representation
Clojure tool for serving WebJar resources
- Host: GitHub
- URL: https://github.com/jarppe/clj-webjars-tools
- Owner: jarppe
- License: epl-1.0
- Created: 2015-03-12T09:50:47.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-12T16:43:46.000Z (almost 10 years ago)
- Last Synced: 2023-03-11T00:52:43.145Z (almost 2 years ago)
- Language: Clojure
- Size: 125 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clj-webjars-tools
Clojure tool for serving WebJar content.
## Usage
This tool allows your ring application to serve static content from
WebJars. Main entry point is a function ```webjar-resource``` that
returns a ring handler.Forexample, say you wan't to include awesome [Font Awesome](http://fontawesome.io) to your
new project. First, add [Font Awesome WebJar](https://github.com/webjars/font-awesome) and
this library to your ```project.clj```:```clj
[org.webjars/font-awesome "4.3.0-1"]
[jarppe/clj-webjars-tools "1.0.0"]
```Next, create a ring web app like this:
```clj
(ns example.hello-world
(:require [org.httpkit.server :as http-kit]
[compojure.core :refer [defroutes GET]]
[compojure.route :as route]
[clj-webjars-tools.core :refer [webjar-resource]]))(def index-page
"
Hello World
")(defroutes app
(GET "/" [] index-page)
(webjar-resource "font-awesome")
(route/not-found "Page not found
"))(defn start-server []
(http-kit/run-server #'app {:port 8080}))
```You propably wan't to limit the path to static resources by some prefix. So let's add ```/static```
to path:```clj
(def index-page
"
Hello World
")
``````clj
(webjar-resource "font-awesome" {:uri-root "/static"})
```You can also limit the WebJar content to some sub-path with ```:jar-root``` key.
## License
Copyright © 2015 Jarppe Länsiö
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.