forked from gshstexsociety/gshstexsociety.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cms.html
192 lines (178 loc) · 7.79 KB
/
cms.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
---
---
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" type="text/css"/>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap-theme.min.css" />
<title>협회 게시판 글 작성</title>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container" id="container1" >
<h5>경기과학고 텍 사용자협회 소식 게시판에 글 작성하기 / <a href="http://blog.kalkin7.com/2014/02/05/wordpress-markdown-quick-reference-for-koreans/">마크다운 문법 도움말</a></h5>
{% if site.github.repo == none %}
<div class="alert alert-danger" role="alert"><code>github.repo</code> is not set. Check <a href="https://github.com/vrypan/jekyll-post-via-web"
>github.com/vrypan/jekyll-post-via-web</a> for instructions.</div>
{% endif %}
{% if site.github.branch == none %}
<div class="alert alert-danger" role="alert"><code>github.branch</code> is not set. Check <a href="https://github.com/vrypan/jekyll-post-via-web"
>github.com/vrypan/jekyll-post-via-web</a> for instructions.</div>
{% endif %}
<div id="messages"></div>
<form id="theform" method="get">
<div class="form-group">
<input type="text" class="form-control" placeholder="글 제목(간결히)" id="p_title" name="title">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="글 제목(자세히)" id="p_title_detail" name="title_detail">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="저자(예 : 37기 홍길동 / 수학 교직원 홍판서)" id="p_author" name="author">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="간단한 설명(웹사이트에는 드러나지 않음, 생략 가능)" id="p_description" name="description">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="관련 양식명(예 : gshs_thesis / 생략 가능)" id="p_meta" name="meta">
</div>
<div class="form-group">
<textarea class="form-control" rows="3" id="p_excerpt" placeholder="표제" name="excerpt"></textarea>
</div>
<div class="form-group">
<textarea class="form-control" rows="8" id="p_body" placeholder="글 내용 작성. 마크다운, HTML 문법 사용 가능." name="body"></textarea>
</div>
<div class="form-inline">
<div class="form-group">
<label for="username" class="sr-only">Username</label>
<input type="text" class="form-control" id="username" placeholder="GitHub username">
</div>
<div class="form-group">
<label for="password" class="sr-only">password</label>
<input type="password" class="form-control" id="password" placeholder="GitHub token">
</div>
<input type="button" class="btn btn-default" id="go" value="등록" />
<br>
<h5>글을 작성하려면 경기과학고 텍 사용자협회의 <a href="https://github.com/gshslatexintro">GitHub</a>에 가입되어 있어야 합니다.</h5>
<h5><a href="https://github.com/settings/tokens">Github Token</a>에서 토큰을 생성해야 합니다.</h5>
<h5>등록한 글은 <b>즉시</b> <a href="https://github.com/gshslatexintro/latex.gs.hs.kr">웹사이트의 GitHub 저장소</a>에 추가되며, 수정을 원할 경우 <a href="https://github.com/gshslatexintro/latex.gs.hs.kr">웹사이트의 GitHub 저장소</a>에서 해 주십시오.</h5>
<h5>웹사이트의 GitHub 저장소에 추가된 글은 <b>매 분 웹사이트에 갱신</b>됩니다. 게시 후 잠시 기다려 주세요.</h5>
<h5>ⓒ 2016 <a href="https://www.vrypan.net/">Panayotis Vryonis</a> under Apache-2.0 License</h5>
</div>
</form>
</div>
<script>
function get_query(){
// Source: http://fellowtuts.com/jquery/getting-query-string-values-in-javascript/
var url = document.location.href;
if (url.indexOf('?') == -1) return false ;
var qs = url.substring(url.indexOf('?') + 1).split('&');
for(var i = 0, result = {}; i < qs.length; i++){
qs[i] = qs[i].split('=');
result[qs[i][0]] = decodeURIComponent(qs[i][1].replace(/\+/g, '%20'));
}
return result;
}
function getSelectionText() {
return text;
}
function post_file(title) {
var d = new Date()
var dd = d.getDate()
if (dd < 10) dd = '0' + dd ;
var mm = d.getMonth()+1 ;
if (mm < 10) mm = '0' + mm ;
var yyyy = d.getFullYear() ;
filename = yyyy + '-' + mm + '-' + dd ;
if (!title) {
filename = filename + '-' + +d.getTime() ;
} else {
var slugified = title.toLowerCase().replace(/\W+/g, '-') ;
if (slugified != '-') {
filename = filename + '-' + slugified ;
} else {
filename = filename + '-' + d.getTime();
}
}
return filename
}
function post_date() {
var d = new Date()
return d.toISOString()
}
var API_NEW_POST = 'https://api.github.com/repos/{{ site.github.repo }}/contents/_posts/' ;
$("#go").click(function() {
var user = $('#username').val();
var password = $('#password').val();
var title = $('#p_title').val();
var title_detail = $('#p_title_detail').val();
var author = $('#p_author').val();
var description = $('#p_description').val();
var excerpt = $('#p_excerpt').val();
var meta = $('#p_meta').val();
var body = $('#p_body').val();
var p_body = '---\n' ;
p_body = p_body + 'layout: post \n' ;
p_body = p_body + 'title: "' + title +'" \n';
p_body = p_body + 'date: '+ post_date() +' \n' ;
p_body = p_body + 'author: "' + author +'" \n';
p_body = p_body + 'description: "' + description +'" \n';
p_body = p_body + 'excerpt: "' + excerpt +'" \n';
p_body = p_body + 'categories: 소식 \n';
if(meta.length > 0){
p_body = p_body + 'meta: "' + meta +'" \n';
}
p_body = p_body + '---\n\n';
p_body = p_body + '# ' + title_detail;
p_body = p_body + '\n\n' + body;
var posted_ok = false;
$.ajax({
dataType: "json",
contentType: 'application/json; charset=UTF-8',
url: API_NEW_POST+post_file(title)+'.md',
type: "PUT",
data: JSON.stringify({
content: btoa(unescape(encodeURIComponent(p_body))),
message: 'posted via web',
branch: '{{ site.github.branch }}'
}),
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa(user+":"+password));
},
success: function(data) {
posted_ok = true ;
$('#container1').html('<h2>Successfully posted to {{ site.title }}</h2') ;
},
error: function(request, status, error) {
responseText = jQuery.parseJSON( request.responseText );
$('#messages').append($('<div class="alert alert-danger alert-dismissible" role="alert">')
.append('<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>')
.append('<strong>' + request.status + '</strong>: ' + responseText.message )
.append('<br>If you are using two-factor authentication, you will have to create ')
.append('<a href="https://github.com/settings/tokens">a personal access token</a> with "repo" permissions and use this instead of your password.')
.append('</div>'));
},
});
});
query_params = get_query();
if (query_params) {
src_body = '';
if (query_params['title']) {
src_title = query_params['title'] ;
$('#p_title').val(src_title) ;
}
if (query_params['selection']) {
src_body = '> ' + query_params['selection'] ;
}
if (query_params['body']) {
src_body = query_params['body'] ;
}
if (query_params['url']) {
src_body = src_body + ' —['+src_title+'](' + query_params['url'] + ')\n' ;
}
$('#p_body').val(src_body) ;
}
</script>
</body>