Commit 25064c560e948fb7c6439fb6cedb76e5f5a0cd4b

  • avatar
  • Ville Tirronen <ville.tirronen @j…u.fi> (Committer)
  • Thu Mar 15 22:53:37 EET 2018
  • avatar
  • Ville Tirronen <ville.tirronen @j…u.fi> (Author)
  • Thu Mar 15 22:53:37 EET 2018
More tjtsm5 details
Build_Service.hs
(19 / 66)
  
1515
1616import qualified ExerciseReturns.Build as EX
1717import qualified LoginManager.Build as LM
18import qualified ElmLogin.Build as EL
1819
1920-- import qualified Utils.Metadata as Meta
2021
8585 shakeOptions { shakeFiles = "_metadata" } [] $ \flags (configDir:xs) -> return $ Just $ do
8686 let cards = ("CardViewer/"</>)
8787 let deploy x = configDir<.>"deploy"</>x
88 let bin = deploy . ("bin"</>) --((configDir<.>"deploy")</>"bin/"</> x)
89 let deployConfigs = deploy . ("config"</>)
88 let bin = deploy . ("bin"</>)
89 let deployConfigs = deploy . ("config/"</>)
9090 let resources x = ((configDir <.> "deploy") </> "resources/"</>x)
9191 {-
9292 want $ [ resources "CardViewer/App.html"
9393 , resources "CardViewer/resources/cards.js"
94 , "ElmLogin/build/Login.js"
95 , "ElmLogin/build/register.js"
96 , "ElmLogin/build/register.js"
9794 , "resources/Login.js"
98 , "resources/fira_code.css"
99 , bin "LoginManager-mkpass"
10095 , bin "PollServant-server"
10196 , bin "MarkPolls"
10297 , bin "ExerciseTool"
115115 servicePrograms <- serviceInfo "services" -- liftIO $ Dhall.input Dhall.auto (LT.pack (("./"</>configDir</>"serviceInfo ")<.>"services"))
116116 need (map (LT.unpack) servicePrograms)
117117 action $ do
118 configs <- Development.Shake.getDirectoryContents configDir
118 configs <- Development.Shake.getDirectoryFiles configDir ["//*"]
119119 need (map deployConfigs configs)
120 deployConfigs "*" %> \out -> copyFile' (configDir</>takeFileName out) out
120 configDir<.>"deploy/config"<//>"*" %> \out -> do
121 let r = configDir</> (makeRelative (deployConfigs "") out)
122 liftIO $ print ("DDD",out,r)
123 copyFile' r out
121124
122125 phony "ExerciseReturns-webClients" $ need (EX.webClients ("ExerciseReturns"</>) bin resources)
123126 phony "ExerciseReturns-service" $ need (EX.binaryAndConf ("ExerciseReturns"</>) bin resources)
128128 phony "LoginManager-webClients" $ need ( LM.webClients ("LoginManager"</>) bin resources deployConfigs)
129129 EX.buildRules ("ExerciseReturns"</>) bin resources (configDir</>"serviceLocations.conf")
130130 LM.buildRules ("LoginManager"</>) bin resources deployConfigs (configDir)
131 EL.buildRules ("ElmLogin"</>) bin resources
131132 --"bin/exercises/*" %> \out -> do
132133 -- putNormal "If this step fails, run 'stack build'"
133134 -- liftIO $ SysDir.createDirectoryIfMissing True "bin/exercises"
156156 () <- cmd "ssh" [hostName,"mkdir -p "++binPath]
157157 cmd "scp" (map (bin) bins ++ [hostName++":"++binPath])
158158 -- cmd "rsync" ["-avz","--no-g","--no-o","--no-t","--no-p", "bin", "fupu2.it.jyu.fi:/extra/"]
159 phony "distribute-configs" $
160 do putNormal "Distributing config files"
161 hostName <- LT.unpack <$> serviceInfo "hostName"
162 resPath <- LT.unpack <$> serviceInfo "configPath"
163 () <- cmd "ssh" [hostName,"mkdir -p "++resPath]
164 cmd [AutoDeps] "rsync" ["-avz","--no-g","--no-o","--no-t","--no-p", deployConfigs "", hostName++":"++resPath]
159165 phony "distribute-resources" $
160166 do putNormal "Distributing files in resources (build first)"
161 need [resources "manifest"
162 --,resources "CardViewer/App.html", resources "CardViewer/resources/cards.js"
163 ]
164167 resPath <- LT.unpack <$> serviceInfo "resourcePath"
165168 hostName <- LT.unpack <$> serviceInfo "hostName"
166169 () <- cmd "ssh" [hostName,"mkdir -p "++resPath]
167 liftIO $ print ("BBBB",resources "")
168 cmd "rsync" ["-avz","--no-g","--no-o","--no-t","--no-p", resources "", hostName++":"++resPath]
170 cmd [AutoDeps] "rsync" ["-avz","--no-g","--no-o","--no-t","--no-p", resources "", hostName++":"++resPath]
169171
170 bin "*" %> \out -> do
171 Stdout path <- cmd "stack" ["path","--local-install-root"]
172 liftIO $ print ("DBG:::",path,out,path</>takeFileName out)
173 copyFile' (filter (/='\n') path</>"bin"</>takeFileName out) out
174
175172 resources "CardViewer/App.html" %> \out -> do
176173 need [cards "app/AppPage.html"]
177174 copyWithDir (cards "app/AppPage.html") out
192192 need ["CardViewer/resources/fira_code.css"]
193193 copyFile' "CardViewer/resources/fira_code.css" out
194194
195 resources "ElmLogin/Login.js" %> \out -> do
196 need ["ElmLogin/build/Login.js"]
197 copyFile' "ElmLogin/build/Login.js" out
195 -- resources "ElmLogin/Login.js" %> \out -> do
196 -- need ["ElmLogin/build/Login.js"]
197 -- copyFile' "ElmLogin/build/Login.js" out
198198
199 resources "ElmLogin/register.js" %> \out -> do
200 need ["ElmLogin/build/register.js"]
201 copyFile' "ElmLogin/build/register.js" out
202
203 "ElmLogin/build/register.js" %>
204 \out -> do
205 need ["ElmLibs/HtmlUtils.elm"
206 ,"ElmLogin/Login.elm"
207 ,"ElmLogin/LoginManager/Generated/Login.elm"
208 ,"ElmLogin/elm-stuff/exact-dependencies.json"]
209 r <- cmd [Cwd "ElmLogin"] "elm make" ["RegisterPage.elm", "--output", "build/register.js"]
210 return r
211
212 "ElmLogin/LoginManager/Generated/Login.elm" %> \out -> do
213 need ["LoginManager/GenElmIFace.hs"]
214 cmd [Cwd "ElmLogin"] "../LoginManager/GenElmIFace.hs" ["LoginManager/Generated/Login.elm"]
215
216199 "LoginManager.tar.gz" %> \out -> do
217200 cmd [AutoDeps] "tar" ["-cjvf",out
218201 ,"bin/LoginManager-server"
216216 ,deployConfigs "defConfirmPage.html"
217217 ,deployConfigs "defConfirmErrorPage.html"]
218218
219 --"ExerciseReturns/elm-upload/*.html" %> \out -> do
220 -- applyDhallTemplate (replaceExtension out "dhall") (configDir</>se) out
221
222 --"ExerciseReturns/elm-review/page/*.html" %> \out -> do
223 -- applyDhallTemplate (replaceExtension out "dhall") configFile out
224
225219 phony "ipfs-ex" $
226220 putToIPFS (EX.everything ("ExerciseReturns"</>) bin resources)
227221
228222
229223
230 elmStuff
231224
232225
233226applyDhallTemplateDeps tmpl arg target = do
253253 liftIO $ putStrLn ("uploading to ipfs: "++intercalate ", " files)
254254 need files
255255 cmd "ipfs" (["add","-w"] ++ files)
256
257
258elmStuff = do
259--
260--
261--
262--
263--
264--
265--
266--
267 "ElmLogin/build/Login.js" %>
268 \out -> do
269 need ["ElmLibs/HtmlUtils.elm"
270 ,"ElmLogin/Login.elm"
271 ,"ElmLogin/Standalone.elm"
272 ,"ElmLogin/LoginManager/Generated/Login.elm"
273 ,"ElmLogin/elm-stuff/exact-dependencies.json"]
274 r <- cmd [Cwd "ElmLogin/"] "elm make" ["Standalone.elm", "--output", "build/Login.js"]
275 return r
ElmLogin/Build.hs
(37 / 0)
  
1module ElmLogin.Build where
2import Development.Shake
3import Development.Shake.Command
4import Development.Shake.FilePath
5import System.Directory
6import qualified System.FilePath as SysPath
7import Development.Shake.Util
8import qualified System.Directory as SysDir
9--import Data.Yaml
10import Control.Monad
11import Data.List (isPrefixOf,intercalate)
12import qualified Data.Text.Lazy as LT
13import Dhall
14
15webClient here bin resources = [resources "ElmLogin/Login.js",resources "ElmLogin/register.js"]
16
17buildRules here bin resources = do
18 resources "ElmLogin/Login.js" %> \out -> do
19 need ["ElmLogin/build/Login.js"]
20 copyFile' "ElmLogin/build/Login.js" out
21
22 resources "ElmLogin/register.js" %> \out -> do
23 need ["ElmLogin/build/register.js"]
24 copyFile' "ElmLogin/build/register.js" out
25
26 "ElmLogin/build/register.js" %>
27 \out -> do
28 need ["ElmLibs/HtmlUtils.elm"
29 ,"ElmLogin/Login.elm"
30 ,"ElmLogin/LoginManager/Generated/Login.elm"
31 ,"ElmLogin/elm-stuff/exact-dependencies.json"]
32 r <- cmd [Cwd "ElmLogin"] "elm make" ["RegisterPage.elm", "--output", "build/register.js"]
33 return r
34
35 "ElmLogin/LoginManager/Generated/Login.elm" %> \out -> do
36 need ["LoginManager/GenElmIFace.hs"]
37 cmd [Cwd "ElmLogin"] "../LoginManager/GenElmIFace.hs" ["LoginManager/Generated/Login.elm"]
ExerciseReturns/elm-review/page/ListReviewsPage.dhall
(4 / 2)
  
1λ(ps:{loginManager:Text, exerciseStore:Text}) -> ''
1let depends = ["custom.css","../../ElmLogin/Login.js","listtasks.js","../../fira_code.css"]
2in let template = λ(ps:{loginManager:Text, exerciseStore:Text}) -> ''
23<!DOCTYPE html>
34<html>
45 <head>
1212 </head>
1313 <style>https://functional-programming.it.jyu.fi/new-resources/fire_code.css </style>
1414 <body>
15 <script type="text/javascript" src="https://functional-programming.it.jyu.fi/new-resources/Login.js"></script>
15 <script type="text/javascript" src="../../ElmLogin/Login.js"></script>
1616 <script type="text/javascript" src="listtasks.js"></script>
1717
1818 <nav class="navbar is-info" role="navigation" aria-label="main navigation">
4444 </body>
4545</html>
4646''
47in {depends=depends, template=template}
ExerciseReturns/elm-review/page/TestPeerPage.dhall
(4 / 3)
  
1λ(ps:{loginManager:Text, exerciseStore:Text}) -> ''
1let depends = ["custom.css","../../ElmLogin/Login.js","embed_peertask.js","../../fira_code.css"]
2in let template = λ(ps:{loginManager:Text, exerciseStore:Text}) -> ''
23<html>
34
45 <head>
1111
1212 <body>
1313
14 <!-- Put the name of your app here (my sources place in `src` forder) -->
1514 <div id="LoginComponent"></div>
16 <script type="text/javascript" src="https://functional-programming.it.jyu.fi/new-resources/Login.js"></script>
15 <script type="text/javascript" src="../ElmLogin/Login.js"></script>
1716 <script type="text/javascript">
1817 var node = document.getElementById('LoginComponent');
1918 var app = Elm.StandaloneLogin.embed(node,{loginManager:"${ps.loginManager}"});
3434
3535</html>
3636''
37in {depends = depends, template = template}
ExerciseReturns/elm-upload/TestPage.dhall
(4 / 4)
  
1λ(ps:{loginManager:Text, exerciseStore:Text}) -> ''
1let depends = ["../ElmLogin/Login.js","embed_gui.js"]
2in let template = λ(ps:{loginManager:Text, exerciseStore:Text}) -> ''
23<html>
34
45 <head>
56 <meta charset="UTF-8">
67 <title>Title</title>
7 <!-- <link rel="stylesheet" href="style.css"> -->
88 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css">
99 </head>
1010
1111 <body>
1212
13 <!-- Put the name of your app here (my sources place in `src` forder) -->
1413 <div id="LoginComponent"></div>
15 <script type="text/javascript" src="https://functional-programming.it.jyu.fi/new-resources/Login.js"></script>
14 <script type="text/javascript" src="../ElmLogin/Login.js"></script>
1615 <script type="text/javascript">
1716 var node = document.getElementById('LoginComponent');
1817 var app = Elm.StandaloneLogin.embed(node,{loginManager:"${ps.loginManager}"});
3333
3434</html>
3535''
36in {depends = depends, template=template}
stack.yaml
(1 / 1)
  
6868 # extra-dep: True
6969
7070extra-deps:
71 - "dhall-1.9.1"
71 - "dhall-1.11.1"
7272 - "ReadArgs-1.2.3"
7373 - "flock-0.3.1.8"
7474 - "Interpolation-0.3.0"
tjtms52.it.jyu.fi/.serviceInfo.swo
(1 / 0)
Binary files differ
tjtms52.it.jyu.fi/ExerciseStore.conf
(2 / 2)
  
66 }
77 , port = 28979
88 , externalUrl = "localhost:28979"
9 , exercisesAt = "./Exercises"
10 , rubricsAt = "./Rubrics"
9 , exercisesAt = "${./serviceInfo .configPath}/Exercises"
10 , rubricsAt = "${./serviceInfo .configPath}/Rubrics"
1111 , loginManager = "http://localhost:8383"
1212 , resources = { generalResourcePath = "resources/" }
1313 , reviewers = { experts = ["VT","Mervi","Pasi"]
tjtms52.it.jyu.fi/Exercises/CheckType
(1 / 0)
  
1./ShellCheck
tjtms52.it.jyu.fi/Exercises/LectureDiary
(17 / 0)
  
1{
2 synopsis = "Submit your lecture diary"
3,requisites = [] : List {txt:Text,link:Text}
4,learning_goals = [] : List Text
5,text = ''
6## Individual learning diary
7
8An individual learning diary considers theoretical perspectives provided in the
9pre-class materials and reflects content of the visitor lecturers. Optimal
10length of the learning diary is 2000-4000 words.
11''
12
13,checks = [ ] : List ./CheckType
14
15,upload_prompt = "Submit your lecture diary here"
16,deadline = {day=+1,month=+9,year=+2018}
17} : ./TaskType
tjtms52.it.jyu.fi/Exercises/Review1
(8 / 0)
  
1{
2 reviewTaskID = { getTaskID = "LectureDiary" }
3,prompt = "Please review a random lecture diary"
4,reviewCount = +3
5,open = {day=+1,month=+1,year=+2018}
6,close = {day=+1,month=+9,year=+2018}
7,dependentOn = [] : Optional {getTaskID : Text}
8}
tjtms52.it.jyu.fi/Exercises/Review2
(8 / 0)
  
1{
2 reviewTaskID = { getTaskID = "LectureDiary" }
3,prompt = "Please review a second random lecture diary"
4,reviewCount = +3
5,open = {day=+1,month=+1,year=+2018}
6,close = {day=+1,month=+9,year=+2018}
7,dependentOn = [{getTaskID = "Review1"}] : Optional {getTaskID : Text}
8}
tjtms52.it.jyu.fi/Exercises/Review3
(8 / 0)
  
1{
2 reviewTaskID = { getTaskID = "LectureDiary" }
3,prompt = "Please review the third and final randomly assigned lecture diary"
4,reviewCount = +3
5,open = {day=+1,month=+1,year=+2018}
6,close = {day=+1,month=+9,year=+2018}
7,dependentOn = [{getTaskID = "Review3"}] : Optional {getTaskID : Text}
8}
tjtms52.it.jyu.fi/Exercises/ShellCheck
(7 / 0)
  
1{ action : Text
2, deps : List (List ./dependency)
3, execute : Text → Text
4, onFailure : Text → { message : Text, severity : Text }
5, onSuccess : Text → { message : Text, action : Text }
6, tag : Text
7}
tjtms52.it.jyu.fi/Exercises/TaskType
(8 / 0)
  
1{ checks : List ./CheckType
2, deadline : { day : Natural, month : Natural, year : Natural }
3, learning_goals : List Text
4, requisites : List {txt:Text, link:Text}
5, synopsis : Text
6, text : Text
7, upload_prompt : Text
8}
tjtms52.it.jyu.fi/Exercises/dependency
(1 / 0)
  
1{ pass : Bool, tag : Text }
tjtms52.it.jyu.fi/Rubrics/LectureDiary
(8 / 0)
  
1[
2 {rev_question = "Business model"
3 ,rev_choices = [] : List Text}
4
5,{rev_question = "Technology acceptance (innovation diffusion)"
6 ,rev_choices = [] : List Text}
7
8]
tjtms52.it.jyu.fi/nginx.lm.dhall
(5 / 0)
  
3333 client_max_body_size 2M;
3434 proxy_set_header Host $host;
3535 }
36 location /resources/ {
37 alias ${./serviceInfo resourcePath};
38 autoindex on;
39 }
40
3641}
3742''
tjtms52.it.jyu.fi/serviceInfo
(1 / 0)
  
11{
22 hostName = "tjtsm52.it.jyu.fi"
33,binPath = "/home/tjtms52/bin"
4,configPath = "/home/tjtms52/config"
45,resourcePath = "/home/tjtms52/resources"
56,services =
67 [