This commit is contained in:
Liang Ding 2019-05-17 12:17:58 +08:00
parent 4b6f6af949
commit ad6df5b1b4
No known key found for this signature in database
GPG Key ID: 136F30F901A2231D
10 changed files with 3 additions and 92 deletions

View File

@ -1,57 +0,0 @@
// Copyright (c) 2014-present, b3log.org
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package file
import (
"encoding/json"
"net/http"
"path/filepath"
"github.com/b3log/wide/util"
)
// DecompressHandler handles request of decompressing zip/tar.gz.
func DecompressHandler(w http.ResponseWriter, r *http.Request) {
result := util.NewResult()
defer util.RetResult(w, r, result)
var args map[string]interface{}
if err := json.NewDecoder(r.Body).Decode(&args); err != nil {
logger.Error(err)
result.Succ = false
return
}
path := args["path"].(string)
// base := filepath.Base(path)
dir := filepath.Dir(path)
if !util.File.IsExist(path) {
result.Succ = false
result.Msg = "Can't find file [" + path + "] to descompress"
return
}
err := util.Zip.Unzip(path, dir)
if nil != err {
logger.Error(err)
result.Succ = false
return
}
}

View File

@ -118,7 +118,6 @@
"team": "Team", "team": "Team",
"sing_up_error": "Sign Up Error", "sing_up_error": "Sign Up Error",
"user_name_ruler": "Username only by az, AZ, 0-9, _ consisting of a length of 16", "user_name_ruler": "Username only by az, AZ, 0-9, _ consisting of a length of 16",
"invalid_email": "Invalid Email",
"password_no_match": "Password doesn't match the confirmation", "password_no_match": "Password doesn't match the confirmation",
"discard": "Discard", "discard": "Discard",
"close": "Close", "close": "Close",
@ -155,9 +154,7 @@
"source": "Source", "source": "Source",
"toggle_comment": "Toggle Comment", "toggle_comment": "Toggle Comment",
"find_in_files": "Find in Files", "find_in_files": "Find in Files",
"email": "Email",
"no_empty": "Can not Empty!", "no_empty": "Can not Empty!",
"change_avatar": "Avatar modify go",
"open": "Open", "open": "Open",
"search_no_match": "No matching files were found.", "search_no_match": "No matching files were found.",
"outline": "Outline", "outline": "Outline",

View File

@ -118,7 +118,6 @@
"team": "チーム", "team": "チーム",
"sing_up_error": "登録に失敗しました", "sing_up_error": "登録に失敗しました",
"user_name_ruler": "16の長さからなる_ AZ、AZ、0-9、によってユーザ名のみ", "user_name_ruler": "16の長さからなる_ AZ、AZ、0-9、によってユーザ名のみ",
"invalid_email": "無効な電子メール",
"password_no_match": "一貫性のないパスワード入力", "password_no_match": "一貫性のないパスワード入力",
"discard": "あきらめる", "discard": "あきらめる",
"close": "クローズ", "close": "クローズ",
@ -155,9 +154,7 @@
"source": "ソース", "source": "ソース",
"toggle_comment": "トグルコメント", "toggle_comment": "トグルコメント",
"find_in_files": "ファイルから検索", "find_in_files": "ファイルから検索",
"email": "Eメール",
"no_empty": "空ではありません", "no_empty": "空ではありません",
"change_avatar": "アバターの変更は行く",
"open": "オープン", "open": "オープン",
"search_no_match": "一致するファイルが見つかりませんでした。", "search_no_match": "一致するファイルが見つかりませんでした。",
"outline": "アウトライン", "outline": "アウトライン",

View File

