Skip to content

Forked from yogthos/memory-hole to act as a web application template.

Notifications You must be signed in to change notification settings

hughjfchen/memory-hole

 
 

Repository files navigation

Memory Hole

When one knew that any document was due for destruction, or even when one saw a scrap of waste paper lying about, it was an automatic action to lift the flap of the nearest memory hole and drop it in, whereupon it would be whirled away on a current of warm air to the enormous furnaces which were hidden somewhere in the recesses of the building


Memory Hole is a support issue organizer. It's designed to provide a way to organize and search common support issues and their resolution.

1.0 Features

  • The app uses LDAP and/or internal table to handle authentication
  • Issues are ranked based on the number of views and last time of access
  • File attachments for issues
  • Issues are organized by user generated tags
  • Markdown with live preview for issues
  • Weighted full text search using PostgreSQL citext extension

Prerequisites

You will need the following to compile and run the application:

Running with Docker

mkdir memory-hole
cd memory-hole
curl -O https://raw.githubusercontent.com/yogthos/memory-hole/master/docker-compose.yml
docker-compose up

The app will be available at http://localhost:8000 once it starts.

Running during development

Create a profiles.clj file in the project directory with the configuration settings for the database and optionally LDAP, e.g:

{:profiles/dev
 {:env
  {:database-url "jdbc:postgresql://localhost/postgres?user=memoryhole&password=memoryhole"
  ;;optional, will use internal table otherwise
  :ldap
  {:host
     {:address         "my-ldap-server.ca"
      :domain          "domain.ca"
      :port            389
      :connect-timeout (* 1000 5)
      :timeout         (* 1000 30)}}}}}

Run the migrations

lein run migrate

This will create the tables and add a default admin user, The default login is: admin/admin.

To start a web server for the application, run:

lein run

To compile ClojureScript front-end, run:

lein figwheel

Building for production

lein uberjar

This will produce target/uberjar/memory-hole.jar archive that can be run as follows:

java -Dconf=conf.edn -jar memory-hole.jar migrate
java -Dconf=conf.edn -jar memory-hole.jar

The conf.edn file should contain the configuration such as the database URL that will be used in production. The following options are available.

Database URL

:database-url "jdbc:postgresql://localhost/postgres?user=memoryhole&password=memoryhole"

HTTP Port

The HTTP port defaults to 3000, to set a custom port add the following key to the config:

:port 80

Session Configuration

The app defaults to using a server-side memory based session store.

The number of sessions before a memory session times out can be set using the :memory-session key as follows:

:memory-session
{:max-age 3600}

If you wish to use a cookie based memory store, then add a :cookie-session key to the configuration. The :cookie-session key should point to a map containing two optional key:

  • :key - a secret key used to encrypt the session cookie
  • :cookie-attrs - a map containing optional cookie attributes:
  • :http-only - restrict the cookie to HTTP if true (default)
  • :secure - restrict the cookie to HTTPS URLs if true
  • :max-age - the number of seconds until the cookie expires

An example configuration might look as follows:

:cookie-session
{:key "a 16-byte secret"
 :cookie-attrs
 {:secure  true
  :max-age 3600}}

HTTPS Support

To enable HTTPS support in production add the the following configuration under the :ssl key:

:ssl
{:port 3001
 :keystore "keystore.jks"
 :keystore-pass "changeit"}

To disable HTTP access, set the :port to nil:

:port nil

Alternatively, you can front the app with Nginx in production. See here for details on configuring Nginx.

A complete conf.edn example:

{:database-url "jdbc:postgresql://localhost/postgres?user=memoryhole&password=memoryhole"
 :cookie-session
 {:key "a 16-byte secret"
  :cookie-attrs
  {:max-age 60}}
 :port nil
 :ssl
 {:port 3001
  :keystore "keystore.jks"
  :keystore-pass "changeit"}}

Nginx Proxy

The app can be proxied with Nginx to a custom path as follows:

server {
    listen ...;
    ...
    location /memory-hole {
        proxy_pass http://127.0.0.1:3000;
    }
    ...
}

You will then need to add the :app-context in the conf.edn file with the context:

{:database-url "jdbc:postgresql://localhost/postgres?user=memoryhole&password=memoryhole"
 :port 3000
 :app-context "/memory-hole"}

Configuring PostgreSQL

Follow these steps to configure the database for the application:

  1. Make sure you have the CITEXT extension installed on PostgreSQL.

  2. Run the psql command:

     psql -U <superuser|postgres user> -d postgres -h localhost
    
  3. Create the role role for accessing the database:

     CREATE ROLE memoryhole;
    
  4. Set the password for the role:

     \password memoryhole;
    
  5. Optionally, create a schema and grant the memoryhole role authorization:

     CREATE SCHEMA memoryhole AUTHORIZATION memoryhole;
     GRANT ALL ON SCHEMA memoryhole TO memoryhole;
     GRANT ALL ON ALL TABLES IN SCHEMA memoryhole TO memoryhole;
    
  6. Add the CITEXT extension to the schema:

     CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA memoryhole;
    
  7. Exit the shell

     \q
    

Acknowledgments

The original implementation of the tool was written by Ryan Baldwin. The app is based on the original schema and SQL queries.

License

Copyright © 2016 Dmitri Sotnikov

About

Forked from yogthos/memory-hole to act as a web application template.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure 89.7%
  • CSS 5.8%
  • HTML 2.6%
  • PLpgSQL 1.9%