[odrs-web] Rebase master to what is going to be oscp-dev



commit 0d6829f822f5c0704f403826ae5b13d0c47f03a4
Author: Andrea Veri <averi redhat com>
Date:   Wed Nov 14 14:45:21 2018 +0100

    Rebase master to what is going to be oscp-dev

 Dockerfile                                         |  29 +++++++++++++++
 LICENSE => app_data/LICENSE                        |   0
 MAINTAINERS => app_data/MAINTAINERS                |   0
 README.md => app_data/README.md                    |   0
 {app => app_data/app}/__init__.py                  |   0
 {app => app_data/app}/db.py                        |   3 +-
 {app => app_data/app}/models.py                    |   0
 {app => app_data/app}/static/Chart.js              |   0
 {app => app_data/app}/static/app-page.png          | Bin
 {app => app_data/app}/static/bar.png               | Bin
 {app => app_data/app}/static/favicon.ico           | Bin
 {app => app_data/app}/static/foot.png              | Bin
 {app => app_data/app}/static/general_bg.png        | Bin
 {app => app_data/app}/static/general_separator.png | Bin
 {app => app_data/app}/static/gnome-16.png          | Bin
 {app => app_data/app}/static/gnome-odrs.png        | Bin
 {app => app_data/app}/static/layout.css            |   0
 {app => app_data/app}/static/review-submit.png     | Bin
 {app => app_data/app}/static/robots.txt            |   0
 {app => app_data/app}/static/search-icon.png       | Bin
 {app => app_data/app}/static/style.css             |   0
 {app => app_data/app}/static/t.png                 | Bin
 {app => app_data/app}/static/top_bar-bg.png        | Bin
 {app => app_data/app}/templates/default.html       |   0
 {app => app_data/app}/templates/delete.html        |   0
 {app => app_data/app}/templates/distros.html       |   0
 {app => app_data/app}/templates/error.html         |   0
 {app => app_data/app}/templates/graph-month.html   |   0
 {app => app_data/app}/templates/graph-year.html    |   0
 {app => app_data/app}/templates/index.html         |   0
 {app => app_data/app}/templates/login.html         |   0
 {app => app_data/app}/templates/modadmin.html      |   0
 {app => app_data/app}/templates/mods.html          |   0
 {app => app_data/app}/templates/oars.html          |   0
 {app => app_data/app}/templates/privacy.html       |   0
 {app => app_data/app}/templates/show-all.html      |   0
 {app => app_data/app}/templates/show.html          |   0
 {app => app_data/app}/templates/stats.html         |   0
 {app => app_data/app}/templates/users.html         |   0
 {app => app_data/app}/views.py                     |   2 +-
 {app => app_data/app}/views_admin.py               |   2 +-
 cron.py => app_data/cron.py                        |   0
 flaskapp.py => app_data/flaskapp.py                |   0
 app_data/odrs-web.doap                             |  28 ++++++++++++++
 schema.sql => app_data/schema.sql                  |   0
 odrs.wsgi => app_data/wsgi-scripts/odrs.wsgi       |   4 +-
 entrypoint.sh                                      |   8 ++++
 odrs.cron                                          |   1 +
 odrs.gnome.org.conf                                |  41 +++++++++++++++++++++
 49 files changed, 113 insertions(+), 5 deletions(-)
---
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..344660a
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,29 @@
+FROM centos/httpd-24-centos7 
+
+USER root 
+
+RUN yum update -y
+RUN yum install gcc make python27-python python27-python-pip python27-mod_wsgi python27-python-devel 
python2-cryptography python-flask python2-flask-wtf python2-flask-login python2-PyMySQL crontab -y
+
+ENV ODRS_HOME=/opt/app-root/src \
+    LANG=C
+
+WORKDIR ${ODRS_HOME}
+
+COPY app_data ${ODRS_HOME}
+
+COPY odrs.gnome.org.conf /etc/httpd/conf.d/odrs.gnome.org.conf
+RUN rm /etc/httpd/conf.d/welcome.conf
+
+RUN python /opt/app-root/src/cron.py ratings /opt/app-root/src/app/static/ratings.json 
+COPY odrs.cron /etc/cron.d/odrs
+
+RUN chown -R 1000310000:0 ${ODRS_HOME} && \
+    chmod -R 664 ${ODRS_HOME} && \
+    find ${ODRS_HOME} -type d -exec chmod 775 {} +
+
+COPY entrypoint.sh /usr/local/bin
+EXPOSE 8443
+
+USER 1001 
+ENTRYPOINT ["entrypoint.sh"]
diff --git a/LICENSE b/app_data/LICENSE
similarity index 100%
rename from LICENSE
rename to app_data/LICENSE
diff --git a/MAINTAINERS b/app_data/MAINTAINERS
similarity index 100%
rename from MAINTAINERS
rename to app_data/MAINTAINERS
diff --git a/README.md b/app_data/README.md
similarity index 100%
rename from README.md
rename to app_data/README.md
diff --git a/app/__init__.py b/app_data/app/__init__.py
similarity index 100%
rename from app/__init__.py
rename to app_data/app/__init__.py
diff --git a/app/db.py b/app_data/app/db.py
similarity index 99%
rename from app/db.py
rename to app_data/app/db.py
index aef2df7..547f256 100644
--- a/app/db.py
+++ b/app_data/app/db.py
@@ -38,7 +38,8 @@ def _create_review(e):
     review.user_display = e[11]
     review.rating = int(e[12])
     if e[13]:
