|
| 1 | +# Gitmint |
| 2 | + |
| 3 | + |
| 4 | +A mint on Gitment, the gitment is a comment system based on GitHub Issues. |
| 5 | + |
| 6 | +[Demo Page](https://imsun.github.io/gitment/) |
| 7 | + |
| 8 | +[中文简介](https://imsun.net/posts/gitment-introduction/) |
| 9 | + |
| 10 | +[新增特性](https://aimingoo.github.io/1-1725.html) |
| 11 | + |
| 12 | +- [Features](#features) |
| 13 | +- [Get started](#get-started) |
| 14 | +- [New Features](#new-features) |
| 15 | +- [Methods and Customize](#methods-and-customize) |
| 16 | +- [About Security](#about-security) |
| 17 | +- [History](#history) |
| 18 | + |
| 19 | +## Features |
| 20 | + |
| 21 | +- [Gitment based](https://github.com/imsun/gitment) |
| 22 | +- No server-side implementation |
| 23 | + - to choose both https://gh-oauth.imsun.net and [gh-oauth-server](https://github.com/imsun/gh-oauth-server), or |
| 24 | + - php oauth proxy [intersect](https://github.com/aimingoo/intersect), or |
| 25 | + - other api proxy/gateway |
| 26 | +- Force redirect protocol to support HTTPS/HTTP Github pages site, |
| 27 | +- Support urlencoded for GET request and response data |
| 28 | +- Language translator for default/other theme, a simple method |
| 29 | +- No client_secret |
| 30 | + |
| 31 | +## Get Started |
| 32 | + |
| 33 | +### 1. Install |
| 34 | + |
| 35 | +```html |
| 36 | +<link rel="stylesheet" href="https://aimingoo.github.io/gitmint/style/default.css"> |
| 37 | +``` |
| 38 | + |
| 39 | +```html |
| 40 | +<script src="https://aimingoo.github.io/gitmint/dist/gitmint.browser.js"></script> |
| 41 | +``` |
| 42 | + |
| 43 | +or via npm and build it: |
| 44 | + |
| 45 | +```sh |
| 46 | +> git clone https://github.com/aimingoo/gitmint |
| 47 | +> cd gitmint |
| 48 | +> npm install && npm run build |
| 49 | + |
| 50 | +# dist files |
| 51 | +> ls style/default.css |
| 52 | +> ls dist/gitmint.browser.js |
| 53 | +``` |
| 54 | + |
| 55 | +or via npm module only: |
| 56 | + |
| 57 | +```sh |
| 58 | +> npm install --save gitmint |
| 59 | +## and in js: |
| 60 | +## import Gitmint from 'gitmint' |
| 61 | +``` |
| 62 | + |
| 63 | +### 2. Register An OAuth Application |
| 64 | + |
| 65 | +[Click here](https://github.com/settings/applications/new) to register an OAuth application, and you will get a client ID and a client secret. |
| 66 | + |
| 67 | +Make sure the callback URL is right. Generally it's the origin of your site, like `https://YOURNAME.github.io`, or `https://your-site`. |
| 68 | + |
| 69 | +### 3. Create and render a gitment |
| 70 | + |
| 71 | +```javascript |
| 72 | +const gitment = new Gitmint({ |
| 73 | + id: 'Your page ID', // optional |
| 74 | + owner: 'Your GitHub ID', |
| 75 | + repo: 'The repo to store comments', |
| 76 | + oauth: { |
| 77 | + client_id: 'Your client ID', |
| 78 | + client_secret: 'Your client secret', |
| 79 | + // proxy_gateway: 'Your proxy service, either this or client_secret' |
| 80 | + }, |
| 81 | + // ... |
| 82 | + // For more available options, check out the documentation below |
| 83 | +}) |
| 84 | + |
| 85 | +gitment.render('comments') |
| 86 | +// or |
| 87 | +// gitment.render(document.getElementById('comments')) |
| 88 | +// or |
| 89 | +// document.body.appendChild(gitment.render()) |
| 90 | +``` |
| 91 | + |
| 92 | +### 4. Initialize Your Comments |
| 93 | + |
| 94 | +maybe, you need a automation tool. |
| 95 | + |
| 96 | +## New features |
| 97 | + |
| 98 | +### proxy_gateway support |
| 99 | + |
| 100 | +no `client_secret` when create gitment instance, either proxy_gateway or client_secret. ex: |
| 101 | + |
| 102 | +```javascript |
| 103 | +const gitment = new Gitmint({ |
| 104 | + ... |
| 105 | + oauth: { |
| 106 | + client_id: 'Your client ID', |
| 107 | + proxy_gateway: 'https://YOUR_PROXY' |
| 108 | + }, |
| 109 | + ... |
| 110 | +``` |
| 111 | +
|
| 112 | +proxy/gateway is a service, @see [aimingoo/intersect](https://github.com/aimingoo/intersect) |
| 113 | +
|
| 114 | +### Language translator |
| 115 | +
|
| 116 | +translator module is included, use it in your theme. example in src/theme/default.js: |
| 117 | +
|
| 118 | +```javascript |
| 119 | +import { chinese as $ } from '../translator' |
| 120 | +... |
| 121 | + |
| 122 | +// translate 'Comment' from english to chinese |
| 123 | +submitButton.innerText = $('Comment') |
| 124 | +``` |
| 125 | +
|
| 126 | +update the translator.js module to support more text and languages. |
| 127 | +
|
| 128 | +### Force redirect protocol |
| 129 | +
|
| 130 | +update const `force_redirect_protocol` in gitment.js, make sure it same to protocol of the callback URL in Github OAuth application's settings. |
| 131 | +
|
| 132 | +## Methods and Customize |
| 133 | +
|
| 134 | +@see [https://github.com/imsun/gitment#methods](https://github.com/imsun/gitment#methods) |
| 135 | +
|
| 136 | +
|
| 137 | +## About Security |
| 138 | +
|
| 139 | +@see [https://github.com/imsun/gitment#about-security](https://github.com/imsun/gitment#about-security), and [https://github.com/imsun/gitment/pull/25#issuecomment-314352684](https://github.com/imsun/gitment/pull/25#issuecomment-314352684) |
| 140 | +
|
| 141 | +## History |
| 142 | +
|
| 143 | +``` |
| 144 | +2017.07.12 create gitmind, first release. |
| 145 | +2017.05.30 fork and push some commits to Gitment. |
| 146 | +``` |
0 commit comments