Skip to content

Commit

Permalink
Merge pull request #33 from apiad/develop
Browse files Browse the repository at this point in the history
v0.6.3
  • Loading branch information
apiad authored Dec 19, 2019
2 parents 4d1adcc + 6d7f52a commit 2eb34ec
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 13 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ Staying away from `eval` and `exec` should keep you safe in most scenarios, but

## History

### v0.6.3

* Add `Show.append` to append existing `show` instances or direct paths.
* Fix error with absolute path for the Markdown demo.
* Append Markdown demo to the Python demo.

### v0.6.2

* Added `mypy` for some static type checking. Will slowly add as many type hints as possible.
Expand Down
42 changes: 41 additions & 1 deletion auditorium/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,44 @@ def themes(ctx):
ctx.anchor("/?theme=black#/themes")


show.append("auditorium/static/md/demo.md")
@show.slide
def markdown_first(ctx):
"""
## Markdown First
If your Python code is short and you prefer to author directly
in Markdown, you can do **almost everything** in a Markdown file
and insert Python here and there.
Run your slideshow with:
"""

ctx.code("auditorium run [file.md]")


@show.slide
def append(ctx):
"""
## Appendix
You can append one `show` instance right after another, _ad-infinitum_,
to compose larger slideshows from shorter ones.
"""

ctx.code(
"""
show_1 = Show("...")
# content
show_2 = Show("...")
# content
show_1.append(show_2)
"""
)

ctx.markdown("It also works directly with file paths, both Python and Markdown.")
ctx.code("show.append('auditorium/static/md/demo.md')")


from .utils import path

show.append(path("./static/md/demo.md"))
26 changes: 22 additions & 4 deletions auditorium/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,31 @@ def load(path, instance_name="show"):

return show

def get_slide(self, slide_id):
if slide_id in self._slides:
return self._slides[slide_id]

for show in self._tail:
try:
return show.get_slide(slide_id)
except:
pass

raise ValueError(f"Invalid slide id: {slide_id}")

@property
def slides(self):
return self._slides
yield from self._slides

for show in self._tail:
yield from show.slides

@property
def sections(self):
return self._sections
yield from self._sections

for show in self._tail:
yield from show.sections

## @slide decorator

Expand Down Expand Up @@ -142,12 +160,12 @@ def _wrap(self, func, id):
## Internal API

def do_markup(self, slide):
slide = self._slides[slide]
slide = self.get_slide(slide)
ctx = slide.run(ShowMode.Markup)
return "\n\n".join(ctx.content)

def do_code(self, slide, values):
slide = self._slides[slide]
slide = self.get_slide(slide)
ctx = slide.run(ShowMode.Code, values)
return ctx.update

Expand Down
8 changes: 7 additions & 1 deletion auditorium/static/css/auditorium.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

.reveal section div.block {
width: 90%;
width: 95%;
margin: auto;
box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.15);
margin-bottom: 20px;
Expand Down Expand Up @@ -88,3 +88,9 @@
.reveal section div.block-error .block-content {
color: darkred;
}

.reveal section div.highlight {
box-shadow: 0px 5px 15px rgba(0, 0, 0, 0.15);
width: 95%;
margin: auto;
}
7 changes: 4 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:
image: docker.pkg.github.com/apiad/auditorium/auditorium:latest
build: "."
volumes:
- "./:/root/auditorium"
ports:
- "6789:6789"
- "./:/code"
network_mode: host
command: auditorium demo
working_dir: "/"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "auditorium"
version = "0.6.2"
version = "0.6.3"
description = "A Python-powered slideshow maker with steroids."
authors = ["Alejandro Piad <alepiad@gmail.com>"]
license = "MIT"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def slide_one(ctx):
"## Title"

assert "slide_one" in show.slides
assert len(show.sections) == 1
assert len(list(show.sections)) == 1


def test_vertical_slide():
Expand All @@ -25,8 +25,8 @@ def second(ctx):

show.render()

assert len(show.slides) == 2
assert len(show.sections) == 1
assert len(list(show.slides)) == 2
assert len(list(show.sections)) == 1


def test_demo():
Expand Down

0 comments on commit 2eb34ec

Please sign in to comment.