-        review.date_deleted = int(e[13].strftime("%s"))
+        if e[13] != '0000-00-00 00:00:00':
+            review.date_deleted = int(e[13].strftime("%s"))
     review.reported = int(e[14])
     return review
 
diff --git a/app/models.py b/app_data/app/models.py
similarity index 100%
rename from app/models.py
rename to app_data/app/models.py
diff --git a/app/static/Chart.js b/app_data/app/static/Chart.js
similarity index 100%
rename from app/static/Chart.js
rename to app_data/app/static/Chart.js
diff --git a/app/static/app-page.png b/app_data/app/static/app-page.png
similarity index 100%
rename from app/static/app-page.png
rename to app_data/app/static/app-page.png
diff --git a/app/static/bar.png b/app_data/app/static/bar.png
similarity index 100%
rename from app/static/bar.png
rename to app_data/app/static/bar.png
diff --git a/app/static/favicon.ico b/app_data/app/static/favicon.ico
similarity index 100%
rename from app/static/favicon.ico
rename to app_data/app/static/favicon.ico
diff --git a/app/static/foot.png b/app_data/app/static/foot.png
similarity index 100%
rename from app/static/foot.png
rename to app_data/app/static/foot.png
diff --git a/app/static/general_bg.png b/app_data/app/static/general_bg.png
similarity index 100%
rename from app/static/general_bg.png
rename to app_data/app/static/general_bg.png
diff --git a/app/static/general_separator.png b/app_data/app/static/general_separator.png
similarity index 100%
rename from app/static/general_separator.png
rename to app_data/app/static/general_separator.png
diff --git a/app/static/gnome-16.png b/app_data/app/static/gnome-16.png
similarity index 100%
rename from app/static/gnome-16.png
rename to app_data/app/static/gnome-16.png
diff --git a/app/static/gnome-odrs.png b/app_data/app/static/gnome-odrs.png
similarity index 100%
rename from app/static/gnome-odrs.png
rename to app_data/app/static/gnome-odrs.png
diff --git a/app/static/layout.css b/app_data/app/static/layout.css
similarity index 100%
rename from app/static/layout.css
rename to app_data/app/static/layout.css
diff --git a/app/static/review-submit.png b/app_data/app/static/review-submit.png
similarity index 100%
rename from app/static/review-submit.png
rename to app_data/app/static/review-submit.png
diff --git a/app/static/robots.txt b/app_data/app/static/robots.txt
similarity index 100%
rename from app/static/robots.txt
rename to app_data/app/static/robots.txt
diff --git a/app/static/search-icon.png b/app_data/app/static/search-icon.png
similarity index 100%
rename from app/static/search-icon.png
rename to app_data/app/static/search-icon.png
diff --git a/app/static/style.css b/app_data/app/static/style.css
similarity index 100%
rename from app/static/style.css
rename to app_data/app/static/style.css
diff --git a/app/static/t.png b/app_data/app/static/t.png
similarity index 100%
rename from app/static/t.png
rename to app_data/app/static/t.png
diff --git a/app/static/top_bar-bg.png b/app_data/app/static/top_bar-bg.png
similarity index 100%
rename from app/static/top_bar-bg.png
rename to app_data/app/static/top_bar-bg.png
diff --git a/app/templates/default.html b/app_data/app/templates/default.html
similarity index 100%
rename from app/templates/default.html
rename to app_data/app/templates/default.html
diff --git a/app/templates/delete.html b/app_data/app/templates/delete.html
similarity index 100%
rename from app/templates/delete.html
rename to app_data/app/templates/delete.html
diff --git a/app/templates/distros.html b/app_data/app/templates/distros.html
similarity index 100%
rename from app/templates/distros.html
rename to app_data/app/templates/distros.html
diff --git a/app/templates/error.html b/app_data/app/templates/error.html
similarity index 100%
rename from app/templates/error.html
rename to app_data/app/templates/error.html
diff --git a/app/templates/graph-month.html b/app_data/app/templates/graph-month.html
similarity index 100%
rename from app/templates/graph-month.html
rename to app_data/app/templates/graph-month.html
diff --git a/app/templates/graph-year.html b/app_data/app/templates/graph-year.html
similarity index 100%
rename from app/templates/graph-year.html
rename to app_data/app/templates/graph-year.html
diff --git a/app/templates/index.html b/app_data/app/templates/index.html
similarity index 100%
rename from app/templates/index.html
rename to app_data/app/templates/index.html
diff --git a/app/templates/login.html b/app_data/app/templates/login.html
similarity index 100%
rename from app/templates/login.html
rename to app_data/app/templates/login.html
diff --git a/app/templates/modadmin.html b/app_data/app/templates/modadmin.html
similarity index 100%
rename from app/templates/modadmin.html
rename to app_data/app/templates/modadmin.html
diff --git a/app/templates/mods.html b/app_data/app/templates/mods.html
similarity index 100%
rename from app/templates/mods.html
rename to app_data/app/templates/mods.html
diff --git a/app/templates/oars.html b/app_data/app/templates/oars.html
similarity index 100%
rename from app/templates/oars.html
rename to app_data/app/templates/oars.html
diff --git a/app/templates/privacy.html b/app_data/app/templates/privacy.html
similarity index 100%
rename from app/templates/privacy.html
rename to app_data/app/templates/privacy.html
diff --git a/app/templates/show-all.html b/app_data/app/templates/show-all.html
similarity index 100%
rename from app/templates/show-all.html
rename to app_data/app/templates/show-all.html
diff --git a/app/templates/show.html b/app_data/app/templates/show.html
similarity index 100%
rename from app/templates/show.html
rename to app_data/app/templates/show.html
diff --git a/app/templates/stats.html b/app_data/app/templates/stats.html
similarity index 100%
rename from app/templates/stats.html
rename to app_data/app/templates/stats.html
diff --git a/app/templates/users.html b/app_data/app/templates/users.html
similarity index 100%
rename from app/templates/users.html
rename to app_data/app/templates/users.html
diff --git a/app/views.py b/app_data/app/views.py
similarity index 99%
rename from app/views.py
rename to app_data/app/views.py
index 8231dec..831f606 100644
--- a/app/views.py
+++ b/app_data/app/views.py
@@ -165,7 +165,7 @@ def oars_index():
 @app.route('/<path:resource>')
 def static_resource(resource):
     """ Return a static image or resource """
