Skip to content

Small web app - written in clojure - functional programming practice

License

Notifications You must be signed in to change notification settings

Aracki/ssa-clojure

Repository files navigation

Clojure customers and employees web app with Bootstrap

Simple clojure web application for handling data from database. This web app is using basic CRUD operations (Create, Read, Update, Delete). It uses standard mysql jdbc connector for communicating with database which is hosted on localhost.

On the front-end, web app uses Bootstrap 3.3.5. and JQuery 3 libraries. All public html files are .mustache extension, because the easy way of binding data between controller.clj and html pages providing simple Logic-less template.

Sending data from server for mustache template with Clostache library:

(defn employees []
  (render-template "employees" {:employees (employees-model/allEmployees)
                                :offices (employees-model/allOffices)
                                }))

In this way you can use this variables in html pages with scriplets code : {{employees}} and {{offices}} and access to theirs attributes :

{{#employees}}
<tr class="success">
    <th>{{employeenumber}}</th>
    <th>{{firstname}} {{lastname}}</th>
    <th>{{email}}</th>
    <th>{{officecode}}</th>
    <td><a href="/model/employees/{{employeenumber}}/update" class="btn btn-info">Edit</a></td>
    <td><a href="/model/employees/{{employeenumber}}/remove" class="btn btn-danger">Remove</a></td>
</tr>
{{/employees}}

The app uses Ring and Compojure library for abstracting HTTP requests and response into a simple API to manipulate with GET, POST, PUT requests.

(POST "/model/employees/insert" [& params]
  (do (employee-model/insertE params)
    (resp/redirect "/employees")))
(POST "/model/employees/:employeeNumber/update" [& params]
(do (employee-model/update (:employeeNumber params) params)
(resp/redirect "/employees")))

Customers table : Alt text

Employees table : Alt text

Edit employee example : Alt text

Insert employee example : Alt text

A Clojure project @FON 2015

Usage

Use file classicmodels.sql in root folder and import it in mysql database.

Start web application using 'lein ring server' command.

License

Copyright © 2015 FIXME

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Small web app - written in clojure - functional programming practice

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published