summaryrefslogtreecommitdiff
path: root/app/links
diff options
context:
space:
mode:
Diffstat (limited to 'app/links')
-rw-r--r--app/links/__init__.py0
-rw-r--r--app/links/admin.py32
-rw-r--r--app/links/build.py22
-rw-r--r--app/links/migrations/0001_initial.py43
-rw-r--r--app/links/migrations/0002_auto_20190501_1054.py44
-rw-r--r--app/links/migrations/__init__.py0
-rw-r--r--app/links/models.py46
-rw-r--r--app/links/urls.py39
-rw-r--r--app/links/views.py65
9 files changed, 291 insertions, 0 deletions
diff --git a/app/links/__init__.py b/app/links/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/links/__init__.py
diff --git a/app/links/admin.py b/app/links/admin.py
new file mode 100644
index 0000000..9ee9fbf
--- /dev/null
+++ b/app/links/admin.py
@@ -0,0 +1,32 @@
+from django.contrib import admin
+
+from utils.widgets import LGEntryForm
+
+from .models import Link
+
+
+@admin.register(Link)
+class EntryAdmin(admin.ModelAdmin):
+ form = LGEntryForm
+ list_display = ('title', 'pub_date', 'status')
+ list_filter = ('pub_date', 'status')
+ prepopulated_fields = {"slug": ('title',)}
+ fieldsets = (
+ ('Link', {
+ 'fields': (
+ 'title',
+ 'body_markdown',
+ 'slug',
+ 'link_url',
+ ('pub_date', 'status'),
+ ),
+ 'classes': (
+ 'show',
+ 'extrapretty',
+ 'wide'
+ )
+ }),
+ )
+
+ class Media:
+ js = ('next-prev-links.js')
diff --git a/app/links/build.py b/app/links/build.py
new file mode 100644
index 0000000..392e991
--- /dev/null
+++ b/app/links/build.py
@@ -0,0 +1,22 @@
+import os
+from builder.base import BuildNew
+from django.urls import reverse
+from . import models
+
+
+class BuildEssays(BuildNew):
+
+ def build(self):
+ self.build_list_view()
+ self.build_detail_view()
+ # These are the unique classes for this model:
+ #self.build_feed("src:feed")
+
+ def build_list_view(self):
+ response = self.client.get('/essays/')
+ self.write_file('essays/', response.content)
+
+
+def essaybuilder():
+ j = BuildEssays("essays", "essay")
+ j.build()
diff --git a/app/links/migrations/0001_initial.py b/app/links/migrations/0001_initial.py
new file mode 100644
index 0000000..be54329
--- /dev/null
+++ b/app/links/migrations/0001_initial.py
@@ -0,0 +1,43 @@
+# Generated by Django 2.1.7 on 2019-03-30 17:07
+
+from django.db import migrations, models
+import django.db.models.deletion
+import taggit.managers
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ('photos', '0001_initial'),
+ ('taxonomy', '__first__'),
+ ]
+
+ operations = [
+ 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)),
+ ('sub_title', models.CharField(blank=True, max_length=200)),
+ ('dek', models.TextField(blank=True)),
+ ('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)),
+ ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=0)),
+ ('meta_description', models.CharField(blank=True, max_length=256, null=True)),
+ ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='taxonomy.Category')),
+ ('featured_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='photos.LuxImage')),
+ ('tags', taggit.managers.TaggableManager(blank=True, help_text='Topics Covered', through='taxonomy.TaggedItems', to='taxonomy.LuxTag', verbose_name='Tags')),
+ ],
+ options={
+ 'get_latest_by': 'pub_date',
+ 'verbose_name_plural': 'Essays',
+ 'ordering': ('-pub_date',),
+ },
+ ),
+ ]
diff --git a/app/links/migrations/0002_auto_20190501_1054.py b/app/links/migrations/0002_auto_20190501_1054.py
new file mode 100644
index 0000000..b4ca5d1
--- /dev/null
+++ b/app/links/migrations/0002_auto_20190501_1054.py
@@ -0,0 +1,44 @@
+# Generated by Django 2.1.7 on 2019-05-01 15:54
+
+from django.db import migrations, models
+import taggit.managers
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('taxonomy', '0001_initial'),
+ ('links', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='Link',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('title', models.CharField(max_length=200)),
+ ('link_url', models.URLField(max_length=400)),
+ ('pub_date', models.DateTimeField(verbose_name='Date published')),
+ ('slug', models.SlugField(unique_for_date='pub_date')),
+ ('body_html', models.TextField(blank=True)),
+ ('body_markdown', models.TextField()),
+ ('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Published')], default=0)),
+ ('tags', taggit.managers.TaggableManager(blank=True, help_text='Topics Covered', through='taxonomy.TaggedItems', to='taxonomy.LuxTag', verbose_name='Tags')),
+ ],
+ ),
+ migrations.RemoveField(
+ model_name='entry',
+ name='category',
+ ),
+ migrations.RemoveField(
+ model_name='entry',
+ name='featured_image',
+ ),
+ migrations.RemoveField(
+ model_name='entry',
+ name='tags',
+ ),
+ migrations.DeleteModel(
+ name='Entry',
+ ),
+ ]
diff --git a/app/links/migrations/__init__.py b/app/links/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/app/links/migrations/__init__.py
diff --git a/app/links/models.py b/app/links/models.py
new file mode 100644
index 0000000..518ba33
--- /dev/null
+++ b/app/links/models.py
@@ -0,0 +1,46 @@
+from django.db import models
+from django.urls import reverse
+from django.contrib.sitemaps import Sitemap
+
+from taggit.managers import TaggableManager
+
+from taxonomy.models import TaggedItems
+from utils.util import render_images, markdown_to_html
+
+
+class Link(models.Model):
+ title = models.CharField(max_length=200)
+ link_url = models.URLField(max_length=400)
+ pub_date = models.DateTimeField('Date published')
+ slug = models.SlugField(unique_for_date='pub_date')
+ tags = TaggableManager(through=TaggedItems, blank=True, help_text='Topics Covered')
+ body_html = models.TextField(blank=True)
+ body_markdown = models.TextField()
+ PUB_STATUS = (
+ (0, 'Draft'),
+ (1, 'Published'),
+ )
+ status = models.IntegerField(choices=PUB_STATUS, default=0)
+
+ def __str__(self):
+ return self.title
+
+ def get_absolute_url(self):
+ return reverse("links:detail", kwargs={"year": self.pub_date.year, "month": self.pub_date.strftime("%m"), "slug": self.slug})
+
+ def save(self):
+ md = render_images(self.body_markdown)
+ self.body_html = markdown_to_html(md)
+ super(Link, self).save()
+
+
+class LinkedSitemap(Sitemap):
+ changefreq = "weekly"
+ priority = 0.8
+ protocol = "https"
+
+ def items(self):
+ return Link.objects.filter(status=1)
+
+ def lastmod(self, obj):
+ return obj.pub_date
diff --git a/app/links/urls.py b/app/links/urls.py
new file mode 100644
index 0000000..fb18532
--- /dev/null
+++ b/app/links/urls.py
@@ -0,0 +1,39 @@
+from django.urls import path, re_path
+
+from . import views
+
+app_name = "links"
+
+urlpatterns = [
+ re_path(
+ r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+).txt$',
+ views.EntryDetailViewTXT.as_view(),
+ name="detail-txt"
+ ),
+ re_path(
+ r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<slug>[-\w]+)$',
+ views.EntryDetailView.as_view(),
+ name="detail"
+ ),
+ re_path(
+ r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/$',
+ views.EntryMonthArchiveView.as_view(month_format='%m'),
+ name="list_month"
+ ),
+ re_path(
+ r'(?P<year>\d{4})/$',
+ views.EntryYearArchiveView.as_view(),
+ name="list_year"
+ ),
+ re_path(
+ r'^(?P<page>\d+)/$',
+ views.EntryListView.as_view(),
+ name="list"
+ ),
+ re_path(
+ r'',
+ views.EntryListView.as_view(),
+ {'page': 1},
+ name="list"
+ ),
+]
diff --git a/app/links/views.py b/app/links/views.py
new file mode 100644
index 0000000..64cc5f7
--- /dev/null
+++ b/app/links/views.py
@@ -0,0 +1,65 @@
+from django.views.generic import ListView
+from django.views.generic.detail import DetailView
+from django.views.generic.dates import YearArchiveView, MonthArchiveView
+from django.contrib.syndication.views import Feed
+
+
+from .models import Link
+
+
+class EntryListView(ListView):
+ model = Link
+
+ def get_queryset(self, **kwargs):
+ qs = Link.objects.filter(status=1)
+ return qs
+
+
+class EntryDetailView(DetailView):
+ model = Link
+
+
+class EntryDetailViewTXT(EntryDetailView):
+ template_name = "entry_detail.txt"
+
+
+
+class EntryYearArchiveView(YearArchiveView):
+ queryset = Link.objects.filter(status__exact=1).select_related()
+ date_field = "pub_date"
+ make_object_list = True
+ allow_future = True
+
+
+class EntryMonthArchiveView(MonthArchiveView):
+ queryset = Link.objects.filter(status__exact=1).select_related()
+ date_field = "pub_date"
+ allow_future = True
+
+
+
+
+
+'''
+class TopicListView(ListView):
+ template_name = 'archives/src_home.html'
+
+ def queryset(self):
+ return Post.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 Post.objects.filter(status__exact=1).order_by('-pub_date')[:10]
+'''