• Stars
    star
    1,031
  • Rank 44,693 (Top 0.9 %)
  • Language
    Clojure
  • License
    Eclipse Public Li...
  • Created over 14 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

clojuredocs.org web app

clojuredocs

The clojuredocs.org webapp

Contributing

The codebase needs a good scrub before groking will not be painful. However, feel free to jump in if you don't mind digging around.

Here's a few ways to contribute:

Let's use GH issues for discussion for now

If you're looking for a project:

  • All the copy could use another set of eyes
  • Content for namespaces (see src/md/namespaces) needs to be added / edited. Example of clojure.core.async
  • Search quick lookup requires a round-trip to the server, which is way too slow. It would be nice to experiment with embedding vars and doing search directly in the js
  • Listing of clojure training / classes / events on home page
  • Stand-alone example page, maybe have the var info (signature, doc string, etc) at the top.
  • Source-linking on libs not included in the standard library e.g. core.async.

Deploy

Production is deployed on an AWS t2.micro instance. There's an nginx process running on the box, balancing to two JVMs managed by Upstart to support zero-downtime deploys.

To regenerate the upstart scripts:

cd $REPO
sudo foreman export -a clojuredocs -e ./.env -u ubuntu -c "web=2" upstart /etc/init/

To start the app processes:

sudo service clojuredocs-web-1 start
sudo service clojuredocs-web-2 start

To redeploy:

# in $REPO
sudo service clojuredocs-web-1 stop
git pull origin master
# This will compile assets & run tests
bin/build
sudo service clojuredocs-web-1 start
# Wait for proc 1 to start serving requests
sudo service clojuredocs-web-2 restart

Reqs

Dev

Run bin/dev, which will start all the things (repl, web process, scss compiler, etc). See Procfile for more info.

Connect to the repl and / or visit http://localhost:5000

You'll notice that var information is already populated. In an effort for not make the same mistakes again, all core-related var info is loaded from the runtime version of Clojure on start up.

OTOH, examples, see-alsos, and notes (and any other user-generated content) are stored in the database.

Local Data

The app uses a MongoDB database named clojuredocs to store data. Run bin/db-reset to seed the database with a recent production export (you must be running mongod for this to work).

Prod Local

Occasionally you'll need to compile and run things as they would be in production (checking advanced cljs compilation, for example): bin/prod-local.

CLJS Source Maps

The ClojureDocs project is set-up to emit source-maps for compiled javascript. To enable in Chrome, check the 'Enable JS source maps' option in the Developer Tools settings pane.

Clojure Version

Clojure vars are pulled directly from the runtime, and are not stored in the database. When new versions of Clojure are released:

  • Change the Clojure dep in project.clj
  • Update the version string, source base url, and gh tag url in clojuredocs.search/clojure-lib
  • Update the version for the mobile nav in clojuredocs.pages.common
  • Update the github URL in clojuredocs.pages.vars/source-url.

App Structure

Interesting files:

  • src/clj/clojuredocs/main.clj -- Main entry-point into the app, starts the jetty server
  • src/clj/clojuredocs/entry.clj -- Root routes and middleware
  • src/clj/clojuredocs/pages.clj -- User-facing HTML pages
  • src/clj/clojuredocs/api.clj -- API endpoints for ajax calls from the frontend.
  • src/cljs/clojuredocs/main.cljs -- Main js entry-point into the app

Conventions

  • Functions that return hiccup structures should be prefixed with a $, like $layout.
  • Mutable state should be prefixed with a !, ex: !my-atom.

Adding Functions, Macros, Special Forms, Namespaces & Other Vars

Most vars are picked up from Clojure at runtime, using core namespace and var introspection utilities. Special forms and namespaces to include on the site are specified explicitly in the clojuredocs.search.static namespace.

Vars are picked up automatically based on the namespaces specified in clojuredocs.search.static/clojure-namespaces vector. Any namespace in this vector will be queried for public vars to be made searchable and displayable on the site.

Special forms are specified in the clojuredocs.search.static/special-forms list, and require a server restart to be picked up in a dev environment.

Adding Core Libraries

Sometimes we'd like to add core libraries that are not part of the standard Clojure distribution (like core.async) to the site. Here's how to do that:

  1. Add dependency to project.clj
  2. Add ns sym to clojure-namespaces in clojuredocs.search.static
  3. Add a short description + links to community articles / videos / other resources to src/md/namespaces/

Dev-Prod differences

  • Dev starts the environment using lein repl :headless, prod uses lein run -m clojuredocs.main. See :repl-options in project.clj for initialization options.

Data Exports

Contributors

Zachary Kim, Lee Hinman, and more.

License

Copyright © 2010-present Zachary Kim

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

More Repositories

1

emacs-dirtree

Directory tree views in Emacs
Emacs Lisp
99
star
2

xmpp-clj

A lightweight clojure wrapper around the smack jabber/XMPP library
Clojure
41
star
3

leiningen-init-script

A leiningen plugin that generates *NIX daemon scripts.
Clojure
24
star
4

cljs

An experimental Clojure(ish) to Javascript compiler.
Clojure
24
star
5

clj-exceptional

Clojure client for Exceptional (http://getexceptional.com/)
Clojure
9
star
6

clojuredocs-analyzer

Clojure
9
star
7

nsfw

nsfw
Clojure
7
star
8

docs.pair.io

Docs for https://pair.io
Clojure
6
star
9

lt-gitstatusbar

Display GIt branch / status in the LightTable status bar
JavaScript
6
star
10

.pair.io

My dotfiles
Emacs Lisp
4
star
11

barista

Programming exercise for the Denver Clojure Users Group.
Clojure
3
star
12

swish-scala

A Scala library for ssh automation.
Scala
3
star
13

inky

Sketch in ClojureScript
JavaScript
3
star
14

cd-wsapi

ClojureDocs External API - See http://github.com/dakrone/cd-wsapi for official repo.
Clojure
3
star
15

lein-cljs

Clojure
3
star
16

lt-syntaxstatusbar

A LightTable plugin to display the current editor's syntax setting in the statubar.
JavaScript
3
star
17

mockdbs

Deep Brain Stimulation Simulator
Java
3
star
18

vim

Napple's Vim setup
2
star
19

optimystic

2
star
20

sicp

Clojure
2
star
21

napplelabs_vim

Napple's Vim setup
2
star
22

cljs-server

A live console site for cljs.
JavaScript
2
star
23

naptime

REST based URL hook scheduler
Clojure
2
star
24

zel-releases

2
star
25

emacsd

Emacs Lisp
2
star
26

zacharykim.com

My personal site.
Clojure
2
star
27

pairio-config-example

Example repo configuration for pair.io
Ruby
2
star
28

mockdbs-scala

Scala port of mockdbs
Scala
1
star
29

mockdbs-clj

Clojure port of MockDBS
Clojure
1
star
30

clojure.pair.io

Generic Clojure instance config
1
star
31

wordspacebook

Clojure
1
star
32

heroku-bench

Clojure
1
star
33

quickjs-cljs

ClojureScript on QuickJS
C
1
star
34

pairio-imaging-example

1
star
35

pairio-quickstart-base

Base quickstart image config.
Shell
1
star
36

jdk1.6.0_18-rpm

1
star
37

cljs-examples

JavaScript
1
star
38

sbtgrowl

SBT growl plugin
Scala
1
star
39

init-script-test

An example project that uses the leiningen-init-script plugin
Clojure
1
star
40

cljs-contrib

JavaScript
1
star
41

pairio-scala

1
star
42

habitat

Environment-based configuration for Clojure projects.
Clojure
1
star