~martijnbraam/boarddb

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH 1/2] frontend/home: Add HTTP 404 page

Details
Message ID
<20220315104639.97563-1-raffaele.tranquillini@gmail.com>
DKIM signature
pass
Download raw message
Patch: +15 -2
Signed-off-by: Raffaele Tranquillini <raffaele.tranquillini@gmail.com>
---
 boarddb/frontend/home.py                 |  5 ++++-
 boarddb/static/css/component/layout.less |  2 +-
 boarddb/templates/404.html               | 10 ++++++++++
 3 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 boarddb/templates/404.html

diff --git a/boarddb/frontend/home.py b/boarddb/frontend/home.py
index 5b3f942..1a7f8a2 100644
--- a/boarddb/frontend/home.py
@@ -196,4 +196,7 @@ def home():
@blueprint_home.route('/board/<slug>')
def view(slug):
    board = Board.query.filter_by(slug=slug).first()
    return render_template('board.html', board=board)
\ No newline at end of file
    if board:
        return render_template('board.html', board=board)
    else:
        return render_template('404.html'), 404
\ No newline at end of file
diff --git a/boarddb/static/css/component/layout.less b/boarddb/static/css/component/layout.less
index 22c0bb8..c3cc059 100644
--- a/boarddb/static/css/component/layout.less
@@ -60,7 +60,7 @@ div.flashes {
  padding: 15px;
}

/* The header widget for board view */
// Header widget for the board view
.board-header {
  padding: 15px;
  display: grid;
diff --git a/boarddb/templates/404.html b/boarddb/templates/404.html
new file mode 100644
index 0000000..e8fa78a
--- /dev/null
@@ -0,0 +1,10 @@
{% extends "base.html" %}

{% block title %}Page Not Found{% endblock %}

{% block main %}

<h1>404 - Page Not Found</h1>
<p>Some board link might have changed. Try searching once again?</p>

{% endblock %}
\ No newline at end of file
-- 
2.35.1

[PATCH 2/2] templates/board: Add several parameters

Details
Message ID
<20220315104639.97563-2-raffaele.tranquillini@gmail.com>
In-Reply-To
<20220315104639.97563-1-raffaele.tranquillini@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Patch: +167 -16
Signed-off-by: Raffaele Tranquillini <raffaele.tranquillini@gmail.com>
---
 boarddb/templates/board.html | 183 ++++++++++++++++++++++++++++++++---
 1 file changed, 167 insertions(+), 16 deletions(-)

diff --git a/boarddb/templates/board.html b/boarddb/templates/board.html
index 5820011..e0cfc05 100644
--- a/boarddb/templates/board.html
@@ -33,6 +33,13 @@
                        </a>
                    </td>
                </tr>

                <tr>
                    <th>Model Code</th>
                    <td>
                        <tt>board id if any</tt>
                    </td>
                </tr>
                <tr>
                    <th>SoC</th>
                    <td>
@@ -205,23 +212,95 @@
                {% endif %}
            </table>
        </div>
        <!------- right column ------->
        <div class="extras">
            <h2>Physical Details</h2>
            (not 100% sure about this split)
            <table>
                {% if board.width and board.height %}
                <tr>
                    <th>Dimensions</th>
                    <td>
                        {{ board.width }}mm x {{ board.height }}mm
                        {% if board.depth %} x {{ board.depth }}mm{% endif %}
                    </td>
                </tr>
                <tr>
                    <th>Form Factor</th>
                    <td>
                        {{ board.formfactor_id }}
                    </td>
                </tr>
                <tr>
                    <th>Mounting holes</th>
                    <td>
                        {{ board.mounting_holes }}
                    </td>
                </tr>
                {% endif %}
                {% if board.weight %}
                <tr>
                    <th>Weight</th>
                    <td>
                        {{ board.weight }}g
                    </td>
                </tr>
                {% endif %}
                {% if board.temperature_min %}
                <tr>
                    <th>Temperature</th>
                    <td>
                        {{ board.temperature_min }}&deg;C to {{ board.temperature_max }}&deg;C
                    </td>
                </tr>
                {% endif %}
            </table>
            <h2>Software Support</h2>
            ...

            <h2>Availability</h2>
            ...stores?
            <table>
                <tr>
                    <th>Linux</th>
                    <td>
                        {{ board.software }}
                        {% if not board.mainline %}
                            <br>
                            <span style="color: green">Mainline Kernel</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <th>Android</th>
                    <td>
                        {{ board.software }}
                    </td>
                </tr>
                <tr>
                    <th>Windows</th>
                    <td>
                        {{ board.software }}
                    </td>
                </tr>
            </table>

            <h2>Certifications</h2>
            safety, e.g. CE, ROHS
            <br>
            others, e.g. form factors (96boards and so on)
            can be a JSON col?
            <table>
                <tr>
                    <th>Conformity</th>
                    <td>
                        CE, FCC, RoHS, etc.
                    </td>
                </tr>
                <tr>
                    <th>96boards</th>
                    <td>
                        ...
                    </td>
                </tr>
            </table>
            
            <h2>Datasheets</h2>
            this would be extremely cool but not easy to implement
            <button>Add link</button>
            <br>
            <strong>⚠️ These are external links! Act with care!</strong>
            <h2>Datasheets </h2>
            {% if board.ext_links %}
            <strong>⚠️ These are external links! Act with care!</strong> 
            <ul>
                <li>
                    Board schematics <a href="1">
@@ -234,10 +313,82 @@
                    </a>
                </li>
            </ul>
            <h2>Physical details</h2>
            dimensions, weight, operating temperature, etc.
            <h2>whatever other extra section</h2>
            recommendations of similar boards, comments, etc
            {% else %}
            <i>No links were added yet.</i>
            {% endif %}
            <div class="collapse">
                <input type="checkbox" id="collapse-link" class="collapse">
                <div class="collapsible">
                    <form method="post" id="add-link-form">
                        Paywalled or spammy links will be deleted.
                        <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
                        <input type="hidden" name="action" value="add_link">
                        <input type="text" name="url" placeholder="URL">
                        <input type="text" name="desc" placeholder="Description (datasheet, schematics, ...)">
                        <button type="submit">Send Suggestion</button>
                    </form>
                </div>
                <label class="collapse" for="collapse-link">Add Link</label>
            </div>


            <h2>Availability</h2>
            <ul>
                <li>Official Website (quote only)</li>
                <li>Amazon</li>
                <li>AliExpress</li>
            </ul>
            
            
            <h2>Similar Boards / See Also</h2>
            (just a stub)
            <div class="grid" style="
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;">
                <div class="card" style="
                flex: 1 1 auto;
                margin: 0.5rem; text-align: center;">
                    <img src="{{ url_for('static', filename='images/') }}{{ board.id }}.jpg" style="width: 100px; height: 100px;">
                    <br>
                    <a href="1">
                        Raspberry Pi Zero 2W
                    </a>
                </div>
                <div class="card" style="
                flex: 1 1 auto;
                margin: 0.5rem; text-align: center">
                    <img src="{{ url_for('static', filename='images/') }}{{ board.id }}.jpg" style="width: 100px; height: 100px;">
                    <br>
                    <a href="1">
                        SomeBoard_2GB
                    </a>
                </div>
                <div class="card" style="
                    flex: 1 1 auto;
                    margin: 0.5rem; text-align: center">
                    <img src="{{ url_for('static', filename='images/') }}{{ board.id }}.jpg" style="width: 100px; height: 100px;">
                    <br>
                    <a href="1">
                        {{ board.name }}
                    </a>
                </div>

            </div>
        </div>
    </main>
    <!-- TODO: i'd centralize the general helper functions in one script for the whole site? -->
    <script>
        document.addEventListener('DOMContentLoaded', function () {
            // Hide fallback (non-JS) elements
            fallbackElements = document.getElementsByClassName("js-hide");
            Array.from(fallbackElements).forEach(element => {
                element.style.display = "none";
            });
            fallbackElements = document.getElementsByClassName("js-show");
            Array.from(fallbackElements).forEach(element => {
                element.style.display = "block";
            });
        });
    </script>
{% endblock %}
\ No newline at end of file
-- 
2.35.1
Details
Message ID
<668d09cc-c1d8-cc87-82b8-e4f96d387662@brixit.nl>
In-Reply-To
<20220315104639.97563-1-raffaele.tranquillini@gmail.com> (view parent)
DKIM signature
missing
Download raw message
I've changed the 404 handler into a global one so it just works when you 
abort(404) anywhere :)

On 3/15/22 11:46, Raffaele Tranquillini wrote:
> Signed-off-by: Raffaele Tranquillini <raffaele.tranquillini@gmail.com>
> ---
>   boarddb/frontend/home.py                 |  5 ++++-
>   boarddb/static/css/component/layout.less |  2 +-
>   boarddb/templates/404.html               | 10 ++++++++++
>   3 files changed, 15 insertions(+), 2 deletions(-)
>   create mode 100644 boarddb/templates/404.html
>
> diff --git a/boarddb/frontend/home.py b/boarddb/frontend/home.py
> index 5b3f942..1a7f8a2 100644
> --- a/boarddb/frontend/home.py
> +++ b/boarddb/frontend/home.py
> @@ -196,4 +196,7 @@ def home():
>   @blueprint_home.route('/board/<slug>')
>   def view(slug):
>       board = Board.query.filter_by(slug=slug).first()
> -    return render_template('board.html', board=board)
> \ No newline at end of file
> +    if board:
> +        return render_template('board.html', board=board)
> +    else:
> +        return render_template('404.html'), 404
> \ No newline at end of file
> diff --git a/boarddb/static/css/component/layout.less b/boarddb/static/css/component/layout.less
> index 22c0bb8..c3cc059 100644
> --- a/boarddb/static/css/component/layout.less
> +++ b/boarddb/static/css/component/layout.less
> @@ -60,7 +60,7 @@ div.flashes {
>     padding: 15px;
>   }
>   
> -/* The header widget for board view */
> +// Header widget for the board view
>   .board-header {
>     padding: 15px;
>     display: grid;
> diff --git a/boarddb/templates/404.html b/boarddb/templates/404.html
> new file mode 100644
> index 0000000..e8fa78a
> --- /dev/null
> +++ b/boarddb/templates/404.html
> @@ -0,0 +1,10 @@
> +{% extends "base.html" %}
> +
> +{% block title %}Page Not Found{% endblock %}
> +
> +{% block main %}
> +
> +<h1>404 - Page Not Found</h1>
> +<p>Some board link might have changed. Try searching once again?</p>
> +
> +{% endblock %}
> \ No newline at end of file
Reply to thread Export thread (mbox)