mirror of
https://github.com/onionshare/onionshare.git
synced 2024-12-27 08:19:41 -05:00
Start code sharing between WebsiteMode and ShareMode
This commit is contained in:
parent
9a327f26ea
commit
0f40e9589c
45
onionshare/web/base_mode.py
Normal file
45
onionshare/web/base_mode.py
Normal file
@ -0,0 +1,45 @@
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import mimetypes
|
||||
from flask import Response, request, render_template, make_response
|
||||
|
||||
from .. import strings
|
||||
|
||||
class BaseModeWeb(object):
|
||||
"""
|
||||
All of the web logic shared between share and website mode
|
||||
"""
|
||||
def __init__(self, common, web):
|
||||
super(BaseModeWeb, self).__init__()
|
||||
self.common = common
|
||||
self.web = web
|
||||
|
||||
# Information about the file to be shared
|
||||
self.file_info = []
|
||||
self.is_zipped = False
|
||||
self.download_filename = None
|
||||
self.download_filesize = None
|
||||
self.gzip_filename = None
|
||||
self.gzip_filesize = None
|
||||
self.zip_writer = None
|
||||
|
||||
# Dictionary mapping file paths to filenames on disk
|
||||
self.files = {}
|
||||
|
||||
self.visit_count = 0
|
||||
self.download_count = 0
|
||||
|
||||
# If "Stop After First Download" is checked (stay_open == False), only allow
|
||||
# one download at a time.
|
||||
self.download_in_progress = False
|
||||
|
||||
# Reset assets path
|
||||
self.web.app.static_folder=self.common.get_resource_path('static')
|
||||
|
||||
|
||||
def init(self):
|
||||
"""
|
||||
Add custom initialization here.
|
||||
"""
|
||||
pass
|
@ -6,38 +6,17 @@ import mimetypes
|
||||
import gzip
|
||||
from flask import Response, request, render_template, make_response
|
||||
|
||||
from .base_mode import BaseModeWeb
|
||||
from .. import strings
|
||||
|
||||
|
||||
class ShareModeWeb(object):
|
||||
class ShareModeWeb(BaseModeWeb):
|
||||
"""
|
||||
All of the web logic for share mode
|
||||
"""
|
||||
def __init__(self, common, web):
|
||||
self.common = common
|
||||
def init(self):
|
||||
self.common.log('ShareModeWeb', '__init__')
|
||||
|
||||
self.web = web
|
||||
|
||||
# Information about the file to be shared
|
||||
self.file_info = []
|
||||
self.is_zipped = False
|
||||
self.download_filename = None
|
||||
self.download_filesize = None
|
||||
self.gzip_filename = None
|
||||
self.gzip_filesize = None
|
||||
self.zip_writer = None
|
||||
|
||||
self.download_count = 0
|
||||
|
||||
# If "Stop After First Download" is checked (stay_open == False), only allow
|
||||
# one download at a time.
|
||||
self.download_in_progress = False
|
||||
|
||||
# Reset assets path
|
||||
self.web.app.static_folder=self.common.get_resource_path('static')
|
||||
|
||||
|
||||
self.define_routes()
|
||||
|
||||
def define_routes(self):
|
||||
|
@ -4,26 +4,18 @@ import tempfile
|
||||
import mimetypes
|
||||
from flask import Response, request, render_template, make_response, send_from_directory
|
||||
|
||||
from .base_mode import BaseModeWeb
|
||||
from .. import strings
|
||||
|
||||
|
||||
class WebsiteModeWeb(object):
|
||||
class WebsiteModeWeb(BaseModeWeb):
|
||||
"""
|
||||
All of the web logic for share mode
|
||||
"""
|
||||
def __init__(self, common, web):
|
||||
self.common = common
|
||||
def init(self):
|
||||
|
||||
self.common.log('WebsiteModeWeb', '__init__')
|
||||
|
||||
self.web = web
|
||||
|
||||
# Dictionary mapping file paths to filenames on disk
|
||||
self.files = {}
|
||||
self.visit_count = 0
|
||||
|
||||
# Reset assets path
|
||||
self.web.app.static_folder=self.common.get_resource_path('static')
|
||||
|
||||
self.define_routes()
|
||||
|
||||
def define_routes(self):
|
||||
|
Loading…
Reference in New Issue
Block a user