Commit 0e510eb0 authored by David Haynes's avatar David Haynes 🙆

Merge branch '181-MVP' into 'go-three'

Resolve "Get back to minimum viable product to ease development"

See merge request !118
parents 050fc94f d9154d47
Pipeline #2492 passed with stage
in 1 minute and 26 seconds
...@@ -36,22 +36,9 @@ before_script: ...@@ -36,22 +36,9 @@ before_script:
- python manage.py migrate - python manage.py migrate
- echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('root', 'root@srct.gmu.edu', 'root') " | python manage.py shell - echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('root', 'root@srct.gmu.edu', 'root') " | python manage.py shell
Go-py3.4:
image: library/python:3.4
stage: test
script:
- python manage.py test
Go-py3.5:
image: library/python:3.5
stage: test
script:
- python manage.py test
Go-py3.6: Go-py3.6:
image: library/python:3.6 image: library/python:3.6
stage: test stage: test
script: script:
# - if pip list --outdated | grep "Latest" | wc -l > 0; then pip list --outdated && exit 1; else exit 0; fi
- coverage run --source=go --omit=*migrations/*,*admin.py,*manage.py,*wsgi.py,*settings.py,*secret.py,*__init__.py,*.pyc,*templates/*,*static/* manage.py test - coverage run --source=go --omit=*migrations/*,*admin.py,*manage.py,*wsgi.py,*settings.py,*secret.py,*__init__.py,*.pyc,*templates/*,*static/* manage.py test
- coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}' - coverage html -i && grep pc_cov htmlcov/index.html | egrep -o "[0-9]+\%" | awk '{ print "covered " $1;}'
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
[![build status](https://git.gmu.edu/srct/go/badges/master/build.svg)](https://git.gmu.edu/srct/go/commits/master) [![build status](https://git.gmu.edu/srct/go/badges/master/build.svg)](https://git.gmu.edu/srct/go/commits/master)
[![coverage report](https://git.gmu.edu/srct/go/badges/master/coverage.svg)](https://git.gmu.edu/srct/go/commits/master) [![coverage report](https://git.gmu.edu/srct/go/badges/master/coverage.svg)](https://git.gmu.edu/srct/go/commits/master)
[![python version](https://img.shields.io/badge/python-2.7,3.4+-blue.svg)]() [![python version](https://img.shields.io/badge/python-3.6-blue.svg)]()
[![Django version](https://img.shields.io/badge/Django-1.11-brightgreen.svg)]() [![Django version](https://img.shields.io/badge/Django-2.0-brightgreen.svg)]()
A project of [GMU SRCT](https://srct.gmu.edu). A project of [GMU SRCT](https://srct.gmu.edu).
...@@ -11,9 +11,8 @@ Go is a drop-in URL shortening service. This project aims to provide an easy to ...@@ -11,9 +11,8 @@ Go is a drop-in URL shortening service. This project aims to provide an easy to
use URL branding service for institutions that wish to widely disseminate use URL branding service for institutions that wish to widely disseminate
information without unnecessarily outsourcing branding. information without unnecessarily outsourcing branding.
Go is currently a `Python 3` (with backwards compatability for `Python 2.7` Go is currently a `Python 3` project written in the `Django` web framework,
until Django 2.0 in December 2017) project written in the `Django` web with `MySQL` as our backend database.
framework, with `MySQL` as our backend database.
## Setup instructions for local development ## Setup instructions for local development
...@@ -70,9 +69,8 @@ Finally we can install git with: ...@@ -70,9 +69,8 @@ Finally we can install git with:
#### On Windows #### On Windows
We recommend that if you are on Windows 10 AE (Anniversary Edition) or above to We recommend that if you are on Windows 10 to make use of the Windows Subsystem
make use of the Windows Subsystem for Linux (WSL). The following link should for Linux (WSL). The following link should get you up and running:
get you up and running:
[https://msdn.microsoft.com/en-us/commandline/wsl/install_guide](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide) [https://msdn.microsoft.com/en-us/commandline/wsl/install_guide](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)
...@@ -210,9 +208,7 @@ bottom row. ...@@ -210,9 +208,7 @@ bottom row.
### Coding style ### Coding style
You should adhere to the style of the repo code. Consistency is key! PEP8 TODO
guidelines are strongly recommended but not enforced at the time. Please
comment your code, I will not accept commits that contain undocumented code.
### Getting Help ### Getting Help
...@@ -220,26 +216,3 @@ I encourage you to join the ...@@ -220,26 +216,3 @@ I encourage you to join the
[#go channel](https://srct.slack.com/messages/go/details/) in SRCT's [#go channel](https://srct.slack.com/messages/go/details/) in SRCT's
[Slack Group](https://srct.slack.com) if you have any questions on setup or [Slack Group](https://srct.slack.com) if you have any questions on setup or
would like to contribute. would like to contribute.
## Some words about deploying Go.
Check out our admin guide:
https://git.gmu.edu/srct/go/wikis/administration-guide
In order to expire links, you need to set up a cron job to run the manage.py
expirelinks command regularly. A sample cron script is available in the
repository and is named go-cleanlinks.cron. Drop this in cron.hourly and change
the paths so that they point to the virtualenv activate script and manage.py.
## Production cron job
```sh
#!/bin/bash
# Cron job to automatically expire outdated links, put this in cron.hourly
ACTIVATE_PATH=/path/to/virtualenv/activate
MANAGE_PATH=/path/to/go/manage.py
source ${ACTIVATE_PATH}
python ${MANAGE_PATH} expirelinks
```
<!-- Custom definition for accordian-group --> <!-- Custom definition for accordian-group -->
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> {{ div.name }}
<h4 class="panel-title"> <div id="{{ div.css_id }}" class="}">
{{ div.name }} {{ fields|safe }}
</h4>
</div>
<div id="{{ div.css_id }}" class="panel-collapse collapse{% if div.active %} in{% endif %}" >
<div class="panel-body">
{{ fields|safe }}
</div>
</div> </div>
</div> </div>
<br /> <br />
<!-- load in go templatetags --> <!-- load in go templatetags -->
{% load go_extras %} {% load go_extras %}
<!-- load in qr code lib -->
{% load qr_tags %}
<!-- CSS for page --> <!-- CSS for page -->
<style> <style>
a.share:link { a.share:link {
color: #000000; color: #000000;
} }
a.share:visited { a.share:visited {
color: #000000; color: #000000;
} }
a.share:hover { a.share:hover {
color: #000000; color: #000000;
} }
a.share { a.share {
text-decoration: none; text-decoration: none;
} }
a.button:link { a.button:link {
color: #FFF; color: #FFF;
} }
a.button:visited { a.button:visited {
color: #FFF; color: #FFF;
} }
a.button:hover { a.button:hover {
color: #FFF; color: #FFF;
} }
legend { legend {
font-size: inherit; font-size: inherit;
} }
#button-container { #button-container {
padding-bottom: 4px; padding-bottom: 4px;
padding-left: 6px; padding-left: 6px;
padding-right: 6px; padding-right: 6px;
padding-top: 4px; padding-top: 4px;
} }
#copy-button-{{url.short}} { #copy-button- {
{
url.short
}
}
{
border: none; border: none;
background-color: #eeeeee; background-color: #eeeeee;
padding-bottom: 3px; padding-bottom: 3px;
} }
#copy-button-{{url.short}}:focus { #copy-button- {
{
url.short
}
}
:focus {
outline: none; outline: none;
} }
#clipboard-icon-{{url.short}} { #clipboard-icon- {
{
url.short
}
}
{
font-size: 14px; font-size: 14px;
} }
#link-{{url.short}}:visited { #link- {
{
url.short
}
}
:visited {
color: #006633; color: #006633;
} }
.tooltip-inner { .tooltip-inner {
white-space: nowrap; white-space: nowrap;
max-width: none; max-width: none;
...@@ -79,7 +100,8 @@ ...@@ -79,7 +100,8 @@
<div class="input-group"> <div class="input-group">
<a id="link-{{url.short}}" class="form-control" href="{{domain}}{{url.short}}" target="_blank">{{domain}}{{url.short}}</a> <a id="link-{{url.short}}" class="form-control" href="{{domain}}{{url.short}}" target="_blank">{{domain}}{{url.short}}</a>
<div id="button-container" class="input-group-addon"> <div id="button-container" class="input-group-addon">
<button id="copy-button-{{url.short}}" type="button" class="button btn btn-default btn-xs fa" role="button" data-clipboard-target="#link-{{url.short}}" title="Copy to Clipboard"> <button id="copy-button-{{url.short}}" type="button" class="button btn btn-default btn-xs fa"
role="button" data-clipboard-target="#link-{{url.short}}" title="Copy to Clipboard">
<i id="clipboard-icon-{{url.short}}" class="fa fa-clipboard fa-1g" aria-hidden="true"></i> <i id="clipboard-icon-{{url.short}}" class="fa fa-clipboard fa-1g" aria-hidden="true"></i>
</button> </button>
</div> </div>
...@@ -89,97 +111,83 @@ ...@@ -89,97 +111,83 @@
<h3>Address Details:</h3> <h3>Address Details:</h3>
<strong>Target URL:</strong> <strong>Target URL:</strong>
<a href="{{url.target}}" target="_blank">{{url.target}}</a> <a href="{{url.target}}" target="_blank">{{url.target}}</a>
<br /> <br /> {% if url.owner == request.user.registereduser and request.user.registereduser.approved
{% if url.owner == request.user.registereduser and request.user.registereduser.approved == True %} == True %}
<strong>Clicks:</strong> {{url.clicks}} <strong>Clicks:</strong> {{url.clicks}}
<br /> <br />
<br />
<strong>QR Code Uses:</strong> {{url.qrclicks}}
<br /> <strong>Social Media Clicks:</strong> {{url.socialclicks}}
<br />
<strong>Social Media Clicks:</strong> {{url.socialclicks}}
<br /> <strong>Expires:</strong> {{url.expires|default_if_none:"Never"}}
<br></br>
<strong>Expires:</strong> {{url.expires|default_if_none:"Never"}}
<br></br> <!-- Delete Button -->
<a class="button btn btn-danger btn-sm" data-target="#deletionModal-{{url.short}}"
<!-- Delete Button --> data-toggle="modal">
<a class="button btn btn-danger btn-sm" data-target="#deletionModal-{{url.short}}" <i class="fa fa-trash-o fa-lg"></i> Delete
data-toggle="modal"> </a>
<i class="fa fa-trash-o fa-lg"></i> Delete
</a> <!-- Edit Button -->
<a href="{{domain}}edit/{{url.short}}" class="button btn btn-info btn-sm">
<!-- Edit Button --> <i class="fa fa-cog fa-lg"></i> Edit
<a href="{{domain}}edit/{{url.short}}" class="button btn btn-info btn-sm"> </a>
<i class="fa fa-cog fa-lg"></i> Edit
</a>
</div>
<!-- right -->
<div class="col-md-6">
<h3>Share Address:</h3>
<!-- define the Go URL as `the_url` -->
{% with domain|add:url.short as the_url %}
<!-- some goofy code to use the qr lib and show the image -->
{% with the_url|add:"?qr" as qr_url%}
{% qr_from_text qr_url 's' %}
{% endwith %}
{% with the_url|add:"?social" as social_url %}
<!-- twitter -->
<a class="share" href="https://twitter.com/share?url={{ social_url }}" target="_blank" title="Share via Twitter">
<i class="fa fa-twitter-square fa-3x"></i>
</a>
<!-- facebook -->
<a class="share" href="https://www.facebook.com/share.php?u={{ social_url }}" target="_blank" title="Share via Facebook">
<i class="fa fa-facebook-square fa-3x"></i>
</a>
<!-- g+ -->
<a class="share" href="https://plus.google.com/share?url={{ social_url }}" target="_blank" title="Share via Google+">
<i class="fa fa-google-plus-square fa-3x"></i>
</a>
<!-- linkedin -->
<a class="share" href="https://www.linkedin.com/shareArticle?mini=true&amp;url={{ social_url }}&amp;ro=false&amp;summary=&amp;source=" target="_blank" title="Share via LinkedIn">
<i class="fa fa-linkedin-square fa-3x"></i>
</a>
{% endwith %}
<!-- list out qr downloads -->
{% with the_url|add:"?qr" as qr_url %}
<!-- spacing matters with <pre>, ignore the ugliness -->
<pre><strong>QR Downloads:</strong>
<a href="https://chart.googleapis.com/chart?cht=qr&chs=268x268&chl={{ qr_url }}" target="_blank">Small (268x268)</a>
<a href="https://chart.googleapis.com/chart?cht=qr&chs=383x383&chl={{ qr_url }}" target="_blank">Medium (383x383)</a>
<a href="https://chart.googleapis.com/chart?cht=qr&chs=547x547&chl={{ qr_url }}" target="_blank">Large (547x547)</a></pre>
{% endwith %}
{% endwith %}
</div>
</div> </div>
<!-- right -->
<div class="col-md-6">
<h3>Share Address:</h3>
<!-- define the Go URL as `the_url` -->
{% with domain|add:url.short as the_url %} {% with the_url|add:"?social" as social_url
%}
<!-- twitter -->
<a class="share" href="https://twitter.com/share?url={{ social_url }}" target="_blank"
title="Share via Twitter">
<i class="fa fa-twitter-square fa-3x"></i>
</a>
<!-- facebook -->
<a class="share" href="https://www.facebook.com/share.php?u={{ social_url }}" target="_blank"
title="Share via Facebook">
<i class="fa fa-facebook-square fa-3x"></i>
</a>
<!-- g+ -->
<a class="share" href="https://plus.google.com/share?url={{ social_url }}" target="_blank"
title="Share via Google+">
<i class="fa fa-google-plus-square fa-3x"></i>
</a>
<!-- linkedin -->
<a class="share" href="https://www.linkedin.com/shareArticle?mini=true&amp;url={{ social_url }}&amp;ro=false&amp;summary=&amp;source="
target="_blank" title="Share via LinkedIn">
<i class="fa fa-linkedin-square fa-3x"></i>
</a>
{% endwith %}
<!--Define Delete Modal--> </div>
<div id="deletionModal-{{url.short}}" class="modal fade" role="dialog" tabindex="-1"> </div>
<div class="modal-dialog">
<!-- Modal content--> <!--Define Delete Modal-->
<div class="modal-content" style="background-color:#f5f5f5; border-radius: 7px"> <div id="deletionModal-{{url.short}}" class="modal fade" role="dialog" tabindex="-1">
<div class="modal-header" style="text-align:center;"> <div class="modal-dialog">
<h4 class="modal-title text-center" style="font-weight:bold; font-size: 21px !important;"> <!-- Modal content-->
Are you sure you would like to delete this link?</h4> <div class="modal-content" style="background-color:#f5f5f5; border-radius: 7px">
<h6 style="font-weight:500; margin-top: 0px; margin-bottom: 0px;"> <div class="modal-header" style="text-align:center;">
Deleting a link is permanent and can not be undone!</h6> <h4 class="modal-title text-center" style="font-weight:bold; font-size: 21px !important;">
</div> Are you sure you would like to delete this link?</h4>
<div class="modal-body" style="padding-bottom: 80px"> <h6 style="font-weight:500; margin-top: 0px; margin-bottom: 0px;">
<a type="button" class="btn btn-success btn-lg" style="border-width: 0px;float:left; width:49%; background-color: #A9B0AD; color: #ffffff; border-radius: 4px;" Deleting a link is permanent and can not be undone!</h6>
data-dismiss="modal">Cancel</a> </div>
<a type="button" class="btn btn-danger btn-lg" href="{{domain}}delete/{{url.short}}" <div class="modal-body" style="padding-bottom: 80px">
style="border-width: 0px; float:right; width:49%;background-color: #AC1D37; color: #ffffff; border-radius: 4px;">Delete</a> <a type="button" class="btn btn-success btn-lg" style="border-width: 0px;float:left; width:49%; background-color: #A9B0AD; color: #ffffff; border-radius: 4px;"
</div> data-dismiss="modal">Cancel</a>
<a type="button" class="btn btn-danger btn-lg" href="{{domain}}delete/{{url.short}}"
style="border-width: 0px; float:right; width:49%;background-color: #AC1D37; color: #ffffff; border-radius: 4px;">Delete</a>
</div> </div>
</div> </div>
</div> </div>
{% else %} </div>
{% endif %}
<br></br> <br></br>
</div> </div>
...@@ -208,4 +216,4 @@ ...@@ -208,4 +216,4 @@
e.clearSelection(); e.clearSelection();
$('#copy-button-{{url.short}}').attr('data-original-title', 'Copied!').tooltip('show'); $('#copy-button-{{url.short}}').attr('data-original-title', 'Copied!').tooltip('show');
}); });
</script> </script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment