diff options
Diffstat (limited to 'bak/unused_apps/src')
-rw-r--r-- | bak/unused_apps/src/__init__.py | 0 | ||||
-rw-r--r-- | bak/unused_apps/src/admin.py | 62 | ||||
-rw-r--r-- | bak/unused_apps/src/build.py | 62 | ||||
-rw-r--r-- | bak/unused_apps/src/migrations/0001_initial.py | 76 | ||||
-rw-r--r-- | bak/unused_apps/src/migrations/0002_auto_20160329_2107.py | 19 | ||||
-rw-r--r-- | bak/unused_apps/src/migrations/0003_auto_20180707_0958.py | 17 | ||||
-rw-r--r-- | bak/unused_apps/src/migrations/0004_auto_20191007_0905.py | 17 | ||||
-rw-r--r-- | bak/unused_apps/src/migrations/__init__.py | 0 | ||||
-rw-r--r-- | bak/unused_apps/src/models.py | 171 | ||||
-rw-r--r-- | bak/unused_apps/src/templates/src/srcpost_detail.html | 112 | ||||
-rw-r--r-- | bak/unused_apps/src/templates/src/srcpost_list.html | 30 | ||||
-rw-r--r-- | bak/unused_apps/src/templates/src/topic_list.html | 35 | ||||
-rw-r--r-- | bak/unused_apps/src/urls.py | 49 | ||||
-rw-r--r-- | bak/unused_apps/src/views.py | 89 |
14 files changed, 739 insertions, 0 deletions
diff --git a/bak/unused_apps/src/__init__.py b/bak/unused_apps/src/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/bak/unused_apps/src/__init__.py diff --git a/bak/unused_apps/src/admin.py b/bak/unused_apps/src/admin.py new file mode 100644 index 0000000..f354b15 --- /dev/null +++ b/bak/unused_apps/src/admin.py @@ -0,0 +1,62 @@ +from django.contrib import admin +from .models import Topic, SrcPost, Book +from utils.widgets import LGEntryForm + + +@admin.register(Topic) +class TopicAdmin(admin.ModelAdmin): + prepopulated_fields = {"slug": ('name',), "pluralized_name": ('name',)} + + +@admin.register(Book) +class BookAdmin(admin.ModelAdmin): + prepopulated_fields = {"slug": ('title', )} + list_display = ('title', 'pub_date', 'status') + fieldsets = ( + ('Entry', { + 'fields': ( + 'title', + 'body_markdown', + 'image', + ('pub_date', 'status'), + ('price', 'price_sale'), + 'meta_description', + ('slug', 'template_name', 'pages'), + ), + 'classes': ( + 'show', + 'extrapretty', + 'wide' + ) + } + ), + ) + + +@admin.register(SrcPost) +class PostAdmin(admin.ModelAdmin): + form = LGEntryForm + list_display = ('title', 'pub_date', 'enable_comments', 'status') + list_filter = ('pub_date', 'enable_comments', 'status') + prepopulated_fields = {"slug": ('title',)} + fieldsets = ( + ('Entry', { + 'fields': ( + 'title', + 'body_markdown', + ('pub_date', 'status'), + 'topics', + 'meta_description', + ('slug', 'enable_comments', 'has_code', 'template_name'), + ), + 'classes': ( + 'show', + 'extrapretty', + 'wide' + ) + } + ), + ) + + class Media: + js = ('image-loader.js', 'next-prev-links.js') diff --git a/bak/unused_apps/src/build.py b/bak/unused_apps/src/build.py new file mode 100644 index 0000000..a16bdaf --- /dev/null +++ b/bak/unused_apps/src/build.py @@ -0,0 +1,62 @@ +import os +from builder.base import BuildNew +from django.urls import reverse +from . import models + + +class BuildSrc(BuildNew): + + def build(self): + self.build_list_view( + base_path=reverse("src:list"), + paginate_by=99999 + ) + self.build_list_view( + base_path=reverse("src:list_books"), + paginate_by=99999 + ) + self.build_detail_view() + # These are the unique classes for this model: + # self.build_books_view() + self.build_topic_view() + self.build_feed("src:feed") + + def build_topic_view(self): + for topic in models.Topic.objects.all(): + ctype = ContentType.objects.get(app_label='posts', model='post') + for cat in Category.objects.all(): + + url = reverse("src:list_topics", kwargs={'slug': topic.slug, }) + path, slug = os.path.split(url) + response = self.client.get(url, HTTP_HOST='127.0.0.1') + self.write_file('%s/' % path, response.content, filename=slug) + + def build_books_view(self): + for obj in models.Book.objects.all(): + url = reverse("src:detail_book", kwargs={'slug': obj.slug, }) + path, slug = os.path.split(url) + response = self.client.get(url, HTTP_HOST='127.0.0.1') + self.write_file('%s/' % path, response.content, filename=slug) + + +def builder(): + j = BuildSrc("src", "srcpost") + j.build() + + +""" + + + + + def build_books(self): + path = 'src/books/' + c = Context({ + 'object_list': Book.objects.filter(status__exact=1), + 'MEDIA_URL': settings.BAKED_MEDIA_URL, + 'IMAGES_URL': settings.BAKED_IMAGES_URL + }) + t = render_to_string('archives/src_books.html', c).encode('utf-8') + self.write_file(path, t) + +""" diff --git a/bak/unused_apps/src/migrations/0001_initial.py b/bak/unused_apps/src/migrations/0001_initial.py new file mode 100644 index 0000000..1f672ee --- /dev/null +++ b/bak/unused_apps/src/migrations/0001_initial.py @@ -0,0 +1,76 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-03-29 21:06 +from __future__ import unicode_literals + +from django.db import migrations, models +import src.models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Book', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('image', models.FileField(blank=True, null=True, upload_to=src.models.get_upload_path)), + ('slug', models.SlugField(unique_for_date='pub_date')), + ('body_html', models.TextField(blank=True)), + ('body_markdown', models.TextField()), + ('pub_date', models.DateTimeField(verbose_name='Date published')), + ('last_updated', models.DateTimeField(auto_now=True)), + ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=0)), + ('price', models.FloatField()), + ('price_sale', models.FloatField()), + ('meta_description', models.CharField(blank=True, max_length=256, null=True)), + ('pages', models.DecimalField(blank=True, decimal_places=0, max_digits=3, null=True)), + ('template_name', models.CharField(choices=[('details/src_book.html', 'Default'), ('details/src_book_2.html', 'Book Two')], default='details/src_book.html', max_length=200)), + ], + options={ + 'get_latest_by': 'pub_date', + 'ordering': ('-pub_date',), + }, + ), + migrations.CreateModel( + name='Entry', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=200)), + ('slug', models.SlugField(unique_for_date='pub_date')), + ('body_html', models.TextField(blank=True)), + ('body_markdown', models.TextField()), + ('pub_date', models.DateTimeField(verbose_name='Date published')), + ('last_updated', models.DateTimeField(auto_now=True)), + ('enable_comments', models.BooleanField(default=False)), + ('has_code', models.BooleanField(default=False)), + ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=0)), + ('meta_description', models.CharField(blank=True, max_length=256, null=True)), + ('template_name', models.IntegerField(choices=[(0, 'default')], default=0)), + ], + options={ + 'get_latest_by': 'pub_date', + 'ordering': ('-pub_date',), + 'verbose_name_plural': 'entries', + }, + ), + migrations.CreateModel( + name='Topic', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=60)), + ('slug', models.SlugField()), + ('pluralized_name', models.CharField(max_length=60)), + ], + ), + migrations.AddField( + model_name='entry', + name='topics', + field=models.ManyToManyField(blank=True, to='src.Topic'), + ), + ] diff --git a/bak/unused_apps/src/migrations/0002_auto_20160329_2107.py b/bak/unused_apps/src/migrations/0002_auto_20160329_2107.py new file mode 100644 index 0000000..25f5e4e --- /dev/null +++ b/bak/unused_apps/src/migrations/0002_auto_20160329_2107.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9 on 2016-03-29 21:07 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('src', '0001_initial'), + ] + + operations = [ + migrations.RenameModel( + old_name='Entry', + new_name='Post', + ), + ] diff --git a/bak/unused_apps/src/migrations/0003_auto_20180707_0958.py b/bak/unused_apps/src/migrations/0003_auto_20180707_0958.py new file mode 100644 index 0000000..f619888 --- /dev/null +++ b/bak/unused_apps/src/migrations/0003_auto_20180707_0958.py @@ -0,0 +1,17 @@ +# Generated by Django 2.0.1 on 2018-07-07 09:58 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('src', '0002_auto_20160329_2107'), + ] + + operations = [ + migrations.AlterModelOptions( + name='post', + options={'get_latest_by': 'pub_date', 'ordering': ('-pub_date',), 'verbose_name_plural': 'posts'}, + ), + ] diff --git a/bak/unused_apps/src/migrations/0004_auto_20191007_0905.py b/bak/unused_apps/src/migrations/0004_auto_20191007_0905.py new file mode 100644 index 0000000..6c223a0 --- /dev/null +++ b/bak/unused_apps/src/migrations/0004_auto_20191007_0905.py @@ -0,0 +1,17 @@ +# Generated by Django 2.2.6 on 2019-10-07 09:05 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('src', '0003_auto_20180707_0958'), + ] + + operations = [ + migrations.RenameModel( + old_name='Post', + new_name='SrcPost', + ), + ] diff --git a/bak/unused_apps/src/migrations/__init__.py b/bak/unused_apps/src/migrations/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/bak/unused_apps/src/migrations/__init__.py diff --git a/bak/unused_apps/src/models.py b/bak/unused_apps/src/models.py new file mode 100644 index 0000000..69d85a5 --- /dev/null +++ b/bak/unused_apps/src/models.py @@ -0,0 +1,171 @@ +import re +from django.db import models +from django.urls import reverse +from django.contrib.sitemaps import Sitemap +from django.conf import settings +import datetime +from itertools import chain + +from utils.util import parse_image, markdown_to_html + + +def render_images(s): + s = re.sub('<img(.*)/>', parse_image, s) + return s + + +class Topic(models.Model): + name = models.CharField(max_length=60) + slug = models.SlugField() + pluralized_name = models.CharField(max_length=60) + + def __str__(self): + return self.name + + def get_absolute_url(self): + return reverse('src:list_topics', kwargs={"slug": self.slug}) + + @property + def pub_date(self): + return datetime.datetime.now() + + +class SrcPost(models.Model): + title = models.CharField(max_length=200) + slug = models.SlugField(unique_for_date='pub_date') + body_html = models.TextField(blank=True) + body_markdown = models.TextField() + pub_date = models.DateTimeField('Date published') + topics = models.ManyToManyField(Topic, blank=True) + last_updated = models.DateTimeField(auto_now=True) + enable_comments = models.BooleanField(default=False) + has_code = models.BooleanField(default=False) + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=0) + meta_description = models.CharField(max_length=256, null=True, blank=True) + TEMPLATES = ( + (0, 'default'), + ) + template_name = models.IntegerField(choices=TEMPLATES, default=0) + + class Meta: + ordering = ('-pub_date',) + get_latest_by = 'pub_date' + verbose_name_plural = 'posts' + + def __str__(self): + return self.title + + def get_absolute_url(self): + return reverse('src:detail', kwargs={"slug": self.slug}) + + def comment_period_open(self): + return self.enable_comments and datetime.datetime.today() - datetime.timedelta(30) <= self.pub_date + + @property + def get_previous_published(self): + return self.get_previous_by_pub_date(status__exact=1) + + @property + def get_next_published(self): + return self.get_next_by_pub_date(status__exact=1) + + def save(self): + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + super(SrcPost, self).save() + + +def get_upload_path(self, filename): + return "images/src/%s" % filename + + +class Book(models.Model): + title = models.CharField(max_length=200) + image = models.FileField(blank=True, null=True, upload_to=get_upload_path) + slug = models.SlugField(unique_for_date='pub_date') + body_html = models.TextField(blank=True) + body_markdown = models.TextField() + pub_date = models.DateTimeField('Date published') + last_updated = models.DateTimeField(auto_now=True) + PUB_STATUS = ( + (0, 'Draft'), + (1, 'Published'), + ) + status = models.IntegerField(choices=PUB_STATUS, default=0) + price = models.FloatField() + price_sale = models.FloatField() + meta_description = models.CharField(max_length=256, null=True, blank=True) + pages = models.DecimalField(max_digits=3, decimal_places=0, null=True, blank=True) + DEFAULT = 'details/src_book.html' + BOOK2 = 'details/src_book_2.html' + TEMPLATES = ( + (DEFAULT, 'Default'), + (BOOK2, 'Book Two'), + ) + template_name = models.CharField( + max_length=200, + choices=TEMPLATES, + default=DEFAULT + ) + + class Meta: + ordering = ('-pub_date',) + get_latest_by = 'pub_date' + + def __str__(self): + return self.title + + def get_absolute_url(self): + return reverse('src:detail_book', kwargs={"slug": self.slug}) + + def get_image_url(self): + img = self.image.url.split('src/')[1] + return '%ssrc/%s' % (settings.IMAGES_URL, img) + + def save(self): + md = render_images(self.body_markdown) + self.body_html = markdown_to_html(md) + super(Book, self).save() + + +'''class SrcDemo(models.Model): + title = models.CharField(max_length=254) + slug = models.SlugField() + body = models.TextField(blank=True, null=True) + head = models.TextField(blank=True, null=True) + DEMO_TEMPLATES = ( + (0, 'Blank'), + (1, 'Basic_light'), + ) + template = models.IntegerField(choices=DEMO_TEMPLATES, default=0) + pub_date = models.DateTimeField('Date published', blank=True) + + class Meta: + verbose_name_plural = "Demos" + app_label = 'projects' + ordering = ('-pub_date',) + + def save(self): + if not self.id: + self.pub_date = datetime.datetime.now() + super(SrcDemo, self).save() +''' + + +class SrcSitemap(Sitemap): + changefreq = "never" + priority = 0.7 + protocol = "https" + + def items(self): + return list(chain( + SrcPost.objects.filter(status=1), + Topic.objects.all() + )) + + def lastmod(self, obj): + return obj.pub_date diff --git a/bak/unused_apps/src/templates/src/srcpost_detail.html b/bak/unused_apps/src/templates/src/srcpost_detail.html new file mode 100644 index 0000000..733f586 --- /dev/null +++ b/bak/unused_apps/src/templates/src/srcpost_detail.html @@ -0,0 +1,112 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} +{% block pagetitle %}{{object.title|striptags}} - by Scott Gilbertson{% endblock %} +{% block metadescription %}{% autoescape on %}{{object.meta_description|striptags|safe}}{% endautoescape %}{% endblock %} +{%block extrahead%} + <meta property="og:type" content="article" /> + <meta property="og:site_name" content="luxagraf:src"/> + <meta property="og:title" content="{{object.title|safe}}" /> + <meta property="og:url" content="https://luxagraf.net{{object.get_absolute_url}}" /> + <meta property="og:image" content=""> + <meta property="og:description" content="{{object.meta_description}}" /> + <meta property="article:published_time" content="{{object.pub_date|date:'c'}}" /> + <meta property="article:author" content="Luxagraf" /> + <meta property="og:site_name" content="Luxagraf:src" /> + <meta property="og:locale" content="en_US" /> + <meta name="twitter:card" content="summary_large_image"/> + <meta name="twitter:site" content="@luxagraf"/> + <meta name="twitter:creator" content="@luxagraf"/> + <link rel="stylesheet" href="/media/src/solarized.css" type="text/css" media="screen"/> +{%endblock%} + +{% block bodyid %}class="src detail single"{% endblock %} +{%block sitesubtitle %}Code Slowly{% endblock%} +{% block breadcrumbs %}<ol class="bl" id="breadcrumbs" itemscope itemtype="http://schema.org/BreadcrumbList"> + <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> + <a itemprop="item" href="/"> + <span itemprop="name">Home</span> + </a> → + <meta itemprop="position" content="1" /> + </li> + <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> + <a href="/src/" itemprop="item"> + <span itemprop="name">Src</span> + </a> + <meta itemprop="position" content="2" /> + </li> + </ol>{% endblock %} +{% block primary %}<main role="main"> + <article class="hentry post-article{% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %} post--article--double{%endif%}{%endwith%}" itemscope itemType="http://schema.org/Article"> + <header id="header" class="post-header {% with object.get_template_name_display as t %}{%if t == "double" or t == "double-dark" %}post--header--double{%endif%}{%endwith%}"> + <h1 class="p-name entry-title post--title" itemprop="headline">{%if object.template_name == 1 or object.template_name == 3 %}{{object.title|safe|smartypants}}{%else%}{{object.title|safe|smartypants|widont}}{%endif%}</h1> + <h2 class="post-subtitle">{{object.meta_description|smartypants|safe}}</h2> + <div class="post-linewrapper"> + {% if object.originally_published_by %}<h4 class="post-source">Originally Published By: <a href="{{object.originally_published_by_url}}" title="View {{object.title}} on {{object.originally_published_by}}">{{object.originally_published_by}}</a></h4>{%endif%} + {% if object.topics.all %}<h4 class="post-source">Topics: {% for topic in object.topics.all%} <a href="/src/topic/{{topic.slug}}">{{topic.name}}</a>{%if forloop.last%}{%else%}, {%endif%}{%endfor%}</h4>{%endif%} + <time class="dt-published published dt-updated post-date" datetime="{{object.pub_date|date:'c'}}" itemprop="datePublished">{{object.pub_date|date:"F"}} <span>{{object.pub_date|date:"j, Y"}}</span></time> + <span class="hide" itemprop="author" itemscope itemtype="http://schema.org/Person">by <a class="p-author h-card" href="/about"><span itemprop="name">Scott Gilbertson</span></a></span> + </div> + </header> + + + <div id="article" class="e-content entry-content post-body post-body-{% with object.template_name as t %}{%if t == 0 or t == 2 %}single{%endif%}{%if t == 1 or t == 3 %}double{%endif%}{%endwith%}" itemprop="articleBody"> + {{object.body_html|safe|smartypants|widont}} + </div> + </article> + {% if object.slug != 'about' %} + {% with object.get_next_published as next %} + {% with object.get_previous_published as prev %} + <nav id="page-navigation"> + <ul>{% if prev%} + <li id="prev"><span class="bl">Previous:</span> + <a href="{{ prev.get_absolute_url }}" rel="prev" title=" {{prev.title}}">{{prev.title|safe}}</a> + </li>{%endif%}{% if next%} + <li id="next"><span class="bl">Next:</span> + <a href="{{ next.get_absolute_url }}" rel="next" title=" {{next.title}}">{{next.title|safe}}</a> + </li>{%endif%} + </ul> + </nav>{%endwith%}{%endwith%} + {%endif%} + </main> + {% if object.slug != 'about' %} + {% if object.enable_comments %} +{% get_comment_count for object as comment_count %} +{%if comment_count > 0 %} +<p class="comments--header">{{comment_count}} Comment{{ comment_count|pluralize }}</p> +{% render_comment_list for object %} +{%endif%} +<div class="comment--form--wrapper {%if comment_count > 0%}comment-form-border{%endif%}"> +{% render_comment_form for object %} +</div> +{% else %} +<p class="comments--header" style="text-align: center">Sorry, comments have been disabled for this post.</p> +{%endif%} +{%endif%} +{% endblock %} +{% block js %} +<script type="text/javascript"> +window.onload = function() { + {% if object.enable_comments %} +{% get_comment_count for object as comment_count %} +{%if comment_count > 0 %} + //delay loading of gravatar images using noscript data-hash attribute + dataattr = document.getElementsByClassName("datahashloader"); + for(var i=0; i<dataattr.length; i++) { + var c = dataattr[i].parentNode; + var img = document.createElement("img"); + img.src = 'https://images.luxagraf.net/gravcache/' + dataattr[i].getAttribute('data-hash') + '.jpg'; + img.className += "gravatar"; + c.insertBefore(img, c.childNodes[3]); + } +{%endif%} +{%endif%} + {% with object.get_template_name_display as t %}{%if t == "single" or t == "single-dark" %} + createMap(); + var open = false; + {%endif%}{%endwith%} +} +</script> +{% if object.has_code %} +{%endif %} +{% endblock %} diff --git a/bak/unused_apps/src/templates/src/srcpost_list.html b/bak/unused_apps/src/templates/src/srcpost_list.html new file mode 100644 index 0000000..dd5d410 --- /dev/null +++ b/bak/unused_apps/src/templates/src/srcpost_list.html @@ -0,0 +1,30 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} + +{% block pagetitle %}Tutorials and tools for building great things{% endblock %} +{% block metadescription %}Tutorials and tools for building great things on the web - by Scott Gilbertson.{% endblock %} +{%block sitesubtitle %}Code Slowly{% endblock%} +{% block breadcrumbs %}{% include "lib/breadcrumbs.html" with breadcrumbs=breadcrumbs %}{% endblock %} +{% block primary %}<main role="main" id="essay-archive" class="essay-archive archive-list"> + <div class="essay-intro"> + <h2>Tutorials and tools for building great things on the web.</h2> + <p>The indie web is an amazing democratic publishing platform unlike anything in history. The catch is, to avoid serving at the pleasure of the corporate king, you need to know <em>how</em> to publish. That's what these articles are here for, to help you learn how to use independent, community supported open source tools. The web won't last forever, let's build something cool while we can.</p> + <p>Topics include HTML, CSS, Django, Linux, Nginx, Python, Postgresql, free software, and, once, the evil that is Google AMP.</p> + <p>A few of the articles below were previously published in: <em><a href="https://arstechnica.com/">Ars Technica</a></em>, <em><a href="https://www.wired.com/author/scott-gilbertson/">Wired</a></em>, and <em><a href="https://www.theregister.co.uk/Author/Scott-Gilbertson/">The Register</a></em></p> + </div> + <h1 class="topic-hed">Articles</h1> + <ul class="fancy-archive-list">{% for object in object_list %}{% if object.slug != 'about' %} + <li class="h-entry hentry" itemscope itemType="http://schema.org/Article"> + <span class="date dt-published">{{object.pub_date|date:"F Y"}}</span> + <a href="{{object.get_absolute_url}}"> + <h2>{{object.title|safe|smartypants|widont}}</h2> + <p class="p-summary">{{object.meta_description|safe|smartypants|widont}}</p> + </a> + </li> + {%endif%}{%endfor%}</ul> + + + + </main> +{%endblock%} diff --git a/bak/unused_apps/src/templates/src/topic_list.html b/bak/unused_apps/src/templates/src/topic_list.html new file mode 100644 index 0000000..7149823 --- /dev/null +++ b/bak/unused_apps/src/templates/src/topic_list.html @@ -0,0 +1,35 @@ +{% extends 'base.html' %} +{% load typogrify_tags %} +{% load comments %} + +{% block pagetitle %}Tutorials and tools for building great things{% endblock %} + +{% block metadescription %}Tutorials about {{topic}} - by Scott Gilbertson.{% endblock %} +{%block sitesubtitle %}Code Slowly{% 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>{% if topic %} + <li><a href="/src/" title="luxagraf:src homepage" itemprop="url"><span itemprop="title"><code>src</code></span></a> → </li> + <li>{{topic}}</li>{%else%} + <li><code>src</code></li>{%endif%} + </ul> + <main role="main" id="essay-archive" class="essay-archive archive-list"> + <div class="essay-intro"> + <h2>Tutorials and tools for building great things on the web.</h2> + <p>The indie web is an amazing democratic publishing platform unlike anything in history. The catch is, to avoid serving at the pleasure of the corporate king, you need to know <em>how</em> to publish. That's what these articles are here for, to help you learn how to use independent, community supported open source tools. The web won't last forever, let's build something cool while we can.</p> + <p>A few of the articles below were previously published in: <em><a href="https://arstechnica.com/">Ars Technica</a></em>, <em><a href="https://www.wired.com/author/scott-gilbertson/">Wired</a></em>, and <em><a href="https://www.theregister.co.uk/Author/Scott-Gilbertson/">The Register</a></em></p> + </div> + <h1 class="topic-hed">Tutorials about {{topic}}</h1> + <ul class="fancy-archive-list">{% for object in object_list %}{% if object.slug != 'about' %} + <li class="h-entry hentry" itemscope itemType="http://schema.org/Article"> + <span class="date dt-published">{{object.pub_date|date:"F Y"}}</span> + <a href="{{object.get_absolute_url}}"> + <h2>{{object.title|safe|smartypants|widont}}</h2> + <p class="p-summary">{{object.meta_description|safe|smartypants|widont}}</p> + </a> + </li> + {%endif%}{%endfor%}</ul> + + + + </main> +{%endblock%} diff --git a/bak/unused_apps/src/urls.py b/bak/unused_apps/src/urls.py new file mode 100644 index 0000000..0ac6897 --- /dev/null +++ b/bak/unused_apps/src/urls.py @@ -0,0 +1,49 @@ +from django.urls import path, re_path + +from . import views + +app_name = "src" + +urlpatterns = [ + path( + r'feed.xml', + views.SrcRSSFeedView(), + name="feed" + ), + path( + r'topic/<str:slug>', + views.TopicListView.as_view(), + name="list_topics" + ), + path( + r'books/<str:slug>', + views.BookDetailView.as_view(), + name='detail_book' + ), + path( + r'books/', + views.BookListView.as_view(), + name='list_books' + ), + path( + r'<str:slug>.txt', + views.EntryDetailViewTXT.as_view(), + name="detail-txt" + ), + path( + r'<str:slug>', + views.EntryDetailView.as_view(), + name="detail" + ), + re_path( + r'<int:page>', + views.SrcListView.as_view(), + name="list" + ), + path( + r'', + views.SrcListView.as_view(), + {'page':1}, + name="list" + ), +] diff --git a/bak/unused_apps/src/views.py b/bak/unused_apps/src/views.py new file mode 100644 index 0000000..7540e02 --- /dev/null +++ b/bak/unused_apps/src/views.py @@ -0,0 +1,89 @@ +from django.views.generic import ListView +from django.views.generic.detail import DetailView +from django.contrib.syndication.views import Feed +from django.urls import reverse +from django.conf import settings + +#from paypal.standard.forms import PayPalPaymentsForm +from utils.views import PaginatedListView +from .models import SrcPost, Topic, Book + + +class BookListView(ListView): + template_name = "archives/src_books.html" + + def queryset(self): + return Book.objects.filter(status__exact=1) + + +class BookDetailView(DetailView): + model = Book + + def get_template_names(self): + book = self.get_object() + return [book.template_name] + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(BookDetailView, self).get_context_data(**kwargs) + book = self.get_object() + if book.price_sale < book.price: + price = book.price_sale + else: + price = book.price + #paypal_dict = { + # "business": settings.PAYPAL_RECEIVER_EMAIL, + # "amount": price, + # "item_name": book.title, + # "invoice": "unique-invoice-id", + # "notify_url": "https://luxagraf.net/src/paypal/" + reverse('src:paypal-ipn'), + # "return_url": "https://luxagraf.net/src/thank-you", + # "cancel_return": "https://luxagraf.net/src/books/", + #} + #context['paypal_form'] = PayPalPaymentsForm(initial=paypal_dict) + return context + + +class SrcListView(PaginatedListView): + model = SrcPost + + def get_queryset(self): + return SrcPost.objects.filter(status__exact=1) + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(SrcListView, self).get_context_data(**kwargs) + context['topics'] = Topic.objects.all() + return context + + +class EntryDetailView(DetailView): + model = SrcPost + slug_field = "slug" + + +class EntryDetailViewTXT(EntryDetailView): + template_name = "jrnl/entry_detail.txt" + + +class TopicListView(ListView): + template_name = 'src/topic_list.html' + + def get_queryset(self): + return SrcPost.objects.filter(topics__slug=self.kwargs['slug']) + + def get_context_data(self, **kwargs): + # Call the base implementation first to get a context + context = super(TopicListView, self).get_context_data(**kwargs) + context['topic'] = Topic.objects.get(slug__exact=self.kwargs['slug']) + return context + + +class SrcRSSFeedView(Feed): + title = "luxagraf:src Code and Technology" + link = "/src/" + description = "Latest postings to luxagraf.net/src" + description_template = 'feeds/blog_description.html' + + def items(self): + return SrcPost.objects.filter(status__exact=1).order_by('-pub_date')[:10] |