-    return send_from_directory('static/', os.path.basename(resource))
+    return send_from_directory("%s/app/static/" % os.environ['HOME'], os.path.basename(resource))
 
 @app.errorhandler(400)
 def json_error(msg=None, errcode=400):
diff --git a/app/views_admin.py b/app_data/app/views_admin.py
similarity index 99%
rename from app/views_admin.py
rename to app_data/app/views_admin.py
index 956e58a..f2a6672 100644
--- a/app/views_admin.py
+++ b/app_data/app/views_admin.py
@@ -411,7 +411,7 @@ def admin_show_unmoderated():
     try:
         db = get_db()
         reviews_all = db.reviews.get_all()
-    except CursorError as e:
+    except Exception as e:
         return _error_internal(str(e))
     user_hash = _get_hash_for_user(current_user)
     if not user_hash:
diff --git a/cron.py b/app_data/cron.py
similarity index 100%
rename from cron.py
rename to app_data/cron.py
diff --git a/flaskapp.py b/app_data/flaskapp.py
similarity index 100%
rename from flaskapp.py
rename to app_data/flaskapp.py
diff --git a/app_data/odrs-web.doap b/app_data/odrs-web.doap
new file mode 100644
index 0000000..dbb399b
--- /dev/null
+++ b/app_data/odrs-web.doap
@@ -0,0 +1,28 @@
+<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#";
+         xmlns:foaf="http://xmlns.com/foaf/0.1/";
+         xmlns:gnome="http://api.gnome.org/doap-extensions#";
+         xmlns="http://usefulinc.com/ns/doap#";>
+  <name>Open Desktop Review Server Web Site</name>
+  <shortname>odrs-web</shortname>
+  <shortdesc>Open Desktop Review Server</shortdesc>
+
+  <homepage rdf:resource="http://odrs.gnome.org"/>
+  <category rdf:resource="http://api.gnome.org/doap-extensions#infrastructure"; />
+
+  <programming-language>python</programming-language>
+  <description xml:lang="en">
+   A Flask web service for submitting application reviews.
+  </description>
+
+  <maintainer>
+    <foaf:Person>
+      <foaf:name>Richard Hughes</foaf:name>
+      <foaf:mbox rdf:resource="mailto:richard hughsie com" />
+      <foaf:homepage rdf:resource="http://www.hughsie.com/"; />
+      <gnome:userid>rhughes</gnome:userid>
+    </foaf:Person>
+  </maintainer>
+
+  <license rdf:resource="http://www.gnu.org/licenses/gpl-2.0.txt"; />
+</Project>
diff --git a/schema.sql b/app_data/schema.sql
similarity index 100%
rename from schema.sql
rename to app_data/schema.sql
diff --git a/odrs.wsgi b/app_data/wsgi-scripts/odrs.wsgi
similarity index 85%
rename from odrs.wsgi
rename to app_data/wsgi-scripts/odrs.wsgi
index 855747a..3f97df7 100644
--- a/odrs.wsgi
+++ b/app_data/wsgi-scripts/odrs.wsgi
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/python2
 # -*- coding: utf-8 -*-
 #
 # Copyright (C) 2016 Richard Hughes <richard hughsie com>
