Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
go
Commits
33f7ae4c
Commit
33f7ae4c
authored
Feb 07, 2017
by
Zach Knox
Browse files
The pages are swapped
but it's kind of ugly I'll fix that later
parent
98bed2aa
Pipeline
#864
passed with stage
in 1 minute and 10 seconds
Changes
5
Pipelines
2
Show whitespace changes
Inline
Side-by-side
go/go/templates/core/index.html
View file @
33f7ae4c
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block -->
{% block title %}
SRCT Go
•
A University Branded URL Shortener
SRCT Go
•
My Links
{% endblock %}
<!-- define the content block for the page -->
...
...
@@ -21,42 +18,27 @@ SRCT Go • A University Branded URL Shortener
<i
class=
"fa fa-circle fa-stack-2x"
></i>
<i
class=
"fa fa-link fa-stack-1x fa-inverse"
></i>
</span>
<i
class=
"fa"
>
Shorten URL
</i>
<i
class=
"fa"
>
My Links
</i>
</strong></h1>
</div>
</div>
<div
class=
"newlink"
style=
"text-align: right;"
>
<a
href=
"{% url 'index' %}"
><i
class=
"fa fa-plus"
aria-hidden=
"true"
></i>
Add new link
</a>
</div>
</div>
<!-- call django crispy forms to render the go link creation form here -->
{% crispy form %}
<!-- load some JS to hide/show the custom date field -->
<script
type=
"text/javascript"
>
$
(
function
()
{
// hide by default
$
(
"
div_id_expires_custom
"
).
hide
();
// if the expires_custom checkbox is checked..
if
(
$
(
"
#id_expires_5
"
).
is
(
"
:checked
"
))
{
// display the field
$
(
"
#div_id_expires_custom
"
).
slideDown
();
}
else
{
// keep it up
$
(
"
#div_id_expires_custom
"
).
slideUp
();
}
// if the expires_custom checkbox is clicked..
$
(
"
#div_id_expires
"
).
click
(
function
()
{
// if the expires_custom checkbox is checked..
if
(
$
(
"
#id_expires_5
"
).
is
(
"
:checked
"
))
{
// display the field
$
(
"
#div_id_expires_custom
"
).
slideDown
();
}
else
{
// keep it hidden
$
(
"
#div_id_expires_custom
"
).
slideUp
();
}
})
})
</script>
<!-- show all of the links -->
<div
class=
"row"
>
<!-- for every url in the urls list-->
{% for url in urls %}
<legend>
<!-- include the link box for this url -->
{% include 'link_box.html' %}
</legend>
<!-- unless the list is empty -->
{% empty %}
<h3>
None found
<i
class=
"fa fa-frown-o"
></i></h3>
{% endfor %}
</div>
{% endblock %}
go/go/templates/
my
_link
s
.html
→
go/go/templates/
core/new
_link.html
View file @
33f7ae4c
<!-- include the base html template -->
{% extends 'layouts/base.html' %}
<!-- load django crispy forms' tags -->
{% load crispy_forms_tags %}
<!-- define the page title block -->
{% block title %}
SRCT Go
•
My Links
SRCT Go
•
A University Branded URL Shortener
{% endblock %}
<!-- define the content block for the page -->
...
...
@@ -18,27 +21,42 @@ SRCT Go • My Links
<i
class=
"fa fa-circle fa-stack-2x"
></i>
<i
class=
"fa fa-link fa-stack-1x fa-inverse"
></i>
</span>
<i
class=
"fa"
>
My Links
</i>
<i
class=
"fa"
>
Shorten URL
</i>
</strong></h1>
</div>
</div>
<div
class=
"newlink"
style=
"text-align: right;"
>
<a
href=
"{% url 'index' %}"
><i
class=
"fa fa-plus"
aria-hidden=
"true"
></i>
Add new link
</a>
</div>
</div>
<!-- show all of the links -->
<div
class=
"row"
>
<!-- for every url in the urls list-->
{% for url in urls %}
<legend>
<!-- include the link box for this url -->
{% include 'link_box.html' %}
</legend>
<!-- unless the list is empty -->
{% empty %}
<h3>
None found
<i
class=
"fa fa-frown-o"
></i></h3>
{% endfor %}
</div>
<!-- call django crispy forms to render the go link creation form here -->
{% crispy form %}
<!-- load some JS to hide/show the custom date field -->
<script
type=
"text/javascript"
>
$
(
function
()
{
// hide by default
$
(
"
div_id_expires_custom
"
).
hide
();
// if the expires_custom checkbox is checked..
if
(
$
(
"
#id_expires_5
"
).
is
(
"
:checked
"
))
{
// display the field
$
(
"
#div_id_expires_custom
"
).
slideDown
();
}
else
{
// keep it up
$
(
"
#div_id_expires_custom
"
).
slideUp
();
}
// if the expires_custom checkbox is clicked..
$
(
"
#div_id_expires
"
).
click
(
function
()
{
// if the expires_custom checkbox is checked..
if
(
$
(
"
#id_expires_5
"
).
is
(
"
:checked
"
))
{
// display the field
$
(
"
#div_id_expires_custom
"
).
slideDown
();
}
else
{
// keep it hidden
$
(
"
#div_id_expires_custom
"
).
slideUp
();
}
})
})
</script>
{% endblock %}
go/go/templates/layouts/navigation.html
View file @
33f7ae4c
...
...
@@ -27,7 +27,7 @@
{% if user.is_authenticated %}
<!-- only if they are an approved user -->
{% if user.registereduser.approved %}
<li><a
href=
"{% url '
my
_link
s
' %}"
>
My
Link
s
</a></li>
<li><a
href=
"{% url '
new
_link' %}"
>
New
Link
</a></li>
{% endif %}
<!-- only if the current user has not registered to use go -->
{% if not user.registereduser.registered %}
...
...
go/go/views.py
View file @
33f7ae4c
...
...
@@ -28,7 +28,7 @@ from datetime import timedelta
not_registered error page. If they are logged in AND registered, they
get the URL registration form.
"""
def
index
(
request
):
def
new_link
(
request
):
# If the user is blocked, redirect them to the blocked page.
# If the user is not authenticated, show them a public landing page.
if
not
request
.
user
.
is_authenticated
():
...
...
@@ -50,11 +50,15 @@ def index(request):
return
redirect
(
'view'
,
post
(
request
).
short
)
# Render index.html passing the form to the template
return
render
(
request
,
'core/
index
.html'
,
{
return
render
(
request
,
'core/
new_link
.html'
,
{
'form'
:
url_form
,
},
)
# for compatibility, just in case
def
my_links
(
request
):
return
index
(
request
)
#rate limits are completely arbitrary
@
ratelimit
(
key
=
'user'
,
rate
=
'3/m'
,
method
=
'POST'
,
block
=
True
)
@
ratelimit
(
key
=
'user'
,
rate
=
'25/d'
,
method
=
'POST'
,
block
=
True
)
...
...
@@ -139,7 +143,7 @@ def view(request, short):
obviously need to be logged in to view your URLs.
"""
@
login_required
def
my_links
(
request
):
def
index
(
request
):
# Do not display this page to unapproved users
if
not
request
.
user
.
registereduser
.
approved
:
...
...
@@ -152,7 +156,7 @@ def my_links(request):
urls
=
URL
.
objects
.
filter
(
owner
=
request
.
user
.
registereduser
)
# Render my_links.html passing the list of URL's and Domain to the template
return
render
(
request
,
'
my_links
.html'
,
{
return
render
(
request
,
'
core/index
.html'
,
{
'urls'
:
urls
,
'domain'
:
domain
,
},
...
...
go/settings/urls.py
View file @
33f7ae4c
...
...
@@ -26,8 +26,8 @@ urlpatterns = [
# /signup - Signup page for access.
url
(
r
'^signup/?$'
,
go
.
views
.
signup
,
name
=
'signup'
),
# /
my
- My-Links page, view and review links.
url
(
r
'^
my
Link
s
/?$'
,
go
.
views
.
my
_link
s
,
name
=
'
my
_link
s
'
),
# /
new
- My-Links page, view and review links.
url
(
r
'^
new
Link/?$'
,
go
.
views
.
new
_link
,
name
=
'
new
_link'
),
# /delete/<short> - Delete a link, no content display.
url
(
r
'^delete/(?P<short>[-\w]+)$'
,
go
.
views
.
delete
,
name
=
'delete'
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment