This commit is contained in:
tonyrewin 2022-08-11 12:59:35 +03:00
parent 65532ea1a3
commit 8a7d062eb4
10 changed files with 203 additions and 22 deletions

View File

@ -1 +0,0 @@
__all__ = ["tables", "bson2json", "html2md"]

View File

@ -5,17 +5,19 @@ import subprocess
import sys import sys
import os import os
# from migration.export import export_email_subscriptions # from export import export_email_subscriptions
from migration.export import export_mdx, export_slug from export import export_mdx, export_slug
from migration.tables.users import migrate as migrateUser
from migration.tables.users import migrate_2stage as migrateUser_2stage
from migration.tables.content_items import get_shout_slug, migrate as migrateShout
from migration.tables.topics import migrate as migrateTopic
from migration.tables.comments import migrate as migrateComment
from migration.tables.comments import migrate_2stage as migrateComment_2stage
from orm.reaction import Reaction from orm.reaction import Reaction
from tables.users import migrate as migrateUser
from tables.users import migrate_2stage as migrateUser_2stage
from tables.content_items import get_shout_slug, migrate as migrateShout
from tables.topics import migrate as migrateTopic
from tables.comments import migrate as migrateComment
from tables.comments import migrate_2stage as migrateComment_2stage
from settings import DB_URL from settings import DB_URL
TODAY = datetime.strftime(datetime.now(), '%Y%m%d') TODAY = datetime.strftime(datetime.now(), '%Y%m%d')
OLD_DATE = '2016-03-05 22:22:00.350000' OLD_DATE = '2016-03-05 22:22:00.350000'

View File

@ -2,7 +2,7 @@ import os
import bson import bson
import json import json
from migration.utils import DateTimeEncoder from utils import DateTimeEncoder
def json_tables(): def json_tables():
print('[migration] unpack dump/discours/*.bson to migration/data/*.json') print('[migration] unpack dump/discours/*.bson to migration/data/*.json')

View File

@ -3,8 +3,8 @@ from datetime import datetime
import json import json
import os import os
import frontmatter import frontmatter
from migration.extract import extract_html, prepare_html_body from extract import extract_html, prepare_html_body
from migration.utils import DateTimeEncoder from utils import DateTimeEncoder
OLD_DATE = '2016-03-05 22:22:00.350000' OLD_DATE = '2016-03-05 22:22:00.350000'
EXPORT_DEST = '../discoursio-web/data/' EXPORT_DEST = '../discoursio-web/data/'

View File

@ -1,7 +1,7 @@
import os import os
import re import re
import base64 import base64
from migration.html2text import html2text from html2text import html2text
TOOLTIP_REGEX = r'(\/\/\/(.+)\/\/\/)' TOOLTIP_REGEX = r'(\/\/\/(.+)\/\/\/)'
contentDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'discoursio-web', 'content') contentDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'discoursio-web', 'content')

View File

@ -2,8 +2,8 @@ from datetime import datetime
from dateutil.parser import parse as date_parse from dateutil.parser import parse as date_parse
from orm import Reaction, User from orm import Reaction, User
from orm import reaction from orm import reaction
from orm.base import local_session from base.orm import local_session
from migration.html2text import html2text from html2text import html2text
from orm.reaction import ReactionKind from orm.reaction import ReactionKind
from orm.shout import Shout from orm.shout import Shout

View File

@ -1,11 +1,11 @@
from dateutil.parser import parse as date_parse from dateutil.parser import parse as date_parse
import sqlalchemy import sqlalchemy
from orm.shout import Shout, ShoutTopic, User from orm.shout import Shout, ShoutTopic, User
from storages.viewed import ViewedByDay from services.stat.viewed import ViewedByDay
from transliterate import translit from transliterate import translit
from datetime import datetime from datetime import datetime
from orm.base import local_session from base.orm import local_session
from migration.extract import prepare_html_body from extract import prepare_html_body
from orm.community import Community from orm.community import Community
from orm.reaction import Reaction, ReactionKind from orm.reaction import Reaction, ReactionKind

View File

@ -1,5 +1,5 @@
from migration.extract import extract_md, html2text from extract import extract_md, html2text
from orm.base import local_session from base.orm import local_session
from orm import Topic, Community from orm import Topic, Community
def migrate(entry): def migrate(entry):

View File

@ -1,8 +1,8 @@
import sqlalchemy import sqlalchemy
from migration.html2text import html2text from html2text import html2text
from orm import User, UserRating from orm import User, UserRating
from dateutil.parser import parse from dateutil.parser import parse
from orm.base import local_session from base.orm import local_session
def migrate(entry): def migrate(entry):
if 'subscribedTo' in entry: del entry['subscribedTo'] if 'subscribedTo' in entry: del entry['subscribedTo']

180
nginx.conf Normal file
View File

@ -0,0 +1,180 @@
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
error_log error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
map $http_origin $allow_origin {
~^https?://(.*\.)?localhost:3000|new.discours.io|discours.io()(:\d+)?$ $http_origin;
default "";
}
upstream discoursio-api-8080 {
server 0.0.0.0:8080;
}
server {
listen localhost:8000;
#server_name localhost;
#charset koi8-r;
# access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
#}
location / {
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
gzip_vary on;
gzip_comp_level 6;
proxy_pass http://discoursio-api-8080;
http2_push_preload on;
proxy_http_version 1.1;
proxy_read_timeout 60s;
proxy_buffer_size 4096;
proxy_buffering on;
proxy_buffers 8 4096;
proxy_busy_buffers_size 8192;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-Start $msec;
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
#
# Custom headers and headers various browsers *should* be OK with but aren't
#
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Allow-Credentials' 'true';
#
# Tell client that this pre-flight info is valid for 20 days
#
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' '*:' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include servers/*;
}