Merge pull request #42 from Trekky12/main

Add offline parameter
This commit is contained in:
Piero Toffanin 2021-02-10 12:22:55 -05:00 committed by GitHub
commit 9434ee83b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 78 additions and 11 deletions

View file

@ -14,7 +14,8 @@ def get_remote_address():
return ip
def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=False, frontend_language_source="en", frontend_language_target="en", frontend_timeout=500):
def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=False, frontend_language_source="en", frontend_language_target="en", frontend_timeout=500, offline=False):
if not offline:
from app.init import boot
boot()
@ -68,7 +69,7 @@ def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=Fa
@app.route("/")
def index():
return render_template('index.html', gaId=ga_id, frontendTimeout=frontend_timeout)
return render_template('index.html', gaId=ga_id, frontendTimeout=frontend_timeout, offline=offline)
@app.route("/languages")
def langs():

View file

@ -25,6 +25,8 @@ def main():
help='Set frontend default language - target (%(default)s)')
parser.add_argument('--frontend-timeout', type=int, default=500, metavar="<milliseconds>",
help='Set frontend translation timeout (%(default)s)')
parser.add_argument('--offline', default=False, action="store_true",
help="Use offline")
args = parser.parse_args()
@ -35,7 +37,8 @@ def main():
debug=args.debug,
frontend_language_source=args.frontend_language_source,
frontend_language_target=args.frontend_language_target,
frontend_timeout=args.frontend_timeout)
frontend_timeout=args.frontend_timeout,
offline=args.offline)
if args.debug:
app.run(host=args.host, port=args.port)
else:

View file

@ -0,0 +1,36 @@
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url('../fonts/MaterialIcons-Regular.eot'); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url('../fonts/MaterialIcons-Regular.woff2') format('woff2'),
url('../fonts/MaterialIcons-Regular.woff') format('woff'),
url('../fonts/MaterialIcons-Regular.ttf') format('truetype');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}

13
app/static/css/materialize.min.css vendored Normal file

File diff suppressed because one or more lines are too long

1
app/static/css/prism.min.css vendored Normal file
View file

@ -0,0 +1 @@
code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

6
app/static/js/materialize.min.js vendored Normal file

File diff suppressed because one or more lines are too long

1
app/static/js/prism.min.js vendored Normal file

File diff suppressed because one or more lines are too long

6
app/static/js/vue@2.js Normal file

File diff suppressed because one or more lines are too long

View file

@ -15,11 +15,11 @@
<meta property="og:description" name="description" class="swiftype" content="Free and Open Source Machine Translation API. 100% self-hosted, no limits, no ties to proprietary services. Run your own API server in just a few minutes."/>
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script src="{% if offline %}{{ url_for('static', filename='js/vue@2.js') }}{% else %}https://cdn.jsdelivr.net/npm/vue@2{% endif %}"></script>
<!-- Compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/themes/prism.min.css" rel="stylesheet" />
<link rel="stylesheet" href="{% if offline %}{{ url_for('static', filename='css/materialize.min.css') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css{% endif %}">
<link href="{% if offline %}{{ url_for('static', filename='css/material-icons.css') }}{% else %}https://fonts.googleapis.com/icon?family=Material+Icons{% endif %}" rel="stylesheet">
<link href="{% if offline %}{{ url_for('static', filename='css/prism.min.css') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/themes/prism.min.css{% endif %}" rel="stylesheet" />
<style type="text/css">
textarea.materialize-textarea{height: 120px;}
@ -242,13 +242,13 @@
</div>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script src="{% if offline %}{{ url_for('static', filename='js/materialize.min.js') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js{% endif %}"></script>
<script>
window.Prism = window.Prism || {};
window.Prism.manual = true;
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/prism.min.js"></script>
<script src="{% if offline %}{{ url_for('static', filename='js/prism.min.js') }}{% else %}https://cdnjs.cloudflare.com/ajax/libs/prism/1.22.0/prism.min.js{% endif %}"></script>
<script>
// API host/endpoint