|
|
|
@ -9,6 +9,7 @@ class Index( object ):
|
|
|
|
|
self.path = path
|
|
|
|
|
self.fields = {}
|
|
|
|
|
self.doc = ""
|
|
|
|
|
self.updates = []
|
|
|
|
|
|
|
|
|
|
def path_short( self ):
|
|
|
|
|
# XXX needs tidy
|
|
|
|
@ -24,7 +25,7 @@ class Index( object ):
|
|
|
|
|
---
|
|
|
|
|
%(md)s
|
|
|
|
|
''' % { 'yaml': yaml.dump( self.fields, default_flow_style = False ),
|
|
|
|
|
'md': self.doc,
|
|
|
|
|
'md': "\n\n***\n\n".join( [ self.doc ] + self.updates ),
|
|
|
|
|
} )
|
|
|
|
|
outfile = open( self.path, 'w', encoding = "utf-8" )
|
|
|
|
|
outfile.write( outdata )
|
|
|
|
@ -34,8 +35,10 @@ class Index( object ):
|
|
|
|
|
indata = open( self.path, 'r', encoding = "utf-8" ).read()
|
|
|
|
|
( pre, yamldata, docdata ) = re.split( "^---$", indata, flags = re.MULTILINE )
|
|
|
|
|
self.fields = yaml.load( yamldata, Loader = yaml.SafeLoader )
|
|
|
|
|
self.doc = docdata.strip()
|
|
|
|
|
|
|
|
|
|
doc = docdata.strip()
|
|
|
|
|
bits = re.split( r"^\**$", doc, flags = re.MULTILINE )
|
|
|
|
|
self.doc = bits.pop( 0 )
|
|
|
|
|
self.updates = [ x.strip() for x in bits ]
|
|
|
|
|
|
|
|
|
|
def _toggle( self, fieldname ):
|
|
|
|
|
if self.fields.get( fieldname ):
|
|
|
|
@ -91,8 +94,8 @@ class Event( Index ):
|
|
|
|
|
self.fields[ '$slug' ] = slug
|
|
|
|
|
|
|
|
|
|
def set_year( self, year ):
|
|
|
|
|
if not self.fields.get( 'year' ):
|
|
|
|
|
self.fields[ 'year' ] = year
|
|
|
|
|
if isinstance( self.fields.get( 'year', None ), ( type( None ), str ) ):
|
|
|
|
|
self.fields[ 'year' ] = int( year )
|
|
|
|
|
|
|
|
|
|
def set_published( self, published ):
|
|
|
|
|
if not self.fields.get( '$date' ):
|
|
|
|
|