Skip to content
forked from hackmdio/codimd

CodiMD - Realtime collaborative markdown notes on all platforms.

License

Notifications You must be signed in to change notification settings

xiaoming96/codimd

 
 

Repository files navigation

CodiMD

Standard - JavaScript Style Guide

Join the chat at https://gitter.im/hackmdio/hackmd #CodiMD on matrix.org build status version Help Contribute to Open Source POEditor

CodiMD lets you create real-time collaborative markdown notes on all platforms. Inspired by Hackpad, with more focus on speed and flexibility, and build from HackMD source code. Feel free to contribute.

Thanks for using! 😄

Table of Contents

HackMD CE became CodiMD

CodiMD was recently renamed from its former name was HackMD. CodiMD is the free software version of HackMD. It was the original Version of HackMD. The HackMD team initiated CodiMD and provided a solid code base. Due to the need of paying bills, A fork was created and called HackMD EE, which is a SaaS (Software as a Service) product available at hackmd.io.

We decided to change the name to break the confusion between HackMD and CodiMD, formally known as HackMD CE, as it never was an open core project.

Just to more confusion: We are still friends with HackMD ❤️

For the whole renaming story, see the related issue

Browsers Requirement

  • Chrome Chrome >= 47, Chrome for Android >= 47
  • Safari Safari >= 9, iOS Safari >= 8.4
  • Firefox Firefox >= 44
  • IE IE >= 9, Edge >= 12
  • Opera Opera >= 34, Opera Mini not supported
  • Android Browser >= 4.4

Installation

Getting started (Native install)

Prerequisite

  • Node.js 6.x or up (test up to 7.5.0)
  • Database (PostgreSQL, MySQL, MariaDB, SQLite, MSSQL) use charset utf8
  • npm (and its dependencies, especially uWebSockets, node-gyp)
  • For building CodiMD we recommend to use a machine with at least 2GB RAM

Instructions

  1. Download a release and unzip or clone into a directory
  2. Enter the directory and type bin/setup, which will install npm dependencies and create configs. The setup script is written in Bash, you would need bash as a prerequisite.
  3. Setup the configs, see more below
  4. Setup environment variables which will overwrite the configs
  5. Build front-end bundle by npm run build (use npm run dev if you are in development)
  6. Modify the file named .sequelizerc, change the value of the variable url with your db connection string For example: postgres:https://username:password@localhost:5432/codimd
  7. Run node_modules/.bin/sequelize db:migrate, this step will migrate your db to the latest schema
  8. Run the server as you like (node, forever, pm2)

Heroku Deployment

You can quickly setup a sample Heroku CodiMD application by clicking the button below.

Deploy on Heroku

If you deploy it without the button, keep in mind to use the right buildpacks. For details check app.json.

Kubernetes

To install use helm install stable/hackmd.

For all further details, please check out the offical CodiMD K8s helm chart.

CodiMD by docker container

Try in PWD

Debian-based version:

latest

Alpine-based version:

alpine

The easiest way to setup CodiMD using docker are using the following three commands:

git clone https://github.com/hackmdio/docker-hackmd.git
cd docker-codimd
docker-compose up

Read more about it in the docker repository…

Upgrade

Native setup

If you are upgrading CodiMD from an older version, follow these steps:

  1. Fully stop your old server first (important)
  2. git pull or do whatever that updates the files
  3. npm install to update dependencies
  4. Build front-end bundle by npm run build (use npm run dev if you are in development)
  5. Modify the file named .sequelizerc, change the value of the variable url with your db connection string For example: postgres:https://username:password@localhost:5432/codimd
  6. Run node_modules/.bin/sequelize db:migrate, this step will migrate your db to the latest schema
  7. Start your whole new server!
  • migrate-to-1.1.0

We deprecated the older lower case config style and moved on to camel case style. Please have a look at the current config.json.example and check the warnings on startup.

Notice: This is not a breaking change right now but in the future

We don't use LZString to compress socket.io data and DB data after version 0.5.0. Please run the migration tool if you're upgrading from the old version.

We've dropped MongoDB after version 0.4.0. So here is the migration tool for you to transfer the old DB data to the new DB. This tool is also used for official service.

Configuration

There are some config settings you need to change in the files below.

./config.json      ----application settings

Environment variables (will overwrite other server configs)

