diff options
author | luxagraf <sng@luxagraf.net> | 2015-12-07 20:19:06 -0500 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2015-12-07 20:19:06 -0500 |
commit | 6ad212ae8a542e93d173c2b8e6efcd68109380c8 (patch) | |
tree | a0ed068b994e40373a506196d57e48fdd673e6a2 | |
parent | e4a7f290d373427c36d7925e7381aadf16524936 (diff) |
added ability to edit resume landing and cv from pages app
-rw-r--r-- | app/TODO | 2 | ||||
-rw-r--r-- | app/pages/admin.py | 2 | ||||
-rw-r--r-- | app/pages/migrations/0001_initial.py | 27 | ||||
-rw-r--r-- | app/pages/migrations/0002_page_path.py | 20 | ||||
-rw-r--r-- | app/pages/migrations/__init__.py | 0 | ||||
-rw-r--r-- | app/pages/models.py | 2 | ||||
-rw-r--r-- | app/pages/views.py | 11 | ||||
-rw-r--r-- | app/resume/urls.py | 9 | ||||
-rw-r--r-- | app/resume/views.py | 10 | ||||
-rw-r--r-- | config/base_urls.py | 14 | ||||
-rw-r--r-- | design/templates/archives/resume.html | 30 | ||||
-rw-r--r-- | design/templates/details/resume.html | 19 |
12 files changed, 93 insertions, 53 deletions
@@ -63,3 +63,5 @@ Then resize all images for responsive gallery. Then play with gallery templates and add a template selecter to form. +like this full width design: http://www.photobyrichard.com/photobyrichard/page/2/ + diff --git a/app/pages/admin.py b/app/pages/admin.py index 844007e..977a0cf 100644 --- a/app/pages/admin.py +++ b/app/pages/admin.py @@ -22,7 +22,7 @@ class PageAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ('title',)} fieldsets = ( ('Page', { - 'fields': ('title', 'body_markdown', 'slug'), + 'fields': ('title', 'body_markdown', ('slug', 'path')), 'classes': ('show', 'extrapretty', 'wide') }), ('Metadata', { diff --git a/app/pages/migrations/0001_initial.py b/app/pages/migrations/0001_initial.py new file mode 100644 index 0000000..4e138f7 --- /dev/null +++ b/app/pages/migrations/0001_initial.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-03 17:02 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Page', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('slug', models.SlugField()), + ('body_html', models.TextField(blank=True)), + ('body_markdown', models.TextField()), + ('meta_description', models.CharField(blank=True, max_length=256, null=True)), + ], + ), + ] diff --git a/app/pages/migrations/0002_page_path.py b/app/pages/migrations/0002_page_path.py new file mode 100644 index 0000000..e09bfbc --- /dev/null +++ b/app/pages/migrations/0002_page_path.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2015-12-03 17:12 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('pages', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='page', + name='path', + field=models.CharField(blank=True, max_length=200, null=True), + ), + ] diff --git a/app/pages/migrations/__init__.py b/app/pages/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/app/pages/migrations/__init__.py diff --git a/app/pages/models.py b/app/pages/models.py index ed7b94e..9b7be7f 100644 --- a/app/pages/models.py +++ b/app/pages/models.py @@ -10,7 +10,7 @@ class Page(models.Model): body_html = models.TextField(blank=True) body_markdown = models.TextField() meta_description = models.CharField(max_length=256, null=True, blank=True) - #path = models.CharField(max_length=200, null=True, blank=True) + path = models.CharField(max_length=200, null=True, blank=True) def __unicode__(self): return self.title diff --git a/app/pages/views.py b/app/pages/views.py index 934cb40..026ab36 100644 --- a/app/pages/views.py +++ b/app/pages/views.py @@ -6,3 +6,14 @@ def page(request, slug): obj = get_object_or_404(Page, slug__exact=slug) context = {'object': obj, } return render_to_response(["details/%s.html" % obj.slug, 'details/page.html'], context, context_instance=RequestContext(request)) + +from django.views.generic.detail import DetailView + + +class PageDetailView(DetailView): + model = Page + slug_field = "slug" + + def get_template_names(self): + obj = self.get_object() + return ["details/%s.html" % obj.slug, 'details/page.html'] diff --git a/app/resume/urls.py b/app/resume/urls.py index ce9c435..bc54d36 100644 --- a/app/resume/urls.py +++ b/app/resume/urls.py @@ -22,13 +22,8 @@ urlpatterns = [ name="live-redirect" ), url( - r'^(?P<slug>[-\w]+)$', + r'^(?P<path>[-\w]+)(?:/(?P<slug>[-\w]+))$', views.PageView.as_view(), - name="cv" - ), - url( - r'^$', - views.BaseView.as_view(), - name="intro" + name="pages" ), ] diff --git a/app/resume/views.py b/app/resume/views.py index 7e5de14..d7230f7 100644 --- a/app/resume/views.py +++ b/app/resume/views.py @@ -30,11 +30,11 @@ class PageView(DetailView): slug_field = "slug" def get_queryset(self): - return Page.objects.filter(path__startswith=self.kwargs['slug']) + try: + return Page.objects.get(path__startswith=self.kwargs['path']) + except: + return Page.objects.get(path__startswith=self.kwargs['path'],slug=self.kwargs['slug']) + def get_template_names(self): return ["details/%s.html" % self.object.slug, 'details/page.html'] - - -class BaseView(TemplateView): - template_name = "archives/resume.html" diff --git a/config/base_urls.py b/config/base_urls.py index 9104d6e..b5751f0 100644 --- a/config/base_urls.py +++ b/config/base_urls.py @@ -5,6 +5,7 @@ from django.conf import settings from django.contrib.sitemaps.views import sitemap from pages.views import page +from pages.views import PageDetailView from jrnl.models import BlogSitemap from jrnl.views import HomepageList from locations.models import WritingbyCountrySitemap @@ -58,14 +59,8 @@ urlpatterns += [ ), url(r'^travel-guide/', include('guide.urls')), url(r'^src/', include('src.urls', namespace='src')), - url( - r'^figments/', - include('figments.urls', namespace='figments') - ), - url( - r'^resume/', - include('resume.urls', namespace='resume') - ), + url(r'^figments/', include('figments.urls', namespace='figments')), + url(r'^resume/', include('resume.urls', namespace='resume')), url(r'^map', include('locations.urls')), url( r'^$', @@ -73,7 +68,8 @@ urlpatterns += [ name="homepage" ), # pages - url(r'^(?P<slug>[-\w]+)/?$', page), + url(r'^(?P<slug>[-\w]+)/?$', PageDetailView.as_view()), + url(r'^(?P<path>[-\w]+)/(?P<slug>[-\w]+)?$', PageDetailView.as_view()), ] urlpatterns += [ diff --git a/design/templates/archives/resume.html b/design/templates/archives/resume.html deleted file mode 100644 index c173460..0000000 --- a/design/templates/archives/resume.html +++ /dev/null @@ -1,30 +0,0 @@ -{% extends 'base.html' %} -{% load typogrify_tags %} - -{% block pagetitle %}{% endblock %} -{% block metadescription %}{% endblock %} - - -{% block primary %}<ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> - <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> - <li>Resume</li> - </ul> - <main role="main"> -<p class="intro">Hello</p> - -<p>This is the website of Scott Gilbertson. I am a writer and publisher living in Athens, Georgia.</p> - -<p>I used to work for Wired.com, where I wrote for and later edited/produced <a href="http://www.webmonkey.com/">Webmonkey.com</a> among other sites. I still <a href="http://www.wired.com/reviews/author/scott-gilbertson/">freelance</a> for Wired (also, <a href="http://www.wired.com/author/luxagraf/">here</a>) and I write about open source software and related topics for publications like <a href="http://arstechnica.com/">Ars Technica</a>, <a href="theregister.co.uk/Author/1785">The Register</a> and elsewhere.</p> - -<p>I’ve also been published in some dead tree magazines like Consumer Digest and Budget Travel. I once appeared on National Public Radio.</p> - -<p>Perpetually out of date <a href="/resume/cv">curriculum vitæ</a> available for those who like such things.</p> - -<p>The personal section of my site, which is primarily about my travels can be found at <a href="https://luxagraf.net/">the root of this URL</a>.</p> - -<p>If you’d like me to write, edit, develop or consult on a website, you can contact me at sng @ luxagraf.net. For consulting on writing or web development projects, please get in touch via my <a href="https://clarity.fm/scottgilbertson">clarity.fm profile</a>.</p> - - -<p>Thank you for visiting.</p> - </main> - {%endblock%} diff --git a/design/templates/details/resume.html b/design/templates/details/resume.html new file mode 100644 index 0000000..6274e34 --- /dev/null +++ b/design/templates/details/resume.html @@ -0,0 +1,19 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} + +{% block pagetitle %}{% endblock %} +{% block metadescription %}{% endblock %} + + +{% block primary %}<ul class="bl" id="breadcrumbs" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> + <li><a href="/" title="luxagraf homepage" itemprop="url"><span itemprop="title">Home</span></a> → </li> + <li>Resume</li> + </ul> + <main role="main"> + <article role="main"> + <div class="post--article" style="margin-top: 3em"> + {{object.body_html|safe|smartypants|widont}} + </div> + </article> + </main> + {%endblock%} |