GithubHelp home page GithubHelp logo

openttd / bananas-frontend-web Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 6.0 234 KB

Front-end to the BaNaNaS API

License: GNU General Public License v2.0

Makefile 0.34% Python 28.95% HTML 51.75% Dockerfile 1.67% JavaScript 10.27% CSS 7.02%

bananas-frontend-web's Introduction

BaNaNaS web front-end

GitHub License

This is a front-end for browsing and upload content to OpenTTD's content service, called BaNaNaS. It works together with bananas-api, which serves the HTTP API.

See introduction.md for more documentation about the different BaNaNaS components and how they work together.

Development

This front-end is written in Python 3.7 with Flask.

Usage

To start it, you are advised to first create a virtualenv:

npm install
python3 -m venv .env
.env/bin/pip install -r requirements.txt

After this, you can run the flask application by running:

make run

Running via docker

docker build -t openttd/bananas-frontend-web:local .
docker run --rm -p 127.0.0.1:5000:80 openttd/bananas-frontend-web:local

bananas-frontend-web's People

Contributors

auge8472 avatar dependabot[bot] avatar frosch123 avatar glx22 avatar james103 avatar pyup-bot avatar spnda avatar truebrain avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bananas-frontend-web's Issues

Map enums from API to nice looking user-readable values.

The frontend displays enums from the API as it.

Add mappings between api-enum and user-enums:

  • Content type: "ai-library" -- "AI Library"
  • Availability: "new-games" -- "New games"
  • Compatibilty branches: "master" -- "Official branch"

Licenses are probably good enough. "Creative Commons" would be too long in tables.

Handle multiple requests in parallel

Currently the frontend can only handle one request at a time, while waiting for the API.

Two solutions:

  • Make the front-end really state-less, so multiple instances can run in parallel. That is, store all session information in cookies. However, don't use Flask's default sessions. While they sign the data to prevent modification, they still expose somewhat-secrets like the API tokens. Encrypt the data instead.
  • Reimplement the frontend with aiohttp.

No link to upload new package from the package overview

If you are at for example
http:///manager/base-graphics/4f474658

There is no longer to "upload update".

You have to go back to Manager to find that link. Possibly it might be good to add it in the package overview too.

Bananas re-starting file-upload when uploading an update

Currently BaNaNas loops file uploads when trying to update existing .grf's in the database.

After ticking the Terms of Service box and uploading the file, the upload starts. Once the upload hits 100%, it takes a short break and re-starts from 0%.

The issue occurs with latest Firefox and Edge browsers. The .grf has been compiled twice and uploaded. Also occurs when the .grf is packed into a zip-file before.

UndefinedError: 'dict object' has no attribute 'description'

Sentry Issue: BANANAS-FRONTEND-WEB-1

UndefinedError: 'dict object' has no attribute 'description'
(13 additional frame(s) were not displayed)
...
  File "jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/code/webclient/templates/manager_package_info.html", line 1, in top-level template code
    {% extends 'base.html' %}
  File "/code/webclient/templates/base.html", line 37, in top-level template code
    {% block content %}{% endblock %}
  File "/code/webclient/templates/manager_package_info.html", line 35, in block "content"
    {% for l in package["description"].splitlines() %}
  File "jinja2/environment.py", line 471, in getattr
    return getattr(obj, attribute)

Exception on /manager/base-graphics/4f474658 [GET]

RuntimeError: dictionary changed size during iteration

Sentry Issue: BANANAS-FRONTEND-WEB-2

RuntimeError: dictionary changed size during iteration
(4 additional frame(s) were not displayed)
...
  File "flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "webclient/pages/login.py", line 22, in login
    session = start_session()
  File "webclient/session.py", line 101, in start_session
    cleanup_sessions()
  File "webclient/session.py", line 95, in cleanup_sessions
    for sid, session in _sessions.items():

Exception on /login [GET]

Can't download any packages using the website; therefore, there is misleading info on the front page.

<li> For downloading content, prefer using OpenTTD's build-in content downloader. But packages are also available for download on this page. </li>

Expected result

The above line should instead read as follows: For downloading content, please use OpenTTD's built-in content downloader.

Actual result

The front page includes a line saying that packages are available for download on the website. However, no packages are available for direct download when using the website, whether the content is for new-games or savegames-only.

Wrong "upload update" link in manager package info

In manager package info there is <a href="/manager/new-package">Upload update</a>
But in manager package list it is <a href="/manager/new-package?unique-id={{ package["unique-id"] }}">Upload update</a> (and there's also <a href="/manager/new-package">Upload new content</a>)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.