@@ -7,7 +7,7 @@
 import sys
 import os
 
-sys.path.insert(0, os.path.join(os.environ['HOME'], 'html'))
+sys.path.insert(0, os.environ['ODRS_HOME'])
 
 def application(environ, start_response):
     for key in ['MYSQL_DB_HOST',
diff --git a/entrypoint.sh b/entrypoint.sh
new file mode 100755
index 0000000..023ca37
--- /dev/null
+++ b/entrypoint.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+sed -i "s/replace_odrs_secret/${ODRS_REVIEWS_SECRET}/" /etc/httpd/conf.d/odrs.gnome.org.conf
+sed -i "s/replace_odrs_username/${MYSQL_DB_USERNAME}/" /etc/httpd/conf.d/odrs.gnome.org.conf
+sed -i "s/replace_odrs_password/${MYSQL_DB_PASSWORD}/" /etc/httpd/conf.d/odrs.gnome.org.conf
+sed -i "s/replace_odrs_host/${MYSQL_DB_HOST}/" /etc/httpd/conf.d/odrs.gnome.org.conf
+
+exec /usr/bin/run-httpd
diff --git a/odrs.cron b/odrs.cron
new file mode 100644
index 0000000..8adf48e
--- /dev/null
+++ b/odrs.cron
@@ -0,0 +1 @@
+59 23 * * * python /opt/app-root/src/cron.py ratings /opt/app-root/src/app/static/ratings.json
diff --git a/odrs.gnome.org.conf b/odrs.gnome.org.conf
new file mode 100644
index 0000000..bd81e9c
--- /dev/null
+++ b/odrs.gnome.org.conf
@@ -0,0 +1,41 @@
+<VirtualHost *:8443>
+    ServerName  odrs.gnome.org 
+    DocumentRoot /opt/app-root/src
+
+    SSLEngine on
+    SSLProtocol All -SSLv2 -SSLv3
+    SSLCertificateFile /var/serving-cert/tls.crt
+    SSLCertificateKeyFile /var/serving-cert/tls.key
+
+    Alias /static/ /opt/app-root/src/app/static
+    Alias /1.0/reviews/api/ratings /opt/app-root/src/app/static/ratings.json
+
+    WSGIDaemonProcess odrs.gnome.org processes=10 threads=15 maximum-requests=100
+    WSGIProcessGroup odrs.gnome.org
+
+    WSGIScriptAlias / /opt/app-root/src/wsgi-scripts/odrs.wsgi
+
+    SetEnv ODRS_REVIEWS_SECRET replace_odrs_secret
+    SetEnv MYSQL_DB_USERNAME replace_odrs_username
+    SetEnv MYSQL_DB_PASSWORD replace_odrs_password
+    SetEnv MYSQL_DB_HOST replace_odrs_host
+
+    <Location /static/>
+        ExpiresActive On
+        ExpiresByType image/png "access plus 1 week"
+        ExpiresByType application/javascript "access plus 1 week"
+        ExpiresByType text/javascript "access plus 1 week"
+        ExpiresByType text/css "access plus 1 day"
+        Header set Cache-Control "public"
+    </Location>
+</VirtualHost>
+
+<Directory "/opt/app-root/src/app/static">
+  AllowOverride None
+
+  Require all granted
+</Directory>
+
+<Directory "/opt/app-root/src/wsgi-scripts">
+  Require all granted
+</Directory>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]