Added Grunt to support asset pipelines and pre-processors; added SASS, Twig, and CoffeeScript to create the app

This commit is contained in:
2022-05-21 20:44:38 -04:00
parent 88c00043b7
commit 866754cf3f
15 changed files with 3056 additions and 103 deletions

View File

@ -0,0 +1,3 @@
window.onload = ->
document.getElementById('ldapHost').textContent = localStorage.getItem('ldap_hostname')
return

View File

@ -0,0 +1,23 @@
ldap = require('ldapjs')
loginForm = (event) ->
event.preventDefault()
bindHost = document.forms.loginForm.ldap_host.value
bindDn = document.forms.loginForm.bind_dn.value
bindPw = document.forms.loginForm.bind_pw.value
client = ldap.createClient(url: 'ldap://' + bindHost + '/')
client.bind bindDn, bindPw, (err) ->
if err
document.querySelector('h1').textContent = 'error'
else
document.querySelector('h1').textContent = 'Logged in!'
localStorage.setItem('ldap_hostname', document.forms.loginForm.ldap_host.value)
localStorage.setItem('ldap_bind_dn', document.forms.loginForm.bind_dn.value)
localStorage.setItem('ldap_bind_pw', document.forms.loginForm.bind_pw.value)
window.location.href = 'index.html'
return
return
window.onload = ->
document.getElementById('loginForm').addEventListener 'submit', loginForm
return

10
assets/sass/archon.sass Normal file
View File

@ -0,0 +1,10 @@
body
background: white
a
color: cornflowerblue
input[type=submit],
button
background-color: cornflowerblue
color: white

File diff suppressed because one or more lines are too long

11
assets/twig/index.twig Normal file
View File

@ -0,0 +1,11 @@
{% extends 'layout.twig' %}
{% block scripts %}
<script src="./js/index.js" charset="utf-8"></script>
{% endblock %}
{% block content %}
<h1>Users Page</h1>
<p id="ldapHost"></p>
{% endblock %}

21
assets/twig/layout.twig Normal file
View File

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<link rel="stylesheet" href="./styles/skeleton-2.0.4.min.css">
<link rel="stylesheet" href="./styles/archon.css">
<title>Hello World!</title>
{% block scripts %}{% endblock %}
</head>
<body>
<div class="container">
{% block content %}{% endblock %}
</div>
We are using Node.js <span id="node-version"></span>,
Chromium <span id="chrome-version"></span>,
and Electron <span id="electron-version"></span>.
</body>
</html>

28
assets/twig/login.twig Normal file
View File

@ -0,0 +1,28 @@
{% extends 'layout.twig' %}
{% block scripts %}
<script src="./js/login.js" charset="utf-8"></script>
{% endblock %}
{% block content %}
<h1>Login</h1>
<form id="loginForm">
<label>
LDAP Host:
<input type="text" name="ldap_host" placeholder="Enter LDAP host...">
</label>
<label>
Bind DN:
<input type="text" name="bind_dn" placeholder="Enter bind DN...">
</label>
<label>
Bind Password:
<input type="text" name="bind_pw" placeholder="Enter bind DN...">
</label>
<input type="submit" name="bind_submit" value="Login">
</form>
{% endblock %}