Skip to content

Commit 09593cb

Browse files
author
aimingoo
committed
Initial release
0 parents  commit 09593cb

19 files changed

+2325
-0
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.DS_Store
2+
.idea
3+
4+
node_modules
5+
6+
dist
7+
test/config.js
8+
index.html

.npmignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.DS_Store
2+
.idea
3+
.gitignore
4+
.npmignore
5+
.babelrc
6+
7+
node_modules
8+
9+
src
10+
test
11+
index.html
12+
webpack.config.js
13+
webpack.dev.config.js

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 imsun
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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+
```

package.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "gitmint",
3+
"version": "0.0.3",
4+
"description": "A mint on Gitment",
5+
"main": "./dist/gitment.js",
6+
"author": {
7+
"name": "Shiquan Sun",
8+
"url": "https://github.com/imsun"
9+
},
10+
"contributors": [{
11+
"name": "Shiquan Sun",
12+
"url": "https://github.com/imsun"
13+
},{
14+
"name": "aimingoo",
15+
"email": "[email protected]",
16+
"url": "https://github.com/aimingoo"
17+
}],
18+
"keywords": [
19+
"Gitment",
20+
"comment system",
21+
"GitHub Issues"
22+
],
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/aimingoo/gitmint"
26+
},
27+
"bugs": {
28+
"url": "https://github.com/aimingoo/gitmint/issues"
29+
},
30+
"homepage": "https://github.com/aimingoo/gitmint",
31+
"scripts": {
32+
"build": "babel src --out-dir dist --ignore test.js --source-maps & NODE_ENV=production webpack --config webpack.config.js --progress --profile --colors",
33+
"dev": "webpack-dev-server --config webpack.dev.config.js --host 0.0.0.0 --progress --profile --colors"
34+
},
35+
"devDependencies": {
36+
"babel-cli": "^6.24.0",
37+
"babel-core": "^6.24.0",
38+
"babel-loader": "^6.4.1",
39+
"babel-preset-es2015": "^6.24.0",
40+
"webpack": "^2.3.2",
41+
"webpack-dev-server": "^2.4.2"
42+
},
43+
"dependencies": {
44+
"mobx": "^3.2.1"
45+
},
46+
"license": "MIT"
47+
}

src/constants.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const LS_ACCESS_TOKEN_KEY = 'gitment-comments-token'
2+
export const LS_USER_KEY = 'gitment-user-info'
3+
4+
export const NOT_INITIALIZED_ERROR = new Error('Comments Not Initialized')

0 commit comments

Comments
 (0)