variables example values description
NODE_ENV production or development set current environment (will apply corresponding settings in the config.json)
DEBUG true or false set debug mode; show more logs
CMD_DOMAIN codimd.org domain name
CMD_URL_PATH codimd sub URL path, like www.example.com/<URL_PATH>
CMD_PORT 80 web app port
CMD_ALLOW_ORIGIN localhost, codimd.org domain name whitelist (use comma to separate)
CMD_PROTOCOL_USESSL true or false set to use SSL protocol for resources path (only applied when domain is set)
CMD_URL_ADDPORT true or false set to add port on callback URL (ports 80 or 443 won't be applied) (only applied when domain is set)
CMD_USECDN true or false set to use CDN resources or not (default is true)
CMD_ALLOW_ANONYMOUS true or false set to allow anonymous usage (default is true)
CMD_ALLOW_ANONYMOUS_EDITS true or false if allowAnonymous is true, allow users to select freely permission, allowing guests to edit existing notes (default is false)
CMD_ALLOW_FREEURL true or false set to allow new note creation by accessing a nonexistent note URL
CMD_DEFAULT_PERMISSION freely, editable, limited, locked or private set notes default permission (only applied on signed users)
CMD_DB_URL mysql:https://localhost:3306/database set the database URL
CMD_SESSION_SECRET no example Secret used to sign the session cookie. If non is set, one will randomly generated on startup
CMD_SESSION_LIFE 1209600000 Session life time. (milliseconds)
CMD_FACEBOOK_CLIENTID no example Facebook API client id
CMD_FACEBOOK_CLIENTSECRET no example Facebook API client secret
CMD_TWITTER_CONSUMERKEY no example Twitter API consumer key
CMD_TWITTER_CONSUMERSECRET no example Twitter API consumer secret
CMD_GITHUB_CLIENTID no example GitHub API client id
CMD_GITHUB_CLIENTSECRET no example GitHub API client secret
CMD_GITLAB_SCOPE read_user or api GitLab API requested scope (default is api) (GitLab snippet import/export need api scope)
CMD_GITLAB_BASEURL no example GitLab authentication endpoint, set to use other endpoint than GitLab.com (optional)
CMD_GITLAB_CLIENTID no example GitLab API client id
CMD_GITLAB_CLIENTSECRET no example GitLab API client secret
CMD_MATTERMOST_BASEURL no example Mattermost authentication endpoint
CMD_MATTERMOST_CLIENTID no example Mattermost API client id
CMD_MATTERMOST_CLIENTSECRET no example Mattermost API client secret
CMD_DROPBOX_CLIENTID no example Dropbox API client id
CMD_DROPBOX_CLIENTSECRET no example Dropbox API client secret
CMD_GOOGLE_CLIENTID no example Google API client id
CMD_GOOGLE_CLIENTSECRET no example Google API client secret
CMD_LDAP_URL ldap:https://example.com URL of LDAP server
CMD_LDAP_BINDDN no example bindDn for LDAP access
CMD_LDAP_BINDCREDENTIALS no example bindCredentials for LDAP access
CMD_LDAP_SEARCHBASE o=users,dc=example,dc=com LDAP directory to begin search from
CMD_LDAP_SEARCHFILTER (uid={{username}}) LDAP filter to search with
CMD_LDAP_SEARCHATTRIBUTES displayName, mail LDAP attributes to search with (use comma to separate)
CMD_LDAP_USERIDFIELD uidNumber or uid or sAMAccountName The LDAP field which is used uniquely identify a user on CodiMD
CMD_LDAP_USERNAMEFIELD Fallback to userid The LDAP field which is used as the username on CodiMD
CMD_LDAP_TLS_CA server-cert.pem, root.pem Root CA for LDAP TLS in PEM format (use comma to separate)
CMD_LDAP_PROVIDERNAME My institution Optional name to be displayed at login form indicating the LDAP provider
CMD_SAML_IDPSSOURL https://idp.example.com/sso authentication endpoint of IdP. for details, see guide.
CMD_SAML_IDPCERT /path/to/cert.pem certificate file path of IdP in PEM format
CMD_SAML_ISSUER no example identity of the service provider (optional, default: serverurl)"
CMD_SAML_IDENTIFIERFORMAT no example name identifier format (optional, default: urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress)
CMD_SAML_GROUPATTRIBUTE memberOf attribute name for group list (optional)
CMD_SAML_REQUIREDGROUPS Hackmd-users group names that allowed (use vertical bar to separate) (optional)
CMD_SAML_EXTERNALGROUPS Temporary-staff group names that not allowed (use vertical bar to separate) (optional)
CMD_SAML_ATTRIBUTE_ID sAMAccountName attribute map for id (optional, default: NameID of SAML response)
CMD_SAML_ATTRIBUTE_USERNAME mailNickname attribute map for username (optional, default: NameID of SAML response)
CMD_SAML_ATTRIBUTE_EMAIL mail attribute map for email (optional, default: NameID of SAML response if CMD_SAML_IDENTIFIERFORMAT is default)
CMD_IMGUR_CLIENTID no example Imgur API client id
CMD_EMAIL true or false set to allow email signin
CMD_ALLOW_PDF_EXPORT true or false Enable or disable PDF exports
CMD_ALLOW_EMAIL_REGISTER true or false set to allow email register (only applied when email is set, default is true. Note bin/manage_users might help you if registration is false.)
CMD_ALLOW_GRAVATAR true or false set to false to disable gravatar as profile picture source on your instance
CMD_IMAGE_UPLOAD_TYPE imgur, s3, minio or filesystem Where to upload images. For S3, see our Image Upload Guides for S3 or Minio
CMD_S3_ACCESS_KEY_ID no example AWS access key id
CMD_S3_SECRET_ACCESS_KEY no example AWS secret key
CMD_S3_REGION ap-northeast-1 AWS S3 region
CMD_S3_BUCKET no example AWS S3 bucket name
CMD_MINIO_ACCESS_KEY no example Minio access key
CMD_MINIO_SECRET_KEY no example Minio secret key
CMD_MINIO_EN