Skip to content

Commit

Permalink
Fix favicon and update js/css libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Jan 12, 2023
1 parent a12368a commit cc0cef2
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 45 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

## What is ResultsDB

ResultsDB is a results store engine for (not only) Fedora QA tools. The API
documentation can be found at <http://docs.resultsdb20.apiary.io/>.
ResultsDB is a results store engine for (not only) Fedora QA tools.

The API v2 documentation can be found at
<http://docs.resultsdb20.apiary.io/>.

## Repositories

Expand Down
11 changes: 10 additions & 1 deletion resultsdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import logging.config as logging_config
import os

from flask import Flask, jsonify, session
from flask import Flask, current_app, jsonify, send_from_directory, session
from flask_pyoidc import OIDCAuthentication
from flask_pyoidc.provider_configuration import (
ClientMetadata,
Expand Down Expand Up @@ -111,6 +111,7 @@ def create_app(config_obj=None):

app.register_blueprint(main)
app.register_blueprint(api_v2, url_prefix="/api/v2.0")
app.add_url_rule("/favicon.png", view_func=favicon)

if app.config["AUTH_MODULE"] == "oidc":
app.logger.info("OpenIDConnect authentication is enabled")
Expand Down Expand Up @@ -232,3 +233,11 @@ def logout():
app.oidc = oidc

create_endpoints(oidc, provider)


def favicon():
return send_from_directory(
os.path.join(current_app.root_path, "static"),
"favicon.png",
mimetype="image/png",
)
11 changes: 7 additions & 4 deletions resultsdb/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ body > .container {
padding-bottom: 30px;
}

.navbar {
padding: .75rem 0;
}

/* consider navbar when jumping to sections */
section::before {
display: block;
Expand All @@ -35,3 +31,10 @@ section::before {
.param {
font-weight: bold;
}

pre {
background-color: var(--bs-light);
padding: 1em;
margin: 0.5em;
border: 1px solid var(--bs-border-color);
}
Binary file removed resultsdb/static/favicon.ico
Binary file not shown.
Binary file added resultsdb/static/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 9 additions & 12 deletions resultsdb/templates/api_v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ <h1>ResultsDB API v3</h1>

<p>This is API reference for ResultsDB REST API v3.</p>

Index:

<h4>Index</h4>
<p><ul>
<li><a href="#authentication">Authentication</a></li>
{% for endpoint in endpoints %}
Expand Down Expand Up @@ -35,37 +34,35 @@ <h2>
following Python code:
</p>

<pre>
import requests

<pre><code class="language-python" data-lang="python">import requests
import requests_gssapi

session = requests.Session()
session.auth = requests_gssapi.HTTPKerberosAuth(mutual_authentication=requests_gssapi.OPTIONAL)
response = session.get("{{ url_for("login", _external=True) }}")
response.raise_for_status()
token = response.json()["token"]
</pre>
</code></pre>

<p>
To publish a test result, pass the token to the "Authorization" HTTP header
in POST requests:
</p>

<pre>
response = session.post(
<pre><code>response = session.post(
"{{ url_for("api_v3.results_brew-builds", _external=True) }}",
headers={"Authorization": f"Bearer {token}"},
json=test_result_data,
)
response.raise_for_status()
</pre>
</code></pre>

<p>Similar POST request with curl:</p>

<pre>
curl --json "$test_result_data" -H "Authorization: Bearer $token" \
<pre><code>curl --json "$test_result_data" -H "Authorization: Bearer $token" \
{{ url_for("api_v3.results_brew-builds", _external=True) }}
</pre>
</code></pre>
</section>

{% for endpoint in endpoints %}
Expand All @@ -83,7 +80,7 @@ <h2>

{% if endpoint.example %}
<h3>Example</h3>
<pre>{{ endpoint.example }}</pre>
<pre><code>{{ endpoint.example }}</code></pre>
{% endif %}

<h3>{{ type }} Parameters</h3>
Expand Down
8 changes: 7 additions & 1 deletion resultsdb/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

{% block body %}

API documentation can be found <a href="http://docs.resultsdb20.apiary.io/">here</a>.
<p>ResultsDB is a results store engine for (not only) Fedora QA tools.</p>

<h4>Documentation</h4>
<ul>
<li><a href="{{ url_for('api_v3.index') }}">API v3</a></li>
<li><a href="http://docs.resultsdb20.apiary.io/">API v2</a></li>
</ul>

{% endblock %}
55 changes: 30 additions & 25 deletions resultsdb/templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Web view on review-rot output.">

<link rel="icon" href="{{ url_for('favicon') }}" />

<title>{{ title|default('ResultsDB') }}</title>

<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">

<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}">
</head>

<body>

<header class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand"><strong>ResultsDB</strong></span>
</div>
<div class="navbar-collapse collapse">

<ul class="nav navbar-nav">
<li><a href="{{ url_for('api_v2.get_groups') }}">Groups</a></li>
<li><a href="{{ url_for('api_v2.get_results') }}">Results</a></li>
<li><a href="{{ url_for('api_v2.get_testcases') }}">Testcases</a></li>
<li><a href="{{ url_for('api_v3.index') }}">API v3</a></li>
<nav class="navbar navbar-expand-lg bg-light fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="/">
<img src="{{ url_for('favicon') }}" width="32" height="32" class="d-inline-block">
<strong>ResultsDB</strong>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link" href="{{ url_for('api_v2.get_groups') }}">Groups</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('api_v2.get_results') }}">Results</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('api_v2.get_testcases') }}">Testcases</a></li>
<li class="nav-item">
<a class="nav-link {% if request.endpoint == 'api_v3.index' %}active{% endif %}" href="{{ url_for('api_v3.index') }}">API v3</a>
</li>
</ul>

</div><!--/.nav-collapse -->
</div><!--/.container -->
</header><!--/.navbar -->
</div>
</div>
</nav>

<main class="container">

Expand All @@ -45,15 +50,15 @@
{% endfor %}

{% block body %}
<h1> My First Flask Application! </h1>
{% endblock %}

</main>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.4.1/dist/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>

<!-- Bootstrap -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>

{% if config['FEDMENU_URL'] is defined %}
<script src="{{ config['FEDMENU_URL'] }}/js/fedmenu.js"></script>
Expand Down

0 comments on commit cc0cef2

Please sign in to comment.