Selaa lähdekoodia

Int Exceptions

PtrKR 7 vuotta sitten
vanhempi
sitoutus
32375d1520
8 muutettua tiedostoa jossa 106 lisäystä ja 74 poistoa
  1. 1 1
      .github/PULL_REQUEST_TEMPLATE.md
  2. 11 10
      Docker-Install.md
  3. 24 0
      conf_example/nginx-ssl.conf
  4. 11 14
      conf_example/nginx.conf
  5. 18 10
      emergency_tool.py
  6. 15 15
      oauthsettings.json
  7. 15 13
      readme-ko.md
  8. 11 11
      readme.md

+ 1 - 1
.github/PULL_REQUEST_TEMPLATE.md

@@ -1,4 +1,4 @@
 <!--
-stable branch로 request를 보내지 마십시오. 개발은 master branch에서 이루어집니다.
+stable branch로 요청을 보내지 마십시오. 개발은 master branch에서 이루어집니다.
 Don't request merge your commit to stable branch, please request to master branch.
 -->

+ 11 - 10
Docker-Install.md

@@ -1,11 +1,12 @@
-## Installation
-```
-docker pull hotococoa/opennamu
-```
-
-## Setting
-```
-export NAMU_PORT=port
-export NAMU_LANG=lang
-```
+## Installation
+```
+docker pull hotococoa/opennamu
+```
+
+## Setting
+```
+export NAMU_PORT=port
+export NAMU_HOST=host
+export NAMU_LANG=lang
+```
 Default: Port 3000, en-US

+ 24 - 0
conf_example/nginx-ssl.conf

@@ -0,0 +1,24 @@
+server {
+    listen       80;
+    server_name  <domain>;
+  
+    return       301 https://$server_name$request_uri;
+}
+  
+  
+server {
+    listen       443 ssl;
+    server_name  <domain>;
+ 
+    ssl_certificate "<certificate file path>";
+    ssl_certificate_key "<private key file path>";
+  
+    location / {
+        proxy_redirect off;
+        proxy_pass_header Server;
+        proxy_set_header Host $http_host;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Scheme $scheme;
+        proxy_pass http://localhost:<port>/;
+    }
+}

+ 11 - 14
conf_example/nginx.conf

@@ -1,18 +1,15 @@
 server {
- listen 80;
- listen [::]:80;
+   listen 80;
+   listen [::]:80;
 
- listen 443 ssl;
- listen [::]:443 ssl;
+   server_name <domain>;
 
- server_name <domain>;
-
- location / {
- proxy_redirect off;
- proxy_pass_header Server;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Scheme $scheme;
- proxy_pass http://localhost:<port>;
- }
+   location / {
+   proxy_redirect off;
+   proxy_pass_header Server;
+   proxy_set_header Host $http_host;
+   proxy_set_header X-Real-IP $remote_addr;
+   proxy_set_header X-Scheme $scheme;
+   proxy_pass http://localhost:<port>;
+   }
 }

+ 18 - 10
emergency_tool.py

@@ -9,8 +9,8 @@ from mark import load_conn2, namumark
 
 try:
     f = open('set.json', 'r')
-except:
-    print('Error: set.json not found. please run setup script first.')
+except FileNotFoundError as e:
+    print('Error: set.json is not found. please run setup script first.')
     exit()
 else:
     f.close()
@@ -74,8 +74,12 @@ elif what_i_do == '4':
 
     curs.execute("update other set data = ? where name = 'host'", [host])
 elif what_i_do == '5':
-    print('port : ', end = '')
-    port = int(input())
+    try:
+        print('port : ', end = '')
+        port = int(input())
+    except ValueError:
+            print('Error: Please input int value')
+            exit()
 
     curs.execute("update other set data = ? where name = 'port'", [port])
 elif what_i_do == '6':
@@ -84,11 +88,15 @@ elif what_i_do == '6':
 
     curs.execute("update other set data = ? where name = 'skin'", [skin])
 elif what_i_do == '7':
-    print('1. sha256')
-    print('2. sha3')
-    print('3. bcrypt')
-    print('select : ', end = '')
-    what_i_do = int(input())
+    try:
+        print('1. sha256')
+        print('2. sha3')
+        print('3. bcrypt')
+        print('select : ', end = '')
+        what_i_do = int(input())
+    except ValueError:
+        print('Error: Please input int value')
+        exit()
 
     print('user name : ', end = '')
     user_name = input()
@@ -99,7 +107,7 @@ elif what_i_do == '7':
     if what_i_do == '1':
         hashed = hashlib.sha256(bytes(user_pw, 'utf-8')).hexdigest()
     elif what_i_do == '2':
-        hashed = sha3.sha3_256(bytes(user_pw, 'utf-8')).hexdigest()
+        hashed = sha3_256(bytes(user_pw, 'utf-8')).hexdigest()
     elif what_i_do == '3':
         hashed = bcrypt.hashpw(bytes(user_pw, 'utf-8'), bcrypt.gensalt()).decode()
        

