Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
This is the Go Redirector
  • Loading branch information
cwbooth5 committed Sep 3, 2015
0 parents commit 15b4390
Show file tree
Hide file tree
Showing 23 changed files with 2,130 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.pyc
*.pickle
tmp/*
5 changes: 5 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,5 @@
The MIT License (MIT)
Copyright (c) 2015, F5 Networks, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 changes: 30 additions & 0 deletions README.md
@@ -0,0 +1,30 @@

# The F5 Go Redirector

*A simple service for redirecting mnemonic terms to destination urls.*

Features include:

- anyone can add terms easily
- regex parsing for "special cases" (using regular expressions)
- automatically appends everything after the second slash to the destination url
- tracks and displays term usage frequency on frontpage with fontsize
- variables allow destination URLs to change en masse (e.g. project name)

## Required Packages

python-cherrypy3
python-jinja2

## Tips

To run, execute go.py and go to localhost:8080 in a browser.

backup go database regularly

$ ./go.py export
$ backup newterms.txt

---
contributed by Saul Pwanson

5 changes: 5 additions & 0 deletions TERMS_OF_USE.txt
@@ -0,0 +1,5 @@
THIS LICENSE AGREEMENT IS ENTERED INTO BETWEEN THE SUBMITTING PARTY AND F5 NETWORKS, INC. AND THE SUBMITTING PARTY AGREES TO BE BOUND BY THE TERMS OF THIS AGREEMENT BY SUBMITTING, POSTING, DOWNLOADING, COPYING, MODIFYING, INPUTTING, INSTALLATION, UPLOAD OR OTHER USE OF F5 MATERIALS AND THE SUBMISSIONS. IF YOU DO NOT AGREE TO THE FOREGOING, DO NOT POST THE SUBISSIONS OR USE THE F5 MATERIALS.
(1) F5 does not claim ownership of the materials you provide to F5 (including feedback and suggestions) or post, upload, input or submit to any F5 GitHub repository (collectively "Submissions"). However, by posting, uploading, inputting, providing or submitting your Submission you grant F5, its affiliated companies and necessary sub-licensees a full, complete, irrevocable copyright license to use your Submission including, without limitation, the rights to: copy, distribute, transmit, publicly display, publicly perform, reproduce, edit, translate and reformat your Submission; and to publish your name in connection with your Submission. In addition, you agree that your submission will be subject to the terms of the MIT License (F5 MIT License).
(2) By posting, uploading, inputting, providing or submitting your Submission you warrant and represent that you own, are approved by your employer, or otherwise control all of the rights to your Submission as described including, without limitation, all the rights necessary for you to provide, post, upload, input or submit the Submissions.
(3) Infringement Indemnification. Submitting party will defend and indemnify F5 against a claim that any information, design, specification, instruction, software, data, or material furnished by the submitting party under this license infringes a trademark, copyright, or patent. F5 will notify the submitting party promptly of such claim and will give sole control of defense and all related settlement negotiations to submitting party. F5 will provide reasonable assistance, information, and authority necessary to perform these obligations. Reasonable out-of-pocket expenses incurred by F5 for providing such assistance will be reimbursed by the submitting party.
(4) THE MATERIALS AND SERVICES MADE AVAILABLE AT AND THROUGH THIS SITE ARE PROVIDED BY F5 ON AN "AS IS" BASIS. F5 MAKES NO REPRESENTATIONS, WARRANTIES OR GUARANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE OPERATION OF THIS SITE, ITS CONTENT, OR ANY PRODUCTS OR SERVICES DESCRIBED OR OFFERED BY THIS SITE. TO THE FULL EXTENT PERMISSIBLE BY APPLICABLE LAW, F5 DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY, INCLUDING MERCHANTABILITY OF COMPUTER PROGRAMS AND INFORMATIONAL CONTENT, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, TITLE, OR THAT THE SITE CONTENT IS RELIABLE, ACCURATE, OR TIMELY. F5 WILL NOT BE LIABLE FOR ANY DAMAGES OF ANY KIND ARISING FROM THE USE OF THIS SITE, INCLUDING, BUT NOT LIMITED TO DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL, CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF USE, DATA OR PROFITS, ARISING OUT OF OR IN ANY WAY CONNECTED WITH THE USE OR PERFORMANCE OF THE WEB SITE, WITH THE DELAY OR INABILITY TO USE THE WEB SITE OR RELATED SERVICES, THE PROVISION OF OR FAILURE TO PROVIDE SERVICES, OR FOR ANY INFORMATION, SOFTWARE, PRODUCTS, SERVICES AND RELATED GRAPHICS OBTAINED THROUGH THE WEB SITE, OR OTHERWISE ARISING OUT OF THE USE OF THE WEB SITE, WHETHER BASED ON CONTRACT, TORT, NEGLIGENCE, STRICT LIABILITY OR OTHERWISE, EVEN IF F5 OR ANY OF ITS SUPPLIERS HAS BEEN ADVISED OF THE POSSIBILITY OF DAMAGES. BECAUSE SOME STATES/JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU. WHILE THIS SITE MAY PROVIDE LINKS TO THIRD PARTY SITES, F5 DOES NOT CONTROL OR ENDORSE ANY THIRD PARTY SITE AND DISCLAIMS ANY RESPONSIBILITY FOR ITS FUNCTIONALITY OR CONTENT. THESE DISCLAIMERS AND LIMITATIONS ARE MADE IN ADDITION TO THOSE MADE IN AND APPLICABLE TO VARIOUS PAGES OR SECTIONS OF THIS SITE.
111 changes: 111 additions & 0 deletions base.html
@@ -0,0 +1,111 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en"><head>
<title>{% block title %}go/{% block titlekeyword %}{% endblock titlekeyword %}{% endblock title %}</title>
<link rel="stylesheet" href="/bootstrap.css" media="screen"/>
<link rel="shortcut icon" href="http://www.f5.com/favicon.ico" />

<style type="text/css">
a { text-decoration: none; }
a:hover {
color: red;
text-decoration: none;
opacity: 1.0 !important;
}

.column {
border: 2px ridge gray;
}

.link {
overflow: hidden;
}
.cloudli {
float: left;
margin-left: .5em;
margin-top: .25em;
}

.center { text-align: center; }
.fineprint {
font-size: 75%;
}

table.table { margin-bottom: 10px; }

table.shallow td { padding: 4px; }

.link div.shallow { min-height: 0px }

.variables {
border: 1px solid black;
width: 100%;
margin: 0 auto;
}

.variables td, .variables th {
border: 1px solid black;
text-align: center;
width: 30%;
}

.linkedit td:first-child {
font-weight: bold;
}

.column .inner {
margin: .5em;
}

.linkedit td input[name="example"], .linkedit td input[name="otherlists"] {
width: 12em;
}

.linkedit input[type="text"], .linkedit textarea {
width: 85%;
}

.linkedit input[type="checkbox"] {
margin-right: .5em;
vertical-align: top;
}

{% block css %}
{% endblock css %}
</style>
</head>
<body>

<div class="container-fluid">
<div class="row-fluid">

<div class="span4">
<h3><a href="/" title="Redirector home">go</a>/{% block keyword %}{% endblock %}</h3>
</div>

<div class="span4 pull-right">
<a class="pull-right" href="/help">go/help</a>
<br/>
<form action="/search">
<input type="hidden" size="24" value="fulltext search currently disabled" readonly="true"/>
{% if username %}
<a class="pull-right" href="/{{ username }}">logged in as {{ username }}</a>
{% else %}
<a class="pull-right" href="/_login_?redirect={{ getCurrentEditableUrlQuoted() }}">login</a>
{% endif %}
</form>
</div>

</div>
{% block body %}

{% endblock body %}

<hr style="clear:both;"/>
</div>

<script type="text/javascript">
{% block javascript %}
{% endblock javascript %}
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions bootstrap.min.css

Large diffs are not rendered by default.

99 changes: 99 additions & 0 deletions check.html
@@ -0,0 +1,99 @@
{% extends "base.html" %}

{% set username = getSSOUsername() %}

{% block keyword %}_check_{% endblock keyword %}

{% block body %}

{% for _, LL in g_db.lists.items() %}
{% if not LL.regex and len(LL.links) == 0 %}
<li>
{{ LL.name }} has 0 links
{% if vacwm %}
{{ g_db.deleteList(LL) }}
{% else %}
and will be deleted
{% endif %}
</li>
{% endif %}

{% if is_int(LL.name) %}
<li>
{{ LL.name }} has integer name,
{% if vacwm %}
{{ g_db.renameList(LL, "n" + LL.name) }}
(renamed to n{{ LL.name }})
{% else %}
will be renamed to n{{ LL.name }}
{% endif %}
</li>
{% endif %}

{% for L in LL.links %}
{% if L._url not in g_db.linksByUrl %}
<li>
lost <a href="/_edit_/{{ L.linkid }}">link #{{ L.linkid }}</a>: {{ L._url }} not in linksByUrl
</li>
{% if vacwm %}
{{ g_db._addLink(L) }}
(added to linksByUrl)
{% else %}
(will be added to linksByUrl)
{% endif %}
{% endif %}

{% if L.linkid not in g_db.linksById %}
<li>
lost link #{{ L.linkid }}: not in linksById
{% if vacwm %}
{{ g_db._addLink(L) }}
(added to linksById)
{% else %}
(will be added to linksById)
{% endif %}
</li>
{% endif %}

{% for A in L.lists %}
{% if L not in A.links %}
<li>
link #{{ L.linkid }} has {{ A }} in its lists but not the reverse.
</li>
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}

{% for url, L in g_db.linksByUrl.items() %}
{% if url != L._url %}
<li>
<a href="/_edit_/{{ L.linkid }}">link #{{ L.linkid }}</a> url ({{ L._url }}) doesn't match byUrl {{ url }}
{% if vacwm %}
{{ g_db._removeLinkFromUrls(url) }} (removed from byUrl)
{% else %}
(will be removed from byUrl)
{% endif %}
</li>
{% endif %}

{% endfor %}

{% for L in g_db.linksById.values() %}
{% if L._url is none %}
<li>
<a href="/_edit_/{{ L.linkid }}">link #{{ L.linkid }}</a> has invalid url: {{ L.url }}
{% if vacwm %}
{{ g_db.deleteLink(L) }}
{% else %}
(will be deleted)
{% endif %}
</li>
{% endif %}
{% endfor %}

{% if not vacwm %}
<a href="?vacwm=true">Cleanup</a>
{% endif %}

{% endblock body %}
32 changes: 32 additions & 0 deletions dumplist.html
@@ -0,0 +1,32 @@
{% extends "base.html" %}

{% block keyword %}:dumplist{% endblock %}
{% block css %}
.red { background-color: red }
{% endblock css %}
{% block body %}
<table border="1px">
<tr>
<th>L.linkid</th>
<th>L.url</th>
<th>L.title</th>
<th>L.edits</th>
<th>L.lists</th>
</tr>
{% for L in g_db.getList(listname).links: %}
<tr>
<td {% if L.linkid not in g_db.linksById %}class="red"{% endif %}><a href="/_edit_/{{ L.linkid }}">{{ L.linkid }}</a></td>
<td {% if L._url not in g_db.linksByUrl %}class="red"{% endif %}>{{ L._url }}</td>
<td>{{ L.title }}</td>
<td>{% for lastEditTime, lastEditor in L.edits %}
{{ lastEditTime|time_t }} by {{ lastEditor }}
<br/>
{% endfor %}
</td>
<td>{% for x in L.lists %}{{ x.name }} {% endfor %}</td>
</tr>
{% endfor %}
</table>

{% endblock %}

97 changes: 97 additions & 0 deletions editlink.html
@@ -0,0 +1,97 @@
{% extends "base.html" %}
{% from "listinc.html" import clickstats %}

<!-- {% set username = getSSOUsername() %} -->

{% block title %}{% if L.linkid == 0 %}Add Link{% else %}Edit go link #{{ L.linkid }}{% endif %}{% endblock title %}
{% block keyword %}{% if L.linkid %}_edit_/{{ L.linkid }}{% else %}_add_{% endif %}{% endblock keyword %}

{% block body %}
<div class="row-fluid">

<div class="column span6">

{% if L.linkid != 0 %}
<a class="pull-right" style="margin-right: .25em;" href="/_delete_/{{ L.linkid }}?returnto={{ returnto }}">DELETE</a>
{% endif %}

<div class="inner">
<form action="/_modify_">
{% if returnto %}
<input type="hidden" name="returnto" value="{{ returnto|escapekeyword }}"/>
{% endif %}

{% if L.linkid != 0 %}
<input type="hidden" name="linkid" value="{{ L.linkid }}"/>
{% endif %}

<table class="table linkedit">
{% if error %}
<tr>
<td colspan="3"><h4 class="alert">{{ error }}</h4></td>
</tr>
{% endif %}

<tr>
<td>Title</td>
<td>
<input type="text" name="title" maxlength="140" size="50" value="{{ title or L.title }}"/>
</td>
<td class="help"></td>
</tr>

<tr>
<td>URL</td>
<td>
<textarea name="url" rows="4" cols="50">{{ url or L._url }}</textarea>
</td>
</tr>

<tr>
<td>Lists</td>
<td>
{% set listnames = L.listnames() or list(lists) %}
{% for t in listnames %}
{% set K = g_db.getList(t, create=False) %}
{% set flDirect = K and K.goesDirectlyTo(L) %}
<input type="checkbox" name="lists" checked="checked" value="{{ t }}">
<a href="/.{{ t|escapekeyword }}">
{% if flDirect %}<b>{% else %}<i>{% endif %}
{{ t }}
{% if flDirect %}</b>{% else %}</i>{% endif %}
</a></input>
<br/>
{% endfor %}
add to: <input type="text" name="otherlists" value="{{ otherlists }}"/> <i>(space-separated)</i>
</td>
</tr>

<tr>
<td/>
<td>
<input type="submit" value="Submit Link"/>
</td>
</tr>
</table>
</form>
</div>
</div> {# end inner #}

<div class="column span6">
<div class="inner">
{% include "vartable.html" %}
<p>also see <a href="http://docs.python.org/2/library/string.html#format-specification-mini-language">Python Format Syntax</a> for variable formatting
and <a href="http://docs.python.org/library/re.html#regular-expression-syntax">Python Regex Syntax</a> for regexes
</div>
</div>

</div>

{{ clickstats(L) }}

<br/>edits:
{% for editTime, editor in L.edits %}
<br/>&mdash;&nbsp;{{ editTime|time_t }} by {{ editor }}
{% endfor %}

{% endblock body %}

0 comments on commit 15b4390

Please sign in to comment.