Skip to content

Commit

Permalink
Merge pull request #32 from eed3si9n/topic/subs
Browse files Browse the repository at this point in the history
subtitles
  • Loading branch information
softprops committed Feb 22, 2013
2 parents de3abfc + 332c44c commit 7075a5c
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -119,6 +119,16 @@ In `sectiona.md`, you'll want to reference `foo.jpg` as

![foo](sectiona/foo.jpg)

### subtitles

Here's how you can add subtitles to a slide.

!SLIDE

ハロー!

#SUB Hello!

### assets

#### js and css
Expand Down
9 changes: 8 additions & 1 deletion core/src/main/resources/css/show.css
Expand Up @@ -15,7 +15,14 @@ body {
overflow: hidden;
}
#slides .content .container {
padding:.5em;
padding:.5em;
height:80%;
}
#slides .content .subtitle {
padding:.5em;
background:#000;
color:#fff;
width: 100%;
}
#reel {
width: 1000000px;
Expand Down
30 changes: 22 additions & 8 deletions core/src/main/scala/Markup.scala
Expand Up @@ -27,15 +27,29 @@ trait Markup { self: Resolver with Config =>
val slides = content.split("(?m)^!SLIDE")
if(slides.isEmpty) log("no slides within file %s at index %s" format(content, index))
((new xml.NodeBuffer, index) /: slides.drop(1))( (a, s) => {
(a._1 &+ (<div class="content" id={"slide-%s" format a._2}>
<div class="container">{
s.split("\n")(0).trim match {
case Meta(meta) => {
<div>{ xml.PCData( s.split("\n").toList.drop(1).mkString("") ) }</div>
}
case _ => parseMarkdown(s)
(a._1 &+ (<div class="content" id={"slide-%s" format a._2}>{
val lines = s.lines.toList
lines.head.trim match {
case Meta(meta) => {
<div class="container">
<div>{ xml.PCData( lines.drop(1).mkString("") ) }</div>
</div>
}
}</div>
case _ =>
lines.partition(_.startsWith("#SUB ")) match {
case (Nil, nonsubs) =>
<div class="container">
{parseMarkdown(nonsubs.mkString("\n"))}
</div>
case (subs, nonsubs) =>
<div class="container">
{parseMarkdown(nonsubs.mkString("\n"))}
</div>
<div class="subtitle">
{parseMarkdown(subs.map(_.drop(5)).mkString("\n"))}
</div>
}
}}
</div>), a._2 + 1)
})
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/Resolver.scala
Expand Up @@ -39,7 +39,7 @@ class FileSystemResolver(uri: URI) extends Resolver {
import java.util.regex.Pattern
private def file(p: String) = new File(uri.toURL.getFile, p)
private def url(p: String) = new URL(uri.toURL, p)
privte def lastSeg(p: String) = p.split(Pattern.quote(File.separator)).last
private def lastSeg(p: String) = p.split(Pattern.quote(File.separator)).last
def configuration = IO.slurp(url("conf.js")).get
def resolve(p: String) =
if(file(p) exists) IO.slurp(url(p))
Expand Down
8 changes: 4 additions & 4 deletions project/build.scala
Expand Up @@ -47,7 +47,7 @@ object Build extends sbt.Build {

/** core transformations from txt files to html slide formated html */
lazy val core = Project(
"PictureShow Core",
"PictureShow_Core",
file("core"),
settings = standardSettings ++ Seq(
libraryDependencies ++= Seq(codec, specs)
Expand All @@ -56,7 +56,7 @@ object Build extends sbt.Build {

/** serves generated html on a configurable port */
lazy val server = Project(
"PictureShow Server",
"PictureShow_Server",
file("server"),
settings = standardSettings ++ Seq(
libraryDependencies ++= Seq(uff, ufj)
Expand All @@ -66,15 +66,15 @@ object Build extends sbt.Build {

/** caches generated html to disk */
lazy val offln = Project(
"PictureShow Offline",
"PictureShow_Offline",
file("offline"),
settings = standardSettings,
dependencies = Seq(core)
)

/** command line client, pshow */
lazy val app = Project(
"PictureShow Conscript",
"PictureShow_Conscript",
file("conscript"),
settings = standardSettings ++ conscript.Harness.conscriptSettings,
dependencies = Seq(core, server, offln)
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
@@ -1,5 +1,5 @@
resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)

addSbtPlugin("net.databinder" % "conscript-plugin" % "0.3.3")
addSbtPlugin("net.databinder" % "conscript-plugin" % "0.3.5")

addSbtPlugin("com.jsuereth" % "xsbt-gpg-plugin" % "0.6")

0 comments on commit 7075a5c

Please sign in to comment.