@ -118,7 +118,6 @@
"team": "단체", "team": "단체",
"sing_up_error": "가입실패", "sing_up_error": "가입실패",
"user_name_ruler": "아이디는 16글자 이하이며 a-z, A-Z, 0-9, _ 만 가능합니다,", "user_name_ruler": "아이디는 16글자 이하이며 a-z, A-Z, 0-9, _ 만 가능합니다,",
"invalid_email": "유효하지 않은 email주소",
"password_no_match": "비밀번호 오류", "password_no_match": "비밀번호 오류",
"discard": "취소", "discard": "취소",
"close": "닫기", "close": "닫기",
@ -155,9 +154,7 @@
"source": "소스", "source": "소스",
"toggle_comment": "주석", "toggle_comment": "주석",
"find_in_files": "문서에서 찾기", "find_in_files": "문서에서 찾기",
"email": "이메일",
"no_empty": "값을 입력해 주세요.", "no_empty": "값을 입력해 주세요.",
"change_avatar": "아이콘변경은 여기로.",
"open": "열기", "open": "열기",
"search_no_match": "해당 문서를 찾지 못하였습니다.", "search_no_match": "해당 문서를 찾지 못하였습니다.",
"outline": "주제", "outline": "주제",

View File

@ -118,7 +118,6 @@
"team": "团队", "team": "团队",
"sing_up_error": "注册失败", "sing_up_error": "注册失败",
"user_name_ruler": "用户名只能由 a-z, A-Z, 0-9, _ 组成长度为16", "user_name_ruler": "用户名只能由 a-z, A-Z, 0-9, _ 组成长度为16",
"invalid_email": "无效的电子邮件",
"password_no_match": "密码输入不一致", "password_no_match": "密码输入不一致",
"discard": "放弃", "discard": "放弃",
"close": "关闭", "close": "关闭",
@ -155,9 +154,7 @@
"source": "源码", "source": "源码",
"toggle_comment": "注释", "toggle_comment": "注释",
"find_in_files": "在文件中查找", "find_in_files": "在文件中查找",
"email": "电子邮件",
"no_empty": "不能为空", "no_empty": "不能为空",
"change_avatar": "头像修改请到",
"open": "打开", "open": "打开",
"search_no_match": "没有发现匹配的文件。", "search_no_match": "没有发现匹配的文件。",
"outline": "大纲", "outline": "大纲",

View File

@ -118,7 +118,6 @@
"team": "團隊", "team": "團隊",
"sing_up_error": "註冊失敗", "sing_up_error": "註冊失敗",
"user_name_ruler": "帳號只能由 az, AZ, 0-9, _ 組成長度為16", "user_name_ruler": "帳號只能由 az, AZ, 0-9, _ 組成長度為16",
"invalid_email": "無效的電子郵件",
"password_no_match": "密碼輸入不一致", "password_no_match": "密碼輸入不一致",
"discard": "捨棄", "discard": "捨棄",
"close": "關閉", "close": "關閉",
@ -155,9 +154,7 @@
"source": "原始碼", "source": "原始碼",
"toggle_comment": "註解", "toggle_comment": "註解",
"find_in_files": "在文件中尋找", "find_in_files": "在文件中尋找",
"email": "電子郵件",
"no_empty": "不能為空", "no_empty": "不能為空",
"change_avatar": "修改頭像請到",
"open": "開啟", "open": "開啟",
"search_no_match": "沒有發現匹配的文件。", "search_no_match": "沒有發現匹配的文件。",
"outline": "大綱", "outline": "大綱",

View File

