1
1
mirror of https://github.com/aelve/guide.git synced 2024-11-22 03:12:58 +03:00
A workspace for research teams
Go to file
2017-10-07 15:02:10 +03:00
favicon Fix pragma style 2017-07-23 02:54:35 +03:00
guidejs Add missing rollup dependency 2017-03-31 11:15:11 +02:00
scripts Add npm install to buildjs.sh, describe changing in README 2017-03-18 15:39:51 -05:00
src [#169][WIP] Fix code after review 2017-10-07 15:02:10 +03:00
static Remove bundle.js from index 2017-07-03 10:08:27 -05:00
templates Remove the subtitle 2017-07-30 03:49:45 +03:00
tests Remove the subtitle 2017-07-30 03:49:45 +03:00
.ghci Add a .ghci file 2016-07-30 01:11:56 +03:00
.gitignore [#124] Replace tuples with data types in admin/links 2017-08-20 21:32:51 +03:00
.gitlab-ci.yml Force GHC to install on every build if necessary. 2017-08-17 13:28:47 -05:00
.hlint.yaml Add a HLint settings file 2017-08-17 22:39:31 +03:00
.travis.yml [travis] Build the JS part 2017-08-13 19:40:43 +03:00
b Add --nix option to run build script 2017-06-29 20:17:36 +02:00
CHANGELOG.md Create the project 2016-02-02 12:36:07 +03:00
guide.cabal Merge pull request #192 from aelve/public-db 2017-08-29 01:16:40 +03:00
INSTALL.md [INSTALL] Update for Stack 2016-08-25 17:05:29 +03:00
LICENSE Create the project 2016-02-02 12:36:07 +03:00
official.sh Add a script for downloading the database 2017-06-09 13:57:05 +02:00
README.md Merge branch 'master' into sessions 2017-05-23 21:30:53 +03:00
Setup.hs Add no-js option for building 2017-08-19 18:13:24 +03:00
stack.yaml Use fmt-0.4.0 with renewed operators +| |+ 2017-08-12 12:56:41 +03:00
zurihac.md Fix 2017-06-09 14:02:46 +02:00

Aelve Guide

Build status BSD3 license

The beta version is running at guide.aelve.com. The most complete section yet is the one about lenses.

Installation instructions and the explanation of config variables (in config.json) are here: INSTALL.md. Don't be afraid to install it locally it's very easy! You don't need to set up any databases or anything like that, and you can get a full copy of the data from the site by simply cloning it from Github.

Contributing

If you want to contribute but don't know where to start, grep the source for [very-easy] and [easy], or look at these issues:

  • “your first pull request” really easy things, with detailed “how to fix it” instructions
  • “your second pull request” less easy things, which assume that you already know where stuff happens in the code
  • “not-fleshed-out idea” discussion issues (“should we have users? what better ways are there to present pros and cons?”) which you can help with even if you don't know Haskell
  • “design” issues about design (which I'm not good at, and so help is wanted)

Overview of the code

Folder structure

  • lib actual code (as a library)
  • src just a dumb Main.hs file to compile an executable
  • tests tests
  • static icons, CSS, Markdown pages, HTML pages, and some JS libraries
  • templates HTML templates for pages and elements of pages
  • scripts some scripts used by automatic testing
  • favicon code used to generate a favicon
  • guidejs client side JavaScript

Notes

When you see something like

-- See Note [acid-state]

it means that there's an extensive comment somewhere else in the code, which you can find by grepping for Note [acid-state]. This convention was stolen from GHC. If you know some plugin for Emacs that would help with jumping to comments (even if those comments would have to be formatted differently), let me know.

Main modules

THIS SECTION IS OUTDATED

There are 4 main modules Guide.hs, JS.hs, View.hs, and Types.hs.

Guide.hs contains:

  • handlers for GET/POST requests (renderMethods, setMethods, etc)
  • feed generation (itemToFeedEntry)
  • some utility functions (undoEdit, lucidWithConfig, createCheckpoint')
  • the main function, which starts the server

JS.hs contains all Javascript that is used in pages. The way it works is tricky: each Javascript function is overloaded in such a way that it can generate either a function call or a function definition. allJSFunctions, exported by JS.hs, is made by producing definitions from all functions in the module and then concatenating them; later allJSFunction is served by the server as /js.js. When you see something like JS.foo (a, b, c) in Haskell code, a call to foo is being generated (and foo can be found in JS.hs).

View.hs contains HTML rendering code. (It's much uglier than using templates, and we should switch to templates one day. Actually, maybe we should even switch to Node.js or Elm from Haskell.)

Types.hs contains almost all types used in code elsewhere Item, Category, and so on. GlobalState is a type for, well, the whole database used by the site. All content, all edits, and all analytics data (i.e. users' IPs, etc) are stored there. The data is held in memory, and acid-state makes sure that data on hard drive is kept in sync with it. For a more detailed explanation, see Note [acid-state].

Currently changing database schema is somewhat painful; to see how exactly painful it is, look at Note [extending types]. Not painful enough to never touch it again, sure, but still kinda annoying. Making it easier is possible, but for that we'd need a different acid-state or a real database.

Other modules

Markdown.hs contains functions for rendering Markdown. There are special types for Markdown as well, coupling rendered Markdown, its text representation, and its parse tree.

Merge.hs contains an algorithm for merging edits if you are editing a description of an item and someone else is editing the same description, upon submitting your edit you'll get a popup showing both versions and a merged version.

Cache.hs provides some helpers for caching pages. (A cache is a global variable holding a map from cache keys to rendered HTML.)

Config.hs has a config type and functions for reading/writing said config.

Utils.hs is just that utility functions.