+ 15 - 15
oauthsettings.json

@@ -1,16 +1,16 @@
-{
-    "_README" : {
-        "en" : "To use the oauth login feature, you must set the 'publish_url' value to a domain address that includes the https protocol, and actually support https connections.",
-        "ko" : "oauth 로그인 기능을 사용하려면 'publish_url'값을 https 프로토콜을 포함한 도메인 주소로 설정하고, 실제로 https 연결을 지원해야합니다.",
-        "support" : ["facebook", "naver"]
-    },
-    "publish_url" : "https://",
-    "facebook" : {
-        "client_id" : "",
-        "client_secret" : ""
-    },
-    "naver" : {
-        "client_id" : "",
-        "client_secret" : ""
-    }
+{
+    "_README" : {
+        "en" : "To use the oAuth login feature, you must set the 'publish_url' value to a domain address that includes the HTTPS protocol, and actually support HTTPS connections.",
+        "ko" : "oAuth 로그인 기능을 사용하려면 'publish_url' 값을 HTTPS 프로토콜을 포함한 도메인 주소로 설정하고, 실제로 HTTPS 연결을 지원해야 합니다.",
+        "support" : ["facebook", "naver"]
+    },
+    "publish_url" : "https://",
+    "facebook" : {
+        "client_id" : "",
+        "client_secret" : ""
+    },
+    "naver" : {
+        "client_id" : "",
+        "client_secret" : ""
+    }
 }

+ 15 - 13
readme-ko.md

@@ -1,4 +1,4 @@
-opennamu
+openNAMU
 ====
 ![Python 3.5 이상 필요](https://img.shields.io/badge/python-%3E%3D%203.5-blue.svg)
 
@@ -22,16 +22,16 @@ opennamu
 [파이썬 설치 가이드](https://github.com/404-sdok/how-to-python/blob/master/0.md)를 참고하여 파이썬을 설치합니다.
 
 ### 릴리즈 다운로드
-[릴리즈](https://github.com/2du/openNAMU/releases)에서 opennamu의 릴리즈 판을 다운로드 받고, 압축을 해제합니다. 레포지토리를 클론하여 릴리즈를 적용하는 것도 가능합니다. 자세한 내용은 [클론](#클론)문단을 참고하세요.
+[릴리즈](https://github.com/2du/openNAMU/releases)에서 openNAMU의 릴리즈 판을 다운로드 받고, 압축을 해제합니다. 레포지토리를 클론하여 릴리즈를 적용하는 것도 가능합니다. 자세한 내용은 [클론](#클론)문단을 참고하세요.
 
 ### 모듈 설치
-다음 명령어로 opennamu 구성 파일이 위치한 디렉토리로 이동합니다.
+다음 명령어로 openNAMU 구성 파일이 위치한 디렉토리로 이동합니다.
 ```
 cd [path]
 ```
 
 
-다음 명령어로 opennamu 실행에 필요한 모듈을 설치합니다.
+다음 명령어로 openNAMU 실행에 필요한 모듈을 설치합니다.
 ```
 pip install -r requirements.txt
 ```
@@ -41,7 +41,7 @@ pip3 install -r requirements.txt
 ```
 ## 애플리케이션 시작
 ### 애플리케이션 시작
-opennamu를 시작합니다.
+openNAMU를 시작합니다.
 ```
 python app.py
 ```
@@ -50,28 +50,30 @@ python app.py
 python3 app.py
 ```
 
-* opennamu의 첫 계정은 소유자 계정으로 설정됩니다.
+* openNAMU의 첫 계정은 소유자 계정으로 설정됩니다.
 
 ### 애플리케이션 공개
-현재 opennamu에서 권장하는 애플리케이션 공개 방법은 아파치나 nginx와 같은 웹서버 호스팅 소프트웨어를 통해 리버스 프록시를 설정하는 것입니다.
+현재 openNAMU에서 권장하는 애플리케이션 공개 방법은 아파치나 nginx와 같은 웹 서버 구동 소프트웨어를 통해 리버스 프록시를 설정하는 것입니다.
 
 * ([apache 설정 파일 예시](./conf_example/apache/), [nginx 설정 파일 예시](./conf_example/nginx.conf))
 
+만약 HTTPS 리버스 프록시를 설정하는 경우, 보안을 위해 openNAMU 설정에서 호스트를 localhost 환경으로 변경할 것을 권장합니다.
+
 
 # 클론
 아래 명령을 터미널(명령 프롬프트)에 입력하여 본 리포지토리를 클론할 수 있습니다.
 ## 일반
- * `git clone -b stable https://github.com/2du/opennamu.git`
+ * `git clone -b stable https://github.com/2du/openNAMU.git`
 
 ## 베타
- * `git clone -b master https://github.com/2du/opennamu.git`
+ * `git clone -b master https://github.com/2du/openNAMU.git`
 
 # 기여
 오픈나무에는 검증되지 않은 몇가지 버그가 존재할 수 있습니다. 당신의 오픈나무 사용과 버그 발견은 오픈나무의 발전을 돕습니다.
-[이슈 생성하기](https://github.com/2du/opennamu/issues/new)
+[이슈 생성하기](https://github.com/2du/openNAMU/issues/new)
 
 오픈나무는 완전한 오픈소스 프로젝트입니다. 새로운 기능을 추가하고 Pull Request를 생성해보세요.
-[Pull Requests 생성하기](https://github.com/2du/opennamu/compare)
+[Pull Request 생성하기](https://github.com/2du/openNAMU/compare)
 
 # 라이선스
 오픈나무는 [BSD 3-Clause License](./LICENSE)에 의해 보호받고 있습니다. 자세한 내용은 문서를 참고하세요.
@@ -82,7 +84,7 @@ python3 app.py
  * Numerical expression - [MathJax](https://www.mathjax.org/) - [Apache License 2.0](https://github.com/mathjax/MathJax/blob/master/LICENSE)
 
 # 기여자 목록
- * [참고](https://github.com/2DU/opennamu/graphs/contributors)
+ * [참고](https://github.com/2DU/openNAMU/graphs/contributors)
 
 ## 도움을 주신 분들
  * [Team Croatia](https://github.com/TeamCroatia)
@@ -92,7 +94,7 @@ python3 app.py
 
 # 기타
 `set.json`은 몇가지 로컬 설정을 저장하는 설정 파일입니다.
- * db = 데이터베이스 이름
+ * [filename].db = 데이터베이스 이름
 
 `set.json`은 삭제해도 다시 새로 만들 수 있습니다.
 

+ 11 - 11
readme.md

@@ -1,10 +1,10 @@
-opennamu
+openNAMU
 ====
 ![Python 3.5 or later Required](https://img.shields.io/badge/python-%3E%3D%203.5-blue.svg)
 
 ![](./logo.png)
 
-opennamu is a Python-based wiki engine. You can use opennamu by installing Python and its dependency modules, and you can modify the code yourself to create more specialized wikis.
+openNAMU is a Python-based wiki engine. You can use openNAMU by installing Python and its dependency modules, and you can modify the code yourself to create more specialized wikis.
 
  * [(README for korean)](./readme-ko.md)
 
@@ -21,20 +21,20 @@ opennamu is a Python-based wiki engine. You can use opennamu by installing Pytho
 # Clone
 You can clone this repository by entering the following command at the terminal (command prompt):
 ## Stable
- * `git clone -b stable https://github.com/2du/opennamu.git`
+ * `git clone -b stable https://github.com/2du/openNAMU.git`
 
 ## Beta
- * `git clone -b master https://github.com/2du/opennamu.git`
+ * `git clone -b master https://github.com/2du/openNAMU.git`
 
 # Contribute
-opennamu may have some untested bugs. Your use of opennamu and bug discovery will help develop opennamu.
-[Create Issues](https://github.com/2du/opennamu/issues/new)
+openNAMU may have some untested bugs. Your use of openNAMU and bug discovery will help develop openNAMU.
+[Create Issues](https://github.com/2du/openNAMU/issues/new)
 
-opennamu is open source project. Add new features and request pull requests. 
-[Create Pull Requests](https://github.com/2du/opennamu/compare)
+openNAMU is open source project. Add new features and request pull requests. 
+[Create Pull Requests](https://github.com/2du/openNAMU/compare)
 
 # Lisence
-opennamu is protected by [BSD 3-Clause License](./LICNESE). Please refer to the documentation for details.
+openNAMU is protected by [BSD 3-Clause License](./LICNESE). Please refer to the documentation for details.
 
 ## External Projects
  * Quotes icon [Dave Gandy](http://www.flaticon.com/free-icon/quote-left_25672) CC 3.0 BY
@@ -42,7 +42,7 @@ opennamu is protected by [BSD 3-Clause License](./LICNESE). Please refer to the
  * Numerical expression [MathJax](https://www.mathjax.org/)
 
 # Authors
- * [Reference](https://github.com/2DU/opennamu/graphs/contributors)
+ * [Reference](https://github.com/2DU/openNAMU/graphs/contributors)
 
 ## Special Thanks
  * [Team Croatia](https://github.com/TeamCroatia)
@@ -52,7 +52,7 @@ opennamu is protected by [BSD 3-Clause License](./LICNESE). Please refer to the
 
 # Etc.
 `set.json` is a configuration file that stores some local settings.
- * db = Database name
+ * [filename].db = Database name
 
 If you delete `set.json`, you can create a new one again.