@ -99,7 +99,7 @@ func main() {
serveSingle("/favicon.ico", "./static/images/favicon.png") serveSingle("/favicon.ico", "./static/images/favicon.png")
// oauth // oauth
http.HandleFunc("/oauth/github", session.RedirectGitHubHandler) http.HandleFunc("/oauth/github/redirect", session.RedirectGitHubHandler)
http.HandleFunc("/oauth/github/callback", session.GithubCallbackHandler) http.HandleFunc("/oauth/github/callback", session.GithubCallbackHandler)
// session // session
@ -133,10 +133,9 @@ func main() {
// outline // outline
http.HandleFunc("/outline", handlerWrapper(file.GetOutlineHandler)) http.HandleFunc("/outline", handlerWrapper(file.GetOutlineHandler))
// file export/import // file export
http.HandleFunc("/file/zip/new", handlerWrapper(file.CreateZipHandler)) http.HandleFunc("/file/zip/new", handlerWrapper(file.CreateZipHandler))
http.HandleFunc("/file/zip", handlerWrapper(file.GetZipHandler)) http.HandleFunc("/file/zip", handlerWrapper(file.GetZipHandler))
http.HandleFunc("/file/decompress", handlerWrapper(file.DecompressHandler))
// editor // editor
http.HandleFunc("/editor/ws", handlerWrapper(editor.WSHandler)) http.HandleFunc("/editor/ws", handlerWrapper(editor.WSHandler))

View File

@ -59,10 +59,6 @@ func RedirectGitHubHandler(w http.ResponseWriter, r *http.Request) {
if "" == referer || !strings.Contains(referer, "://") { if "" == referer || !strings.Contains(referer, "://") {
referer = conf.Wide.Server + referer referer = conf.Wide.Server + referer
} }
if strings.HasSuffix(referer, "/") {
referer = referer[:len(referer)-1]
}
referer += "__1"
state := util.Rand.String(16) + referer state := util.Rand.String(16) + referer
states[state] = state states[state] = state
path := loginAuthURL + "?client_id=" + clientId + "&state=" + state + "&scope=public_repo,read:user,user:follow" path := loginAuthURL + "?client_id=" + clientId + "&state=" + state + "&scope=public_repo,read:user,user:follow"

View File

@ -448,7 +448,6 @@ var menu = {
"GoBuildArgsForDarwin": $GoBuildArgsForDarwin.val(), "GoBuildArgsForDarwin": $GoBuildArgsForDarwin.val(),
"workspace": $workspace.val(), "workspace": $workspace.val(),
"password": $password.val(), "password": $password.val(),
"email": $email.val(),
"locale": $locale.val(), "locale": $locale.val(),
"theme": $theme.val(), "theme": $theme.val(),
"editorFontFamily": $editorFontFamily.val(), "editorFontFamily": $editorFontFamily.val(),

View File

@ -101,24 +101,13 @@
{{end}} {{end}}
</select> </select>
</label> </label>
<label>
{{.i18n.email}}{{.i18n.colon}}
<input data-value="{{.user.Email}}" value="{{.user.Email}}" name="email"/>
</label>
<input data-value="{{.user.Locale}}" value="{{.user.Locale}}" name="locale" hidden="hidden" /> <input data-value="{{.user.Locale}}" value="{{.user.Locale}}" name="locale" hidden="hidden" />
<label> <label>
{{.i18n.workspace}}{{.i18n.colon}} {{.i18n.workspace}}{{.i18n.colon}}
<input data-value="{{.user.Workspace}}" value="{{.user.Workspace}}" name="workspace" readonly="readonly" /> <input data-value="{{.user.Workspace}}" value="{{.user.Workspace}}" name="workspace" readonly="readonly" />
</label> </label>
<label>
{{.i18n.password}}{{.i18n.colon}}
<input data-value="{{.user.Password}}" value="{{.user.Password}}" name="password" type="password"/>
</label>
<label class="fn-clear"> <label class="fn-clear">
<img onerror="this.src='/static/images/user-thumbnail.png'" <img onerror="this.src='/static/images/user-thumbnail.png'" src="{{.user.Gravatar}}" title="{{.user.Name}}" class='gravatar'/>
src="https://secure.gravatar.com/avatar/{{.user.Gravatar}}?s=48&d=https://hacpai.com/images/user-thumbnail.png"
title="{{.user.Name}}" class='gravatar'/>
<a href="http://gravatar.com/" target="_blank">{{.i18n.change_avatar}} Gravatar.com</a>
</label> </label>
</div> </div>
</div> </div>