Add admin panel to delete URLs from the browser. Add copyright notice.
This commit is contained in:
		
							parent
							
								
									332d82e97a
								
							
						
					
					
						commit
						8288b3624e
					
				
					 11 changed files with 445 additions and 75 deletions
				
			
		
							
								
								
									
										100
									
								
								templates/admin.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										100
									
								
								templates/admin.html
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,100 @@
 | 
			
		|||
<!--
 | 
			
		||||
Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
 | 
			
		||||
This file is part of liteshort by 132ikl
 | 
			
		||||
This software is license under the MIT license. It should be included in your copy of this software.
 | 
			
		||||
A copy of the MIT license can be obtained at https://mit-license.org/
 | 
			
		||||
-->
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="UTF-8">
 | 
			
		||||
    <title>URL Admin - {{ config.site_name }}</title>
 | 
			
		||||
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
 | 
			
		||||
    <link rel="stylesheet" href="{{ url_for('static', filename='ia.css') }}">
 | 
			
		||||
    <link rel="stylesheet" href="{{ url_for('static', filename='admin.css') }}">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
    <div id="top">
 | 
			
		||||
        <div id="header">
 | 
			
		||||
            <div id="logo" class="drop-shadow">
 | 
			
		||||
                <a href="{{ url_for('main') }}">
 | 
			
		||||
                    <img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
 | 
			
		||||
                </a>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div id="title" class="drop-shadow">
 | 
			
		||||
                <a href="{{ url_for('main') }}">
 | 
			
		||||
                    I.C.T.S.V. URL Shortener
 | 
			
		||||
                </a>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div id="middle">
 | 
			
		||||
        <div id="content_admin">
 | 
			
		||||
            <div class="clearfix"></div>
 | 
			
		||||
            <div id="box" class="align-self-center col-xl-4 col-lg-4 col-md-6 col-sm-10 col-xs-12">
 | 
			
		||||
                <h3 id="box-title">URL Admin <span class="small">(<a href="{{ url_for('logout') }}">Logout</a>)</span></h3>
 | 
			
		||||
 | 
			
		||||
                {% with messages = get_flashed_messages(with_categories=true) %}
 | 
			
		||||
                    {% if messages %}
 | 
			
		||||
                        {% for category, message in messages %}
 | 
			
		||||
                            {% if category == 'success' %}
 | 
			
		||||
                            <div class="success">
 | 
			
		||||
                                ✓ {{ message }}
 | 
			
		||||
                            </div>
 | 
			
		||||
                            {% elif category == 'error' %}
 | 
			
		||||
                            <div class="error">
 | 
			
		||||
                                ✖ {{ message }}
 | 
			
		||||
                            </div>
 | 
			
		||||
                            {% endif %}
 | 
			
		||||
                        {% endfor %}
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                {% endwith %}
 | 
			
		||||
 | 
			
		||||
                <p>There are {{ num_items }} links in the database.</p>
 | 
			
		||||
 | 
			
		||||
                <div class="paginator">
 | 
			
		||||
                    {% for i in range(1, page_count + 1) %}
 | 
			
		||||
                        {% if i == page %}
 | 
			
		||||
                            <span class="paginator-current">{{ i }}</span>
 | 
			
		||||
                        {% else %}
 | 
			
		||||
                            <a class="paginator-link" href="?page={{ i }}">{{ i }}</a>
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                    {% endfor %}
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                <table id="link-table">
 | 
			
		||||
                    <tr class="link-table-header">
 | 
			
		||||
                        <th>Short link</th>
 | 
			
		||||
                        <th>Long link</th>
 | 
			
		||||
                        <th>Delete?</th>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    {% for long, short in urls.items() %}
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td>{{ short }}</td>
 | 
			
		||||
                            <td>{{ long }}</td>
 | 
			
		||||
                            <td class="link-table-center">
 | 
			
		||||
                                <a href="{{ url_for('delete', short=short) }}?page={{ page }}">X</a>
 | 
			
		||||
                            </td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    {% else %}
 | 
			
		||||
                        <tr>
 | 
			
		||||
                            <td colspan="2">No links yet.</td>
 | 
			
		||||
                        </tr>
 | 
			
		||||
                    {% endfor %}
 | 
			
		||||
                </table>
 | 
			
		||||
 | 
			
		||||
                <div class="paginator">
 | 
			
		||||
                    {% for i in range(1, page_count + 1) %}
 | 
			
		||||
                        {% if i == page %}
 | 
			
		||||
                            <span class="paginator-current">{{ i }}</span>
 | 
			
		||||
                        {% else %}
 | 
			
		||||
                            <a class="paginator-link" href="?page={{ i }}">{{ i }}</a>
 | 
			
		||||
                        {% endif %}
 | 
			
		||||
                    {% endfor %}
 | 
			
		||||
                </div>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										67
									
								
								templates/login.html
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								templates/login.html
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,67 @@
 | 
			
		|||
<!--
 | 
			
		||||
Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
 | 
			
		||||
This file is part of liteshort by 132ikl
 | 
			
		||||
This software is license under the MIT license. It should be included in your copy of this software.
 | 
			
		||||
A copy of the MIT license can be obtained at https://mit-license.org/
 | 
			
		||||
-->
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="en">
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="UTF-8">
 | 
			
		||||
    <title>Admin Login - {{ config.site_name }}</title>
 | 
			
		||||
    <link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
 | 
			
		||||
    <link rel="stylesheet" href="{{ url_for('static', filename='ia.css') }}">
 | 
			
		||||
    <meta name="viewport" content="width=device-width, initial-scale=1">
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
    <div id="top">
 | 
			
		||||
        <div id="header">
 | 
			
		||||
            <div id="logo" class="drop-shadow">
 | 
			
		||||
                <a href="{{ url_for('main') }}">
 | 
			
		||||
                    <img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
 | 
			
		||||
                </a>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div id="title" class="drop-shadow">
 | 
			
		||||
                <a href="{{ url_for('main') }}">
 | 
			
		||||
                    I.C.T.S.V. URL Shortener
 | 
			
		||||
                </a>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
    <div id="middle">
 | 
			
		||||
        <div id="content">
 | 
			
		||||
            <div class="clearfix"></div>
 | 
			
		||||
            <div id="box" class="align-self-center col-xl-4 col-lg-4 col-md-6 col-sm-10 col-xs-12">
 | 
			
		||||
                <div class="form">
 | 
			
		||||
                    <h3 id="box-title">Admin Login</h3>
 | 
			
		||||
                    <form action="{{ url_for('login') }}" method="POST">
 | 
			
		||||
                        <div id="username-box">
 | 
			
		||||
                            <input id="username" name="username" type="text" placeholder="Username">
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <div id="password-box">
 | 
			
		||||
                            <input id="password" name="password" type="password" placeholder="Password">
 | 
			
		||||
                        </div>
 | 
			
		||||
                        <button id="submit" type="submit" class="btn btn-primary" formmethod="post">Login</button>
 | 
			
		||||
                    </form>
 | 
			
		||||
                </div>
 | 
			
		||||
 | 
			
		||||
                {% with messages = get_flashed_messages(with_categories=true) %}
 | 
			
		||||
                    {% if messages %}
 | 
			
		||||
                        {% for category, message in messages %}
 | 
			
		||||
                            {% if category == 'success' %}
 | 
			
		||||
                            <div class="success">
 | 
			
		||||
                                ✓ {{ message }}
 | 
			
		||||
                            </div>
 | 
			
		||||
                            {% elif category == 'error' %}
 | 
			
		||||
                            <div class="error">
 | 
			
		||||
                                ✖ {{ message }}
 | 
			
		||||
                            </div>
 | 
			
		||||
                            {% endif %}
 | 
			
		||||
                        {% endfor %}
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                {% endwith %}
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
<!--
 | 
			
		||||
Copyright (c) 2019 Steven Spangler <132@ikl.sh>
 | 
			
		||||
Copyright (c) 2019 Steven Spangler <132@ikl.sh>, Kevin Alberts <kevin@kevinalberts.nl>
 | 
			
		||||
This file is part of liteshort by 132ikl
 | 
			
		||||
This software is license under the MIT license. It should be included in your copy of this software.
 | 
			
		||||
A copy of the MIT license can be obtained at https://mit-license.org/
 | 
			
		||||
| 
						 | 
				
			
			@ -17,10 +17,14 @@ A copy of the MIT license can be obtained at https://mit-license.org/
 | 
			
		|||
    <div id="top">
 | 
			
		||||
        <div id="header">
 | 
			
		||||
            <div id="logo" class="drop-shadow">
 | 
			
		||||
                <img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
 | 
			
		||||
                <a href="{{ url_for('main') }}">
 | 
			
		||||
                    <img src="{{ url_for('static', filename='ictsv-logo-white.svg') }}" alt="logo">
 | 
			
		||||
                </a>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div id="title" class="drop-shadow">
 | 
			
		||||
                I.C.T.S.V. URL Shortener
 | 
			
		||||
                <a href="{{ url_for('main') }}">
 | 
			
		||||
                    I.C.T.S.V. URL Shortener
 | 
			
		||||
                </a>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -62,6 +66,14 @@ A copy of the MIT license can be obtained at https://mit-license.org/
 | 
			
		|||
                        {% endfor %}
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                {% endwith %}
 | 
			
		||||
 | 
			
		||||
                <p id="copyright">
 | 
			
		||||
                    <span>This URL shortening service is provided by <a href="https://inter-actief.net/">I.C.T.S.V. Inter-<i>Actief</i></a>.</span>
 | 
			
		||||
                    <span>URLs may be deleted or modified by us if deemed necessary.</span>
 | 
			
		||||
                    <span>No personal information is processed by this application.</span>
 | 
			
		||||
                    <span> </span>
 | 
			
		||||
                    <span>© <a href="https://inter-actief.net/">I.C.T.S.V. Inter-<i>Actief</i></a> and <a href="https://gitlab.ia.utwente.nl/WWW/ia-short">individual contributors</a>. Based on <a href="https://github.com/132ikl/liteshort">liteshort</a>.</span>
 | 
			
		||||
                </p>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Reference in a new issue