summaryrefslogtreecommitdiff
path: root/app/figments
diff options
context:
space:
mode:
authorlxf <sng@luxagraf.net>2019-05-25 15:10:38 +0000
committerlxf <sng@luxagraf.net>2019-05-25 15:10:38 +0000
commitdd09ca3810ea0798899870930c3efb388b776a7c (patch)
tree0cf0f8ba6c44b774a0867f48fce9cafb96620974 /app/figments
parentfc037fa9bf0eee9920ae1da14ce80d594f39cba4 (diff)
made some changes to use new checkin model
Diffstat (limited to 'app/figments')
-rw-r--r--app/figments/admin.py46
-rw-r--r--app/figments/build.py17
-rw-r--r--app/figments/ebook.py79
-rw-r--r--app/figments/models.py97
-rw-r--r--app/figments/urls.py38
-rw-r--r--app/figments/views.py42
6 files changed, 0 insertions, 319 deletions
diff --git a/app/figments/admin.py b/app/figments/admin.py
deleted file mode 100644
index 34452bd..0000000
--- a/app/figments/admin.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from django.contrib import admin
-from .models import Figment, Series
-from utils.widgets import LGEntryForm
-
-
-class FigmentAdmin(admin.ModelAdmin):
- form = LGEntryForm
- list_display = ('title', 'pub_date', 'get_series')
- prepopulated_fields = {"slug": ('title',)}
- fieldsets = (
- ('Figment', {
- 'fields': (
- 'title',
- 'body_markdown',
- ('slug', 'status'),
- 'pub_date',
- ),
- 'classes': (
- 'show',
- 'extrapretty',
- 'wide'
- )
- }
- ),
- ('Extra', {
- 'fields': (
- 'dek',
- 'prologue',
- 'series',
- 'published_link',
- ),
- 'classes': (
- 'collapse',
- 'extrapretty',
- 'wide'
- )
- }
- ),
- )
-
-
-class SeriesAdmin(admin.ModelAdmin):
- pass
-
-admin.site.register(Figment, FigmentAdmin)
-admin.site.register(Series, SeriesAdmin)
diff --git a/app/figments/build.py b/app/figments/build.py
deleted file mode 100644
index b656ab0..0000000
--- a/app/figments/build.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from django.urls import reverse
-from builder.base import BuildNew
-
-
-class BuildFigments(BuildNew):
- def build(self):
- self.build_list_view(
- base_path=reverse('figments:list'),
- paginate_by=99999
- )
- self.build_detail_view()
- self.build_feed('figments:feed')
-
-
-def builder():
- j = BuildFigments("figments", "figment")
- j.build()
diff --git a/app/figments/ebook.py b/app/figments/ebook.py
deleted file mode 100644
index 81210a4..0000000
--- a/app/figments/ebook.py
+++ /dev/null
@@ -1,79 +0,0 @@
-import os
-from ebooklib import epub
-
-from django.conf import settings
-from typogrify.filters import typogrify
-
-
-def generate_epub_file(f):
- book = epub.EpubBook()
-
- # add metadata
- book.set_identifier('lux23')
- book.set_title(f.title)
- book.set_language('en')
-
- book.add_author('Scott Gilbertson')
-
- # intro chapter
- c1 = epub.EpubHtml(title='Introduction', file_name='intro.xhtml', lang='en')
- c1.content = u'<html><head></head><body><h1>Forward</h1><p>Thank you for downloading my story <em>%s</em>. I hope you enjoy it and please feel free to email me if you have any questions or comments.</p> <p>If you enjoy this story and would like to read more, head on over to <a href="https://luxagraf.net/figments/">luxagraf.net</a>.</p><p>&ndash; Scott Gilbertson <br/> &nbsp;&nbsp;sng@luxagraf.net</p></body></html>' % f.title
-
- # chapter
- c2 = epub.EpubHtml(title=f.title, file_name='story.xhtml')
- c2.content = '<h1>%s</h1>' % f.title
- c2.content += typogrify(f.body_html)
-
- # add chapters to the book
- book.add_item(c1)
- book.add_item(c2)
- # create table of contents
- # - add section
- # - add auto created links to chapters
-
- book.toc = (epub.Link('intro.xhtml', 'Introduction', 'intro'),
- epub.Link('story.xhtml', f.title, 'story'),
- )
-
- # add navigation files
- book.add_item(epub.EpubNcx())
- book.add_item(epub.EpubNav())
-
- # define css style
- style = '''
-@namespace epub "http://www.idpf.org/2007/ops";
-body {
- font-family: Georgia, Times, Times New Roman, serif;
-}
-h2 {
- text-align: left;
- text-transform: uppercase;
- font-weight: 200;
-}
-ol {
- list-style-type: none;
-}
-ol > li:first-child {
- margin-top: 0.3em;
-}
-nav[epub|type~='toc'] > ol > li > ol {
- list-style-type:square;
-}
-nav[epub|type~='toc'] > ol > li > ol > li {
- margin-top: 0.3em;
-}
-'''
-
- # add css file
- nav_css = epub.EpubItem(uid="style_nav", file_name="style/nav.css", media_type="text/css", content=style)
- book.add_item(nav_css)
-
- # create spine
- book.spine = ['nav', c1, c2]
- path, filename = os.path.split(f.get_absolute_url())
- fpath = '%s%s/' % (settings.FLATFILES_ROOT, path)
- if not os.path.isdir(fpath):
- os.makedirs(fpath)
- bk = '%s%s.epub' % (fpath, f.slug)
- # create epub file
- epub.write_epub(bk, book, {})
diff --git a/app/figments/models.py b/app/figments/models.py
deleted file mode 100644
index 8b22049..0000000
--- a/app/figments/models.py
+++ /dev/null
@@ -1,97 +0,0 @@
-import datetime
-from itertools import chain
-from django.db import models
-from django.urls import reverse
-from django.contrib.sitemaps import Sitemap
-from django.contrib.syndication.views import Feed
-from django.db.models.signals import post_save
-from django.dispatch import receiver
-
-from utils.util import markdown_to_html
-
-from .ebook import generate_epub_file
-
-
-class Series(models.Model):
- title = models.CharField(max_length=200)
- slug = models.CharField(max_length=50)
- is_book = models.BooleanField(default=False)
- body_markdown = models.TextField(null=True, blank=True)
- body_html = models.TextField(null=True, blank=True)
- pub_date = models.DateTimeField(auto_now_add=True)
-
- class Meta:
- verbose_name_plural = 'Series'
-
- def __str__(self):
- return self.title
-
-
-class Figment(models.Model):
- title = models.CharField(max_length=200)
- slug = models.CharField(max_length=50)
- pub_date = models.DateTimeField(blank=True)
- body_markdown = models.TextField(null=True, blank=True)
- prologue = models.TextField(null=True, blank=True)
- dek = models.TextField(null=True, blank=True)
- body_html = models.TextField(null=True, blank=True)
- PUB_STATUS = (
- (0, 'Draft'),
- (1, 'Published'),
- )
- status = models.IntegerField(choices=PUB_STATUS, default=0)
- series = models.ManyToManyField(Series, related_name="series", blank=True)
- TEMPLATES = (
- (0, 'default'),
- )
- template_name = models.IntegerField(choices=TEMPLATES, default=0)
- published_link = models.CharField(max_length=300, help_text="link to online pub", blank=True, null=True)
-
- class Meta:
- ordering = ('-pub_date',)
-
- def __str__(self):
- return self.title
-
- def get_absolute_url(self):
- return reverse("figments:detail", kwargs={"slug": self.slug})
-
- def get_series(self):
- return "\n".join([s.title for s in self.series.all()])
-
- def save(self, *args, **kwargs):
- if not self.id and not self.pub_date:
- self.pub_date = datetime.datetime.now()
- self.body_html = markdown_to_html(self.body_markdown)
- super(Figment, self).save()
-
-
-@receiver(post_save, sender=Figment)
-def post_save_events(sender, instance, **kwargs):
- if instance.body_markdown != instance._loaded_values['body_markdown']:
- print("you updated")
- generate_epub_file(instance)
- else:
- print("no update found, not buidling")
-
-
-class LatestFull(Feed):
- title = "luxagraf figments: stories less literally true."
- link = "/figments/"
- description = "Latest postings to luxagraf.net/figments"
- description_template = 'feeds/blog_description.html'
-
- def items(self):
- return Figment.objects.filter(status__exact=1).order_by('-pub_date')[:10]
-
-
-class FigmentSitemap(Sitemap):
- changefreq = "never"
- priority = 0.7
- protocol = "https"
-
- def items(self):
- return list(chain(Figment.objects.filter(status__exact=1), Series.objects.all()))
-
- def lastmod(self, obj):
- return obj.pub_date
diff --git a/app/figments/urls.py b/app/figments/urls.py
deleted file mode 100644
index 4a37cf5..0000000
--- a/app/figments/urls.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from django.conf.urls import url
-
-from . import views
-
-app_name = "figments"
-
-urlpatterns = [
- url(
- r'^feed.xml',
- views.FigRSSFeedView(),
- name="feed"
- ),
- url(
- r'series/$',
- views.SeriesListView.as_view(),
- name='list_series'
- ),
- url(
- r'(?P<slug>[-\w]+).txt$',
- views.FigmentDetailViewTXT.as_view(),
- name="detail-txt"
- ),
- url(
- r'(?P<slug>[-\w]+).amp$',
- views.FigmentDetailViewAMP.as_view(),
- name="detail-amp"
- ),
- url(
- r'(?P<slug>[-\w]+)$',
- views.FigmentDetailView.as_view(),
- name='detail'
- ),
- url(
- r'^$',
- views.FigmentListView.as_view(),
- name='list'
- ),
-]
diff --git a/app/figments/views.py b/app/figments/views.py
deleted file mode 100644
index 6521c29..0000000
--- a/app/figments/views.py
+++ /dev/null
@@ -1,42 +0,0 @@
-from django.views.generic import ListView, DetailView
-from django.contrib.syndication.views import Feed
-
-from .models import Figment, Series
-
-
-class FigmentListView(ListView):
- model = Figment
- template_name = "archives/figments.html"
- context_object_name = 'object_list'
-
- def get_queryset(self):
- return Figment.objects.filter(status__exact=1).order_by('-pub_date')
-
-
-class SeriesListView(ListView):
- model = Series
- template_name = "archives/figments_series.html"
- context_object_name = 'object_list'
-
-
-class FigmentDetailView(DetailView):
- model = Figment
- template_name = "details/figments.html"
-
-
-class FigmentDetailViewTXT(FigmentDetailView):
- template_name = "details/entry.txt"
-
-
-class FigmentDetailViewAMP(FigmentDetailView):
- template_name = "details/entry.amp"
-
-
-class FigRSSFeedView(Feed):
- title = "luxagraf figments: stories less literally true."
- link = "/figments/"
- description = "Latest postings to luxagraf.net/figments"
- description_template = 'feeds/blog_description.html'
-
- def items(self):
- return Figment.objects.filter(status__exact=1).order_by('-pub_date')[:10]