-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrea Magnorsky
committed
Jul 28, 2016
1 parent
7d8064d
commit cbba578
Showing
12 changed files
with
209 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,4 @@ let main = | |
|> save | ||
0 | ||
|
||
main | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
@echo off | ||
cls | ||
|
||
.paket\paket.bootstrapper.exe | ||
if errorlevel 1 ( | ||
exit /b %errorlevel% | ||
) | ||
|
||
.paket\paket.exe restore -v | ||
if errorlevel 1 ( | ||
exit /b %errorlevel% | ||
) | ||
|
||
packages\FAKE\tools\FAKE.exe build.fsx %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
#I @"packages/FsReveal/fsreveal/" | ||
#I @"packages/FAKE/tools/" | ||
#I @"packages/Suave/lib/net40" | ||
|
||
#r "FakeLib.dll" | ||
#r "suave.dll" | ||
|
||
#load "fsreveal.fsx" | ||
|
||
// Git configuration (used for publishing documentation in gh-pages branch) | ||
// The profile where the project is posted | ||
let gitOwner = "myGitUser" | ||
let gitHome = "https://github.com/" + gitOwner | ||
// The name of the project on GitHub | ||
let gitProjectName = "MyProject" | ||
|
||
open FsReveal | ||
open Fake | ||
open Fake.Git | ||
open System.IO | ||
open System.Diagnostics | ||
open Suave | ||
open Suave.Web | ||
open Suave.Http | ||
open Suave.Http.Files | ||
|
||
let outDir = __SOURCE_DIRECTORY__ @@ "output" | ||
let slidesDir = __SOURCE_DIRECTORY__ @@ "slides" | ||
|
||
Target "Clean" (fun _ -> | ||
CleanDirs [outDir] | ||
) | ||
|
||
let fsiEvaluator = | ||
let evaluator = FSharp.Literate.FsiEvaluator() | ||
evaluator.EvaluationFailed.Add(fun err -> | ||
traceImportant <| sprintf "Evaluating F# snippet failed:\n%s\nThe snippet evaluated:\n%s" err.StdErr err.Text ) | ||
evaluator | ||
|
||
let copyStylesheet() = | ||
try | ||
CopyFile (outDir @@ "css" @@ "custom.css") (slidesDir @@ "custom.css") | ||
with | ||
| exn -> traceImportant <| sprintf "Could not copy stylesheet: %s" exn.Message | ||
|
||
let copyPics() = | ||
try | ||
CopyDir (outDir @@ "images") (slidesDir @@ "images") (fun f -> true) | ||
with | ||
| exn -> traceImportant <| sprintf "Could not copy picture: %s" exn.Message | ||
|
||
let generateFor (file:FileInfo) = | ||
try | ||
copyPics() | ||
let rec tryGenerate trials = | ||
try | ||
FsReveal.GenerateFromFile(file.FullName, outDir, fsiEvaluator = fsiEvaluator) | ||
with | ||
| exn when trials > 0 -> tryGenerate (trials - 1) | ||
| exn -> | ||
traceImportant <| sprintf "Could not generate slides for: %s" file.FullName | ||
traceImportant exn.Message | ||
|
||
tryGenerate 3 | ||
|
||
copyStylesheet() | ||
with | ||
| :? FileNotFoundException as exn -> | ||
traceImportant <| sprintf "Could not copy file: %s" exn.FileName | ||
|
||
let handleWatcherEvents (e:FileSystemEventArgs) = | ||
let fi = fileInfo e.FullPath | ||
traceImportant <| sprintf "%s was changed." fi.Name | ||
match fi.Attributes.HasFlag FileAttributes.Hidden || fi.Attributes.HasFlag FileAttributes.Directory with | ||
| true -> () | ||
| _ -> generateFor fi | ||
|
||
let startWebServer () = | ||
let serverConfig = | ||
{ defaultConfig with | ||
homeFolder = Some (FullName outDir) | ||
} | ||
let app = | ||
Writers.setHeader "Cache-Control" "no-cache, no-store, must-revalidate" | ||
>>= Writers.setHeader "Pragma" "no-cache" | ||
>>= Writers.setHeader "Expires" "0" | ||
>>= browseHome | ||
startWebServerAsync serverConfig app |> snd |> Async.Start | ||
Process.Start "http://localhost:8083/index.html" |> ignore | ||
|
||
Target "GenerateSlides" (fun _ -> | ||
!! (slidesDir @@ "*.md") | ||
++ (slidesDir @@ "*.fsx") | ||
|> Seq.map fileInfo | ||
|> Seq.iter generateFor | ||
) | ||
|
||
Target "KeepRunning" (fun _ -> | ||
use watcher = new FileSystemWatcher(FullName slidesDir,"*.*") | ||
watcher.EnableRaisingEvents <- true | ||
watcher.IncludeSubdirectories <- true | ||
watcher.Changed.Add(handleWatcherEvents) | ||
watcher.Created.Add(handleWatcherEvents) | ||
watcher.Renamed.Add(handleWatcherEvents) | ||
|
||
startWebServer () | ||
|
||
traceImportant "Waiting for slide edits. Press any key to stop." | ||
|
||
System.Console.ReadKey() |> ignore | ||
|
||
watcher.EnableRaisingEvents <- false | ||
watcher.Dispose() | ||
) | ||
|
||
Target "ReleaseSlides" (fun _ -> | ||
if gitOwner = "myGitUser" || gitProjectName = "MyProject" then | ||
failwith "You need to specify the gitOwner and gitProjectName in build.fsx" | ||
let tempDocsDir = __SOURCE_DIRECTORY__ @@ "temp/gh-pages" | ||
CleanDir tempDocsDir | ||
Repository.cloneSingleBranch "" (gitHome + "/" + gitProjectName + ".git") "gh-pages" tempDocsDir | ||
|
||
fullclean tempDocsDir | ||
CopyRecursive outDir tempDocsDir true |> tracefn "%A" | ||
StageAll tempDocsDir | ||
Git.Commit.Commit tempDocsDir "Update generated slides" | ||
Branches.push tempDocsDir | ||
) | ||
|
||
"Clean" | ||
==> "GenerateSlides" | ||
==> "KeepRunning" | ||
|
||
"GenerateSlides" | ||
==> "ReleaseSlides" | ||
|
||
RunTargetOrDefault "KeepRunning" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
if test "$OS" = "Windows_NT" | ||
then | ||
# use .Net | ||
|
||
.paket/paket.bootstrapper.exe | ||
exit_code=$? | ||
if [ $exit_code -ne 0 ]; then | ||
exit $exit_code | ||
fi | ||
|
||
.paket/paket.exe restore -v | ||
exit_code=$? | ||
if [ $exit_code -ne 0 ]; then | ||
exit $exit_code | ||
fi | ||
|
||
packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx | ||
else | ||
# use mono | ||
mono .paket/paket.bootstrapper.exe | ||
exit_code=$? | ||
if [ $exit_code -ne 0 ]; then | ||
exit $exit_code | ||
fi | ||
|
||
mono .paket/paket.exe restore -v | ||
exit_code=$? | ||
if [ $exit_code -ne 0 ]; then | ||
exit $exit_code | ||
fi | ||
mono packages/FAKE/tools/FAKE.exe $@ --fsiargs -d:MONO build.fsx | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
source https://nuget.org/api/v2 | ||
|
||
nuget FsReveal | ||
nuget FAKE | ||
nuget Suave |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
NUGET | ||
remote: https://nuget.org/api/v2 | ||
specs: | ||
FAKE (3.27.2) | ||
FSharp.Compiler.Service (0.0.87) | ||
FSharp.Core (3.1.2.1) | ||
FSharp.Formatting (2.8.0) | ||
FSharp.Compiler.Service (>= 0.0.86) | ||
FSharpVSPowerTools.Core (>= 1.7.0) | ||
FSharpVSPowerTools.Core (1.7.0) | ||
FSharp.Compiler.Service (>= 0.0.87) | ||
FsPickler (1.0.16) | ||
FsReveal (0.7.2) | ||
FSharp.Formatting (>= 2.7.5) | ||
Suave (0.26.1) | ||
FSharp.Core (>= 3.1.2.1) | ||
FsPickler (>= 1.0.7) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.