From a2a753cac3fb2223fc3a00de820e79f685622dc8 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 26 Jan 2016 22:41:43 +0000 Subject: [PATCH] rewrite urls to split them into seperate files --- project/common/tests.py | 12 ++++++------ project/pages/tests.py | 16 ++++++++-------- project/pages/urls.py | 19 ------------------- project/pages/urls/__init__.py | 1 + project/pages/urls/about.py | 9 +++++++++ project/pages/urls/core.py | 7 +++++++ project/pages/urls/projects.py | 8 ++++++++ project/pages/urls/robotics.py | 10 ++++++++++ project/urls.py | 6 +++++- .../components/index/project-images-main.js | 4 ++-- static/src/js/components/navbar/navbar.js | 10 +++++----- static/src/less/navbar.less | 14 +++++++++----- static/src/less/variables.less | 2 +- templates/about/index.html | 4 ++-- templates/base.html | 2 +- templates/projects/test.md | 2 +- templates/robotics/2015-index.html | 2 +- templates/robotics/index.html | 4 ++-- 18 files changed, 78 insertions(+), 54 deletions(-) delete mode 100644 project/pages/urls.py create mode 100644 project/pages/urls/__init__.py create mode 100644 project/pages/urls/about.py create mode 100644 project/pages/urls/core.py create mode 100644 project/pages/urls/projects.py create mode 100644 project/pages/urls/robotics.py diff --git a/project/common/tests.py b/project/common/tests.py index de2a749..d8ce389 100644 --- a/project/common/tests.py +++ b/project/common/tests.py @@ -37,19 +37,19 @@ class ReverserTestCase(TestCase): class MarkdownViewTestCase(TestCase): def test_accessable(self): - response = self.client.get(reverse('pages:projects', args=['test'])) + response = self.client.get(reverse('projects:project', args=['test'])) self.assertEqual(response.status_code, 200) def test_parsing(self): - response = self.client.get(reverse('pages:projects', args=['test'])) + response = self.client.get(reverse('projects:project', args=['test'])) self.assertContains(response, '

Testing

') def test_template_engine(self): - response = self.client.get(reverse('pages:projects', args=['test'])) - self.assertContains(response, reverse('pages:all-projects')) + response = self.client.get(reverse('projects:project', args=['test'])) + self.assertContains(response, reverse('projects:all')) def test_invalid_template(self): - response = self.client.get(reverse('pages:projects', args=['not-a-project'])) + response = self.client.get(reverse('projects:project', args=['not-a-project'])) self.assertEqual(response.status_code, 404) @@ -69,7 +69,7 @@ class WorkerTestCase(TestCase): 'to_email': 'info@theorangeone.net', 'context': data } - self.client.post(reverse('pages:about'), data) + self.client.post(reverse('about:index'), data) self.assertEqual(Job.objects.count(), 1) job = Job.objects.all()[0] self.assertEqual(job.workspace, workspace) diff --git a/project/pages/tests.py b/project/pages/tests.py index 70a96ed..258e176 100644 --- a/project/pages/tests.py +++ b/project/pages/tests.py @@ -10,13 +10,13 @@ class IndexTestCase(TestCase): class AboutWebsiteTestCase(TestCase): def test_accessable(self): - response = self.client.get(reverse('pages:about-website')) + response = self.client.get(reverse('about:website')) self.assertEqual(response.status_code, 200) class AboutIndexTestCase(TestCase): def test_accessable(self): - response = self.client.get(reverse('pages:about')) + response = self.client.get(reverse('about:index')) self.assertEqual(response.status_code, 200) def test_email_send(self): @@ -25,11 +25,11 @@ class AboutIndexTestCase(TestCase): 'name': 'Person', 'message': 'Hi there, things.' } - response = self.client.post(reverse('pages:about'), data) + response = self.client.post(reverse('about:index'), data) self.assertRedirects(response, '/about/?sent') def test_success_message_shows(self): - response = self.client.get(reverse('pages:about') + '?sent') + response = self.client.get(reverse('about:index') + '?sent') self.assertContains(response, 'Already Sent') @@ -47,19 +47,19 @@ class NoJavascriptTestCase(TestCase): class AllProjectsTestCase(TestCase): def test_accessable(self): - response = self.client.get(reverse('pages:all-projects')) + response = self.client.get(reverse('projects:all')) self.assertEqual(response.status_code, 200) class RoboticsTestCase(TestCase): def test_2015_index_accessable(self): - response = self.client.get(reverse('pages:robotics-2015-index')) + response = self.client.get(reverse('robotics:2015-index')) self.assertEqual(response.status_code, 200) def test_2014_index_accessable(self): - response = self.client.get(reverse('pages:robotics-2014-index')) + response = self.client.get(reverse('robotics:2014-index')) self.assertEqual(response.status_code, 200) def test_2015_robot_accessable(self): - response = self.client.get(reverse('pages:robotics-2015-robot')) + response = self.client.get(reverse('robotics:2015-robot')) self.assertEqual(response.status_code, 200) diff --git a/project/pages/urls.py b/project/pages/urls.py deleted file mode 100644 index 7bfa65b..0000000 --- a/project/pages/urls.py +++ /dev/null @@ -1,19 +0,0 @@ -from django.conf.urls import url -from . import views - - -urlpatterns = [ - url(r'^about/website/$', views.about.WebsiteView.as_view(), name='about-website'), - url(r'^about/me/$', views.about.MeView.as_view(), name='about-me'), - url(r'^about/$', views.about.IndexView.as_view(), name='about'), - - url(r'^projects/all/$', views.projects.AllView.as_view(), name="all-projects"), - url(r'^projects/(?P.+)/$', views.projects.ProjectView.as_view(), name="projects"), - - url(r'^robotics/$', views.robotics.IndexView.as_view(), name="robotics-index"), - url(r'^robotics/2014/$', views.robotics.Index2014View.as_view(), name="robotics-2014-index"), - url(r'^robotics/2015/robot/$', views.robotics.Robot2015View.as_view(), name="robotics-2015-robot"), - url(r'^robotics/2015/$', views.robotics.Index2015View.as_view(), name="robotics-2015-index"), - - url(r'^$', views.core.IndexView.as_view(), name='index') -] diff --git a/project/pages/urls/__init__.py b/project/pages/urls/__init__.py new file mode 100644 index 0000000..996541b --- /dev/null +++ b/project/pages/urls/__init__.py @@ -0,0 +1 @@ +from . import about, core, projects, robotics diff --git a/project/pages/urls/about.py b/project/pages/urls/about.py new file mode 100644 index 0000000..2146120 --- /dev/null +++ b/project/pages/urls/about.py @@ -0,0 +1,9 @@ +from django.conf.urls import url +from project.pages.views import about + + +urlpatterns = [ + url(r'^website/$', about.WebsiteView.as_view(), name='website'), + url(r'^me/$', about.MeView.as_view(), name='me'), + url(r'^$', about.IndexView.as_view(), name='index'), +] diff --git a/project/pages/urls/core.py b/project/pages/urls/core.py new file mode 100644 index 0000000..f104586 --- /dev/null +++ b/project/pages/urls/core.py @@ -0,0 +1,7 @@ +from django.conf.urls import url +from project.pages.views import core + + +urlpatterns = [ + url(r'^$', core.IndexView.as_view(), name='index') +] diff --git a/project/pages/urls/projects.py b/project/pages/urls/projects.py new file mode 100644 index 0000000..f1ecafe --- /dev/null +++ b/project/pages/urls/projects.py @@ -0,0 +1,8 @@ +from django.conf.urls import url +from project.pages.views import projects + + +urlpatterns = [ + url(r'^projects/all/$', projects.AllView.as_view(), name="all"), + url(r'^projects/(?P.+)/$', projects.ProjectView.as_view(), name="project") +] diff --git a/project/pages/urls/robotics.py b/project/pages/urls/robotics.py new file mode 100644 index 0000000..c74adc4 --- /dev/null +++ b/project/pages/urls/robotics.py @@ -0,0 +1,10 @@ +from django.conf.urls import url +from project.pages.views import robotics + + +urlpatterns = [ + url(r'^robotics/$', robotics.IndexView.as_view(), name="index"), + url(r'^robotics/2014/$', robotics.Index2014View.as_view(), name="2014-index"), + url(r'^robotics/2015/robot/$', robotics.Robot2015View.as_view(), name="2015-robot"), + url(r'^robotics/2015/$', robotics.Index2015View.as_view(), name="2015-index") +] diff --git a/project/urls.py b/project/urls.py index cdd8c78..d2719f2 100644 --- a/project/urls.py +++ b/project/urls.py @@ -7,7 +7,11 @@ urlpatterns = [ url(r'^reverse/$', include(reverse_urls, namespace='reverser')), url(r'^404/', Custom404View.as_view(), name="404"), url(r'^no-js/', NoJavascriptView.as_view(), name="no-js"), - url(r'', include('project.pages.urls', namespace='pages')) + url(r'^about/', include('project.pages.urls.about', namespace='about')), + url(r'^core/', include('project.pages.urls.core', namespace='core')), + url(r'^projects/', include('project.pages.urls.projects', namespace='projects')), + url(r'^robotics/', include('project.pages.urls.robotics', namespace='robotics')), + url(r'', include('project.pages.urls.core', namespace='pages')) ] # handler404 = Custom404View diff --git a/static/src/js/components/index/project-images-main.js b/static/src/js/components/index/project-images-main.js index 3606520..88336f8 100644 --- a/static/src/js/components/index/project-images-main.js +++ b/static/src/js/components/index/project-images-main.js @@ -7,7 +7,7 @@ const DATA = [ { title: 'Custom PC', text: 'Without my PCs, I wouldnt be able to do anything you see here.', - link: 'pages:about-me', + link: 'about:me', }, { title: 'BSOD-Enabler', @@ -32,7 +32,7 @@ const DATA = [ { title: 'Student Robotics', text: '', - link: 'pages:robotics-index', + link: 'robotics:index', } ]; diff --git a/static/src/js/components/navbar/navbar.js b/static/src/js/components/navbar/navbar.js index a2ee95c..fc6a886 100644 --- a/static/src/js/components/navbar/navbar.js +++ b/static/src/js/components/navbar/navbar.js @@ -18,11 +18,11 @@ export default class NavBar extends React.Component { diff --git a/static/src/less/navbar.less b/static/src/less/navbar.less index 541a82c..f42c96c 100644 --- a/static/src/less/navbar.less +++ b/static/src/less/navbar.less @@ -11,9 +11,12 @@ @media (min-width: @screen-md-min) { margin-right: 23px; } + &:not(.dropdown) > a { + padding-top: 12px; + } & > a { @media (min-width: @screen-md-min) { - padding: 15px 10px; + padding: 10px 10px; } @media (max-width: @screen-xs-max) { padding: 15px 15px; @@ -37,6 +40,7 @@ &.dropdown { top: 100%; bottom: initial; + height: @navbar-height; } .open & { opacity: 1; @@ -49,7 +53,7 @@ .navbar { - max-height: 52px; + max-height: @navbar-height; border-radius: 0; .home-button a { .transition(~"ease-in-out .3 all"); @@ -85,7 +89,7 @@ &.align { @media (min-width: @screen-sm) { position: absolute; - height: 52px; + height: @navbar-height; } @media (max-width: @screen-sm) { position: fixed; @@ -98,7 +102,7 @@ #navbar-anchor { position: absolute; - height: 52px; + height: @navbar-height; } @media (min-width: @screen-xs-max) { @@ -124,7 +128,7 @@ @media (min-width: @screen-xs-max) { navbar + * { - margin-top: 52px; + margin-top: @navbar-height; } } diff --git a/static/src/less/variables.less b/static/src/less/variables.less index 8155f87..91d4d69 100644 --- a/static/src/less/variables.less +++ b/static/src/less/variables.less @@ -142,7 +142,7 @@ @container-md: @container-desktop; @container-large-desktop: (1140px + @grid-gutter-width); @container-lg: @container-large-desktop; -@navbar-height: 50px; +@navbar-height: 52px; @navbar-margin-bottom: @line-height-computed; @navbar-border-radius: @border-radius-base; @navbar-padding-horizontal: floor((@grid-gutter-width / 2)); diff --git a/templates/about/index.html b/templates/about/index.html index 8cc93c6..52929c7 100644 --- a/templates/about/index.html +++ b/templates/about/index.html @@ -21,7 +21,7 @@ Some info about my website, which clearly works well as you're using it right now!

- More Info + More Info

@@ -37,7 +37,7 @@ Some info about me. Although not very much. Because Privacy!

- More Info + More Info

diff --git a/templates/base.html b/templates/base.html index f3aee95..3a25fdf 100644 --- a/templates/base.html +++ b/templates/base.html @@ -29,7 +29,7 @@ diff --git a/templates/projects/test.md b/templates/projects/test.md index 44b2f2f..e5e71f7 100644 --- a/templates/projects/test.md +++ b/templates/projects/test.md @@ -1,4 +1,4 @@ # Testing This page is for testing only. -Please [check out my other projects]({% url 'pages:all-projects' %}). +Please [check out my other projects]({% url 'projects:all' %}). diff --git a/templates/robotics/2015-index.html b/templates/robotics/2015-index.html index 12a6613..34cb88c 100644 --- a/templates/robotics/2015-index.html +++ b/templates/robotics/2015-index.html @@ -35,7 +35,7 @@
Quick Links - The Robot - A.L.I.C.E + The Robot - A.L.I.C.E The Code Gallery Blog diff --git a/templates/robotics/index.html b/templates/robotics/index.html index 01a4b6e..db07bce 100644 --- a/templates/robotics/index.html +++ b/templates/robotics/index.html @@ -24,7 +24,7 @@

Student Robotics 2014

Robot Name: Lucy

-

More Info

+

More Info

@@ -34,7 +34,7 @@

Student Robotics 2015

Robot Name : A.L.I.C.E (Autonomous Logistics and Inevitable Collision Engine)

-

More Info

+

More Info