Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/offline master #104

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#I @"packages/FsReveal/fsreveal/"
#I @"packages/FsReveal/tools/"
#I @"packages/FAKE/tools/"
#I @"packages/Suave/lib/net40"

Expand Down Expand Up @@ -39,11 +39,11 @@ Target "Clean" (fun _ ->
CleanDirs [outDir]
)

let fsiEvaluator =
let fsiEvaluator =
let evaluator = FSharp.Literate.FsiEvaluator()
evaluator.EvaluationFailed.Add(fun err ->
evaluator.EvaluationFailed.Add(fun err ->
traceImportant <| sprintf "Evaluating F# snippet failed:\n%s\nThe snippet evaluated:\n%s" err.StdErr err.Text )
evaluator
evaluator

let copyStylesheet() =
try
Expand All @@ -57,15 +57,15 @@ let copyPics() =
with
| exn -> traceImportant <| sprintf "Could not copy picture: %s" exn.Message

let generateFor (file:FileInfo) =
let generateFor (file:FileInfo) =
try
copyPics()
let rec tryGenerate trials =
try
FsReveal.GenerateFromFile(file.FullName, outDir, fsiEvaluator = fsiEvaluator)
with
with
| exn when trials > 0 -> tryGenerate (trials - 1)
| exn ->
| exn ->
traceImportant <| sprintf "Could not generate slides for: %s" file.FullName
traceImportant exn.Message

Expand All @@ -92,8 +92,11 @@ let socketHandler (webSocket : WebSocket) =
while true do
let! refreshed =
Control.Async.AwaitEvent(refreshEvent.Publish)
|> Suave.Sockets.SocketOp.ofAsync
do! webSocket.send Text (ASCII.bytes "refreshed") true
|> Suave.Sockets.SocketOp.ofAsync
let seg =
let bs = ASCII.bytes "refreshed"
ByteSegment bs
do! webSocket.send Text seg true
}

let startWebServer () =
Expand All @@ -107,10 +110,10 @@ let startWebServer () =

let port = findPort 8083

let serverConfig =
let serverConfig =
{ defaultConfig with
homeFolder = Some (FullName outDir)
bindings = [ HttpBinding.mkSimple HTTP "127.0.0.1" port ]
bindings = [ HttpBinding.createSimple HTTP "127.0.0.1" port ]
}
let app =
choose [
Expand All @@ -131,7 +134,7 @@ Target "GenerateSlides" (fun _ ->

Target "KeepRunning" (fun _ ->
use watcher = !! (slidesDir + "/**/*.*") |> WatchChanges handleWatcherEvents

startWebServer ()

traceImportant "Waiting for slide edits. Press any key to stop."
Expand Down Expand Up @@ -162,5 +165,5 @@ Target "ReleaseSlides" (fun _ ->

"GenerateSlides"
==> "ReleaseSlides"

RunTargetOrDefault "KeepRunning"
8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ then
.paket/paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi

.paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi

packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
Expand All @@ -21,13 +21,13 @@ else
mono .paket/paket.bootstrapper.exe
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi

mono .paket/paket.exe restore
exit_code=$?
if [ $exit_code -ne 0 ]; then
exit $exit_code
exit $exit_code
fi
mono packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx
fi
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ source https://nuget.org/api/v2

nuget FsReveal
nuget FAKE
nuget Suave
nuget Suave prerelease
Loading