Skip to content

Commit

Permalink
Fix the FileNotFound issue with code includes on cactus reload
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswseitz committed Dec 17, 2013
1 parent 517b0b0 commit ed7f2d0
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
Expand Up @@ -3,4 +3,4 @@
- Command Pattern as defined in "Design Patterns"
- Name is imperative "do something!"

@(changeOwnerCommand)[code-samples/src/main/scala/event_sourcing/ChangeOwner.scala]
@(changeOwnerCommand)[../../../code-samples/src/main/scala/event_sourcing/ChangeOwner.scala]
@@ -0,0 +1,10 @@
## Command Sourcing

### Pro {.pros}

- A bit easier to implement
- Command log doubles as full audit log

### Contra {.cons}

-
34 changes: 21 additions & 13 deletions plugins/deckjs.py
@@ -1,23 +1,25 @@
import os
import datetime
import logging
from markdown import markdown
import re

SLIDES_PATH = 'slides' + os.sep
SLIDES = []

from markdown import markdown
from markdown.preprocessors import Preprocessor
from markdown.extensions import Extension
import re


# TODO: extract this into a module of its own
class CodeSnippets(Extension):
def extendMarkdown(self, md, md_globals):
md.preprocessors.add('code_snippets', CodeSnippetIncludingPreProcessor(), '_begin')
def __init__(self, seek_directory):
self.seek_directory = seek_directory

def extendMarkdown(self, md, md_globals):
preproc = CodeSnippetIncludingPreProcessor(self.seek_directory)
md.preprocessors.add('code_snippets', preproc, '_begin')

class CodeSnippetIncludingPreProcessor(Preprocessor):
def __init__(self):
self.satement_replacers = [CodeIncludeSatementReplacer()]
def __init__(self, seek_directory):
self.satement_replacers = [CodeIncludeSatementReplacer(seek_directory)]

def run(self, lines):
new_lines = []
Expand All @@ -32,16 +34,18 @@ def run(self, lines):


class CodeIncludeSatementReplacer(object):

def __init__(self):
def __init__(self, seek_directory):
self.include_statement = re.compile(r"@(\(([^\)]*)\))?\[([^\]]*)\]")
self.seek_directory = seek_directory

def replaces(self, line):
return self.include_statement.match(line) != None

def replacement_for(self, line):
parameters = self.include_statement.search(line)
include_file = parameters.group(3)
if not os.path.isabs(include_file):
include_file = os.path.join(self.seek_directory, include_file)
snippet_maker = parameters.group(2)
with open(include_file) as file_content:
if not snippet_maker:
Expand All @@ -64,6 +68,9 @@ def truncate_to_part_between_maker(self, marker, file_content):
return "\n".join(included)


SLIDES_PATH = 'slides' + os.sep
MARKDOWN_EXTRAS = ['extra', 'codehilite', CodeSnippets(os.getcwd())]
SLIDES = []

def preBuild(site):
global SLIDES
Expand All @@ -79,8 +86,9 @@ def preBuild(site):
slide_meta_data["title"] = "-".join(page.path.split("-")[1:])
slide_meta_data["path"] = page.path
page_content = open(page.paths['full']).read()
page_directory = os.path.dirname(page.paths['full'])
if page.path.endswith(".md"):
slide_meta_data["markdown_content"] = markdown(page_content, ['extra', 'codehilite', CodeSnippets()])
slide_meta_data["markdown_content"] = markdown(page_content, ['extra', 'codehilite', CodeSnippets(page_directory)])

SLIDES.append(slide_meta_data)

Expand Down
Empty file added static/themes/custom.css
Empty file.

0 comments on commit ed7f2d0

Please sign in to comment.