Skip to content

Commit

Permalink
Merge pull request #416 from h3llrais3r/angularize-ui
Browse files Browse the repository at this point in the history
Angularize UI
  • Loading branch information
h3llrais3r committed Mar 7, 2021
2 parents f9d2dda + d8c2d25 commit 0a5e3d4
Show file tree
Hide file tree
Showing 1,211 changed files with 175,614 additions and 69,350 deletions.
20 changes: 13 additions & 7 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ skip_tags: true
# Build environment
environment:
matrix:
- PYTHON: C:\Python27-x64
PYTHON_VERSION: 2.7
PYTHON_ARCH: 64
#- PYTHON: C:\Python27-x64
# PYTHON_VERSION: 2.7
# PYTHON_ARCH: 64

- PYTHON: C:\Python35-x64
PYTHON_VERSION: 3.5
Expand All @@ -38,7 +38,7 @@ matrix:
cache:
- '%LOCALAPPDATA%\pip\Cache'
- '%APPDATA%\npm-cache'
- 'node_modules'
- 'web\autosubliminal\node_modules'

# Command(s) to execute before starting
init:
Expand All @@ -61,6 +61,7 @@ init:
# Command(s) to install dependencies
install:
# Backend code
# Install/upgrade python dependencies
- set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH% # Prepend newly installed Python to the PATH of this build
- python --version # Verify version
Expand All @@ -70,18 +71,23 @@ install:
- pip install --upgrade pytest # Upgrade pytest to latest version to prevent build errors
- pip install -e .[dev,test]
- pip install coverage

# Frontend code
- cd web/autosubliminal
# Install minimal required node version from package.json
- ps: $env:NODE_VERSION = (Get-Content -Raw -Path package.json | ConvertFrom-Json).engines.node -replace "[>=]"
- ps: Install-Product node $env:NODE_VERSION x64
- node --version
- npm --version
# Install npm dependencies
- npm install
- cd ../..

# Test command(s)
# Build & Test command(s)
before_test:
- npm run eslint
- npm run stylelint
- cd web/autosubliminal
- npm run lint
- cd ../..

test_script:
- coverage run setup.py test
Expand Down
8 changes: 0 additions & 8 deletions .babelrc.json

This file was deleted.

9 changes: 0 additions & 9 deletions .eslintignore

This file was deleted.

54 changes: 0 additions & 54 deletions .eslintrc.json

This file was deleted.

1 change: 0 additions & 1 deletion .stylelintignore

This file was deleted.

3 changes: 0 additions & 3 deletions .stylelintrc.json

This file was deleted.

14 changes: 10 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,36 @@ cache:
npm: true
directories:
- $HOME/.cache/pip
- node_modules
- web/autosubliminal/node_modules

# Install command(s)
before_install:
- export BOTO_CONFIG=/dev/null # FIXME: Workaround for https://github.com/travis-ci/travis-ci/issues/7940

install:
# Backend code
# Install/upgrade python dependencies
- pip install --upgrade pip
- pip install --upgrade six # Upgrade pytest to latest version to prevent build errors
- pip install --upgrade pytest # Upgrade pytest to latest version to prevent build errors
- pip install -e .[dev,test]
- pip install coveralls

# Frontend code
- cd web/autosubliminal
# Install minimal required node version from package.json
- nvm install "$(jq -r '.engines.node' package.json | sed 's/[>=]//g')"
- node --version
- npm --version
# Install npm dependencies
- npm install
- cd ../..

# Build command(s)
# Build & Test command(s)
before_script:
- npm run eslint
- npm run stylelint
- cd web/autosubliminal
- npm run lint
- cd ../..

script:
- coverage run setup.py test # Coverage configuration is done in .coveragerc
Expand Down
5 changes: 2 additions & 3 deletions autosubliminal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def initialize():
SUBLIMINALPROVIDERMANAGER, SUBLIMINALPROVIDERS, SUBLIMINALPROVIDERCONFIGS, \
SUBTITLEUTF8ENCODING, MANUALREFINEVIDEO, REFINEVIDEO, PREFERHEARINGIMPAIRED, \
ANTICAPTCHACLASS, ANTICAPTCHACLIENTKEY, ADDIC7EDUSERNAME, ADDIC7EDPASSWORD, \
OPENSUBTITLESUSERNAME, OPENSUBTITLESPASSWORD, LEGENDASTVUSERNAME, LEGENDASTVPASSWORD, \
OPENSUBTITLESUSERNAME, OPENSUBTITLESPASSWORD, LEGENDASTVUSERNAME, LEGENDASTVPASSWORD, \
SHOWNAMEMAPPING, ADDIC7EDSHOWNAMEMAPPING, ALTERNATIVESHOWNAMEMAPPING, \
MOVIENAMEMAPPING, ALTERNATIVEMOVIENAMEMAPPING, \
SKIPSHOW, SKIPMOVIE, \
Expand Down Expand Up @@ -343,15 +343,14 @@ def _init_cache(replace):
"""Initialize internal cache."""

# Imports
from autosubliminal.core.cache import clear_imdbpie_cache, clear_mako_cache, MutexFileLock, region
from autosubliminal.core.cache import clear_imdbpie_cache, MutexFileLock, region

# Make sure the cache dir exists
if not os.path.exists(CACHEDIR):
os.makedirs(CACHEDIR)

# Clean mako cache
if replace:
clear_mako_cache()
clear_imdbpie_cache()

# Configure autosubliminal/dogpile cache
Expand Down
76 changes: 42 additions & 34 deletions autosubliminal/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import signal
import subprocess
import sys
import time
import webbrowser

import cherrypy
Expand All @@ -19,10 +20,12 @@
from autosubliminal.diskscanner import DiskScanner
from autosubliminal.libraryscanner import LibraryScanner
from autosubliminal.server.root import WebServerRoot
from autosubliminal.server.tool import SPARedirectTool
from autosubliminal.subchecker import SubChecker
from autosubliminal.util.encoding import s2n
from autosubliminal.util.json import json_out_handler
from autosubliminal.util.packaging import get_library_version
from autosubliminal.util.websocket import send_websocket_event, SYSTEM_RESTART, SYSTEM_SHUTDOWN, SYSTEM_START
from autosubliminal.versionchecker import VersionChecker

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -130,6 +133,10 @@ def _configure_server(restarting=False):
# Configure our custom json_out_handler (Uncomment if it should be used for any @cherrypy.tools.json_out())
# cherrypy.config.update({'tools.json_out.handler': json_out_handler})

# Enable spa redirect tool (redirect to custom index.webroot.html which takes care of the webroot as well)
_setup_index_html()
cherrypy.tools.spa_redirect = SPARedirectTool('/autosubliminal/index.webroot.html')

if not restarting:
# Enable websocket plugin
websocket_plugin = WebSocketPlugin(cherrypy.engine)
Expand All @@ -142,56 +149,47 @@ def _configure_server(restarting=False):
cherrypy.server.httpserver = None


def _setup_index_html():
# Read index.html and replace base href
with open('web/autosubliminal/static/index.html', mode='r') as f:
content = f.read()
content = content.replace('<base href="/autosubliminal/">',
'<base href="' + autosubliminal.WEBROOT + '/autosubliminal/">')

# Write index.webroot.html with changed base href
with open('web/autosubliminal/static/index.webroot.html', mode='w') as f:
f.truncate() # clear before writing
f.write(content)


def _get_application_configuration():
# Configure application
conf = {
'/': {
'tools.encode.encoding': 'utf-8',
'tools.decode.encoding': 'utf-8',
'tools.staticdir.root': os.path.abspath(os.path.join(autosubliminal.PATH, 'web/static')),
'tools.decode.encoding': 'utf-8'
},
'/api': {
'tools.json_out.handler': json_out_handler, # Use our custom json_out_handler for /api
'tools.response_headers.on': True, # Always force content-type
'tools.response_headers.headers': [('Content-Type', 'application/json; charset=utf-8')]
},
'/css': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'css',
'tools.expires.on': True,
'tools.expires.secs': 3600 * 24 * 7
},
'/fonts': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'fonts',
'tools.expires.on': True,
'tools.expires.secs': 3600 * 24 * 7
},
'/images': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'images',
'tools.expires.on': True,
'tools.expires.secs': 3600 * 24 * 7
},
'/js': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'js',
'tools.expires.on': True,
'tools.expires.secs': 3600 * 24 * 7
},
'/favicon.ico': {
'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.abspath(
os.path.join(autosubliminal.PATH, 'web/static/images/favicon.ico'))
},
'/system/websocket': {
'/websocket/system': {
'tools.websocket.on': True,
'tools.websocket.handler_cls': WebSocketHandler
},
'/log/websocket': {
'/websocket/log': {
'tools.websocket.on': True,
'tools.websocket.handler_cls': WebSocketLogHandler
}
},
'/autosubliminal': {
'tools.staticdir.root': os.path.abspath(os.path.join(autosubliminal.PATH, 'web/autosubliminal')),
'tools.staticdir.on': True,
'tools.staticdir.dir': 'static',
'tools.spa_redirect.on': True
# 'tools.expires.on': True,
# 'tools.expires.secs': 3600 * 24 * 7
},
}

# Return config
Expand All @@ -204,6 +202,10 @@ def start():
# Start permanent threads
autosubliminal.WEBSOCKETBROADCASTER = WebSocketBroadCaster(name='WebSocketBroadCaster')

# Sleep 3 seconds before sending the start event trough websocket (client websockets reconnect every 2 seconds)
time.sleep(3)
send_websocket_event(SYSTEM_START)

# Schedule threads
# Order of CHECKVERSION, SCANDISK and CHECKSUB is important because they are all using the queue lock
# Make sure they are started in the specified order:
Expand All @@ -224,6 +226,9 @@ def start():

def stop(exit=True):
log.info('Stopping')
if exit:
send_websocket_event(SYSTEM_SHUTDOWN)
time.sleep(2) # Sleep 2 seconds to give the frontend to receive the event

# Mark as stopped
autosubliminal.STARTED = False
Expand All @@ -245,6 +250,9 @@ def stop(exit=True):

def restart(exit=False):
log.info('Restarting')
send_websocket_event(SYSTEM_RESTART)
time.sleep(2) # Sleep 2 seconds to give the frontend to receive the event

if exit:
# Exit current process and restart a new one with the same args
# Get executable and args
Expand Down
Loading

0 comments on commit 0a5e3d4

Please sign in to comment.