Skip to content

Commit

Permalink
feat: remove old web (#147)
Browse files Browse the repository at this point in the history
* feat: remove old web

* feat: remove robots.txt
  • Loading branch information
psincraian authored Jul 10, 2019
1 parent fbfa265 commit 5566d06
Show file tree
Hide file tree
Showing 24 changed files with 3 additions and 3,074 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<p align="center">
<img width="100px" alt="pepy-logo"
src="pepy/infrastructure/web/static/logo.png"
src="docs/logo.png"
/>
</p>
<p align="center">
Expand Down Expand Up @@ -42,7 +42,7 @@ The structure of the code is the following:
class like DB or BigQuery, the Flask web application, the container, and so on.
* `pepy/infrastructure/cli`: the command line programs.
* `pepy/infrastructure/container`: config files and the dependency injection manager.
* `pepy/infrastructure/web`: the Flask application with all the routes.
* `pepy/infrastructure/api`: the api endpoints controller.

## FAQ
**Where the downloads come from?**
Expand Down
File renamed without changes
56 changes: 1 addition & 55 deletions pepy/infrastructure/web/__init__.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,14 @@
import traceback
from datetime import datetime, timedelta
from flask import Flask, render_template, request, redirect, flash, send_from_directory, send_file, Response, url_for
from flask import Flask, request, Response

from pepy.application.command import UpdateDownloads
from pepy.domain.exception import DomainException
from pepy.domain.model import ProjectName, Password
from pepy.infrastructure import container
from pepy.infrastructure.api import api
from pepy.infrastructure.web._form import SearchForm

app = Flask(__name__)
app.config.from_object(container.config)
app.register_blueprint(api, url_prefix='/api')


@app.route("/", methods=["GET", "POST"])
def index_action():
form = SearchForm()
if form.validate_on_submit():
project_name = form.project_name.data
return redirect(url_for("project_action", project_name=project_name))
projects = container.project_provider.for_home()
return render_template("index.html", form=form, projects=projects)


@app.route("/count/<project_name>")
def count_action(project_name):
return redirect(url_for("project_action", project_name=project_name), 301)


@app.route("/project/<project_name>")
def project_action(project_name):
project = container.project_provider.find(project_name)
return render_template("project.html", project=project, downloads=project.last_downloads)


@app.route("/badge/<project_name>")
def badge_action(project_name):
badge = container.badge_query.generate_badge(project_name)
Expand All @@ -53,34 +27,6 @@ def badge_week_action(project_name):
return Response(badge.image, mimetype="image/svg+xml", headers={"Cache-Control": "max-age=86400"})


@app.route("/robots.txt")
def robots():
return send_from_directory(app.static_folder, request.path[1:])


@app.route("/task/update_downloads", methods=["POST"])
def update_downloads():
raw_date = request.args.get("date")
try:
if raw_date is not None:
date = datetime.strptime(raw_date, "%Y-%m-%d")
else:
date = datetime.now() - timedelta(days=1)
except ValueError:
return Response("Date format should be YYYY-mm-dd", 400)

password = request.args.get("password", "")
container.command_bus.publish(UpdateDownloads(date.date(), Password(password)))
return "Updated :-)"


@app.errorhandler(DomainException)
def handle_domain_exception(error: DomainException):
flash(error.message(), "danger")
url = request.referrer if request.referrer is not None else "/"
return redirect(url)


@app.errorhandler(Exception)
def handle_exception(error: Exception):
container.logger.critical(f"Error: {error} Traceback: \n {traceback.format_exc()}")
Expand Down
11 changes: 0 additions & 11 deletions pepy/infrastructure/web/_form.py

This file was deleted.

77 changes: 0 additions & 77 deletions pepy/infrastructure/web/gulpfile.js

This file was deleted.

18 changes: 0 additions & 18 deletions pepy/infrastructure/web/package.json

This file was deleted.

11 changes: 0 additions & 11 deletions pepy/infrastructure/web/static/css/pepy.css

This file was deleted.

1 change: 0 additions & 1 deletion pepy/infrastructure/web/static/css/pepy.min.css

This file was deleted.

Binary file removed pepy/infrastructure/web/static/favicon.ico
Binary file not shown.
4 changes: 0 additions & 4 deletions pepy/infrastructure/web/static/js/pepy.js

This file was deleted.

1 change: 0 additions & 1 deletion pepy/infrastructure/web/static/js/pepy.min.js

This file was deleted.

2 changes: 0 additions & 2 deletions pepy/infrastructure/web/static/robots.txt

This file was deleted.

3 changes: 0 additions & 3 deletions pepy/infrastructure/web/static/scss/_main.scss

This file was deleted.

12 changes: 0 additions & 12 deletions pepy/infrastructure/web/static/scss/_project.scss

This file was deleted.

2 changes: 0 additions & 2 deletions pepy/infrastructure/web/static/scss/pepy.scss

This file was deleted.

22 changes: 0 additions & 22 deletions pepy/infrastructure/web/static/twitter.svg

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5566d06

Please sign in to comment.