Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
openmole
openmole
Commits
2a779400
Commit
2a779400
authored
Jun 06, 2017
by
Mathieu Leclaire
Browse files
Generates all the market in one single page
parent
1f31e43c
Changes
9
Hide whitespace changes
Inline
Side-by-side
openmole/bin/org.openmole.site/js/src/main/scala/org/openmole/site/MarketTable.scala
0 → 100644
View file @
2a779400
package
org.openmole.site
/*
* Copyright (C) 02/06/17 // mathieu.leclaire@openmole.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
object
MarketTable
{
def
table
=
{
// for {
// entry ← Market.entries
// } yield {
// println("E " + entry)
// }
}
}
openmole/bin/org.openmole.site/js/src/main/scala/org/openmole/site/Menu.scala
View file @
2a779400
...
...
@@ -59,7 +59,6 @@ object Menu {
lazy
val
searchInput
=
bs
.
input
(
""
)(
placeholder
:=
"Search"
,
width
:=
150
).
render
val
result
:
Var
[
Seq
[
IIndexSearchResult
]]
=
Var
(
Seq
())
val
resultDiv
=
div
(
Rx
{
println
(
"RXX"
)
for
{
r
←
result
().
take
(
10
)
}
yield
{
...
...
openmole/bin/org.openmole.site/js/src/main/scala/org/openmole/site/SiteJS.scala
View file @
2a779400
...
...
@@ -36,6 +36,7 @@ object SiteJS extends JSApp {
@JSExport
()
def
main
()
:
Unit
=
{
MarketTable
.
table
val
menu
=
Menu
.
build
.
render
JSPages
.
toJSPage
(
org
.
scalajs
.
dom
.
window
.
location
.
pathname
.
split
(
'/'
).
last
)
foreach
{
page
⇒
...
...
openmole/bin/org.openmole.site/jvm/src/main/scala/org/openmole/site/MD.scala
0 → 100644
View file @
2a779400
/**
* Created by Romain Reuillon on 05/07/16.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package
org.openmole.site
import
java.lang.StringBuilder
import
java.util
import
com.github.rjeschke._
import
org.apache.commons.lang3.StringEscapeUtils
import
org.openmole.site.market.GeneratedMarketEntry
import
scala.collection.JavaConversions._
import
scalaz._
import
org.openmole.site.tools._
object
MD
{
val
emiter
=
new
txtmark
.
BlockEmitter
{
override
def
emitBlock
(
stringBuilder
:
StringBuilder
,
list
:
util.List
[
String
],
s
:
String
)
:
Unit
=
{
def
code
=
list
.
mkString
(
"\n"
)
val
html
=
if
(
s
==
"openmole"
)
hl
.
openmole
(
code
)
else
hl
.
highlight
(
code
,
s
)
stringBuilder
.
append
(
html
.
render
)
}
}
def
mdToHTML
(
md
:
String
)
=
{
val
configuration
=
txtmark
.
Configuration
.
builder
().
setCodeBlockEmitter
(
emiter
).
forceExtentedProfile
().
build
()
txtmark
.
Processor
.
process
(
md
,
configuration
)
}
def
prefixLink
(
prefix
:
String
)(
n
:
Seq
[
scala.xml.Node
])
=
{
//import scala.xml.transform._
val
HTMLTransformer
=
new
xml
.
transform
.
RuleTransformer
(
new
xml
.
transform
.
RewriteRule
{
override
def
transform
(
node
:
xml.Node
)
=
node
match
{
case
image
@
<
img
/>
⇒
val
newSrc
=
prefix
+
image
\
"@src"
val
alt
=
image
\
"@alt"
xml
.
XML
.
loadString
(
s
"""<img src="$newSrc" style="max-width:100%;" alt="$alt"/>"""
)
case
link
@
<
a
>{
stuff
}</
a
>
⇒
val
uri
=
new
java
.
net
.
URI
(
link
\
"@href"
text
)
if
(!
uri
.
isAbsolute
)
{
val
newTarget
=
prefix
+
link
\
"@href"
xml
.
XML
.
loadString
(
s
"""<a href="$newTarget">
|$stuff
|</a>"""
.
stripMargin
)
}
else
link
case
passthrough
⇒
passthrough
}
})
HTMLTransformer
.
transform
(
n
)
}
def
relativiseLinks
(
md
:
String
,
prefix
:
String
)
=
{
def
escaped
=
s
"<div>${StringEscapeUtils.unescapeHtml4(md)}</div>"
prefixLink
(
prefix
)(
xml
.
XML
.
loadString
(
escaped
)).
mkString
}
def
generatePage
(
entry
:
GeneratedMarketEntry
)(
implicit
parent
:
Parent
[
DocumentationPage
])
=
entry
.
readme
.
map
{
md
⇒
println
(
"md "
+
Seq
(
entry
.
entry
.
name
,
entry
.
entry
.
name
))
import
scalatags.Text.all._
def
frag
=
RawFrag
(
relativiseLinks
(
MD
.
mdToHTML
(
md
),
entry
.
entry
.
name
+
"/"
))
DocumentationPages
(
entry
.
entry
.
name
,
frag
,
location
=
Some
(
Seq
(
entry
.
entry
.
name
,
entry
.
entry
.
name
)))
}
}
openmole/bin/org.openmole.site/jvm/src/main/scala/org/openmole/site/Pages.scala
View file @
2a779400
...
...
@@ -18,17 +18,16 @@
package
org.openmole.site
//import org.openmole.site.market._
import
org.openmole.site.market.GeneratedMarketEntry
import
org.openmole.site.market._
import
scalatags.Text.all._
//
import com.github.rjeschke._
//
import org.openmole.site.market.Market.Tags
import
com.github.rjeschke._
import
org.openmole.site.market.Market.Tags
import
scalatex.
{
openmole
⇒
scalatex
}
import
org.openmole.tool.file._
import
scalat
ex.
{
openmole
⇒
scalatex
}
import
scalat
ags.Text
import
scalaz.Reader
object
Pages
{
...
...
@@ -75,6 +74,7 @@ object Page {
}
case
class
PageIntro
(
intro
:
scalatags.Text.all.Frag
,
more
:
Option
[
scalatags.Text.all.Frag
]
=
None
)
trait
Page
{
def
content
:
Frag
...
...
@@ -171,7 +171,7 @@ object DocumentationPages {
_
.
children
}.
distinct
def
root
=
new
DocumentationPage
{
val
root
=
new
DocumentationPage
{
def
name
=
"Documentation"
override
def
title
=
Some
(
name
)
...
...
@@ -180,9 +180,9 @@ object DocumentationPages {
def
details
=
Seq
()
def
children
=
Seq
(
application
,
language
,
tutorial
/*
, market
*/
,
development
)
def
children
=
Seq
(
application
,
language
,
tutorial
,
market
,
development
)
def
application
=
new
DocumentationPage
{
val
application
=
new
DocumentationPage
{
def
name
=
"Application"
override
def
title
=
Some
(
name
)
...
...
@@ -193,7 +193,7 @@ object DocumentationPages {
def
details
=
Seq
()
def
migration
=
new
DocumentationPage
()
{
val
migration
=
new
DocumentationPage
()
{
def
children
:
Seq
[
DocumentationPage
]
=
Seq
()
def
name
:
String
=
"Migration"
...
...
@@ -206,7 +206,7 @@ object DocumentationPages {
}
}
def
language
=
val
language
=
new
DocumentationPage
{
def
name
=
"Language"
...
...
@@ -218,7 +218,7 @@ object DocumentationPages {
def
details
=
Seq
()
def
model
=
new
DocumentationPage
{
val
model
=
new
DocumentationPage
{
def
name
=
"Models"
override
def
title
=
Some
(
name
)
...
...
@@ -231,7 +231,7 @@ object DocumentationPages {
lazy
val
modelIntro
=
Some
(
PageIntro
(
scalatex
.
documentation
.
language
.
ModelIntro
(),
Some
(
scalatex
.
documentation
.
language
.
Model
())))
def
scala
=
new
DocumentationPage
{
val
scala
=
new
DocumentationPage
{
def
name
=
"Scala"
override
def
title
=
Some
(
name
)
...
...
@@ -245,7 +245,7 @@ object DocumentationPages {
override
def
intro
=
modelIntro
}
def
java
=
new
DocumentationPage
{
val
java
=
new
DocumentationPage
{
def
name
=
"Java"
override
def
title
=
Some
(
name
)
...
...
@@ -259,7 +259,7 @@ object DocumentationPages {
override
def
intro
=
modelIntro
}
def
native
=
new
DocumentationPage
{
val
native
=
new
DocumentationPage
{
def
name
=
"Native"
override
def
title
=
Some
(
name
)
...
...
@@ -273,7 +273,7 @@ object DocumentationPages {
override
def
intro
=
modelIntro
}
def
ccplusplus
=
new
DocumentationPage
{
val
ccplusplus
=
new
DocumentationPage
{
def
name
=
"C/C++"
override
def
title
=
Some
(
name
)
...
...
@@ -287,7 +287,7 @@ object DocumentationPages {
override
def
intro
=
modelIntro
}
def
rscript
=
new
DocumentationPage
{
val
rscript
=
new
DocumentationPage
{
def
name
=
"R Script"
override
def
title
=
Some
(
name
)
...
...
@@ -301,7 +301,7 @@ object DocumentationPages {
override
def
intro
=
modelIntro
}
def
python
=
new
DocumentationPage
{
val
python
=
new
DocumentationPage
{
def
name
=
"Python"
override
def
title
=
Some
(
name
)
...
...
@@ -315,7 +315,7 @@ object DocumentationPages {
override
def
intro
=
modelIntro
}
def
netLogo
=
new
DocumentationPage
{
val
netLogo
=
new
DocumentationPage
{
def
name
=
"NetLogo"
override
def
title
=
Some
(
name
)
...
...
@@ -329,7 +329,7 @@ object DocumentationPages {
override
def
intro
=
modelIntro
}
def
mole
=
new
DocumentationPage
{
val
mole
=
new
DocumentationPage
{
def
name
=
"Mole"
override
def
title
=
Some
(
name
)
...
...
@@ -344,7 +344,7 @@ object DocumentationPages {
}
//details
def
nativeAPI
=
new
DocumentationPage
{
val
nativeAPI
=
new
DocumentationPage
{
override
def
id
=
"NativeAPI"
def
name
=
"API"
...
...
@@ -358,7 +358,7 @@ object DocumentationPages {
def
content
=
scalatex
.
documentation
.
details
.
NativeAPI
()
}
def
nativePackaging
=
new
DocumentationPage
{
val
nativePackaging
=
new
DocumentationPage
{
override
def
id
=
"NativePackaging"
def
name
=
"Native Packaging"
...
...
@@ -373,7 +373,7 @@ object DocumentationPages {
}
//troubleshooting care
def
CARETroubleshooting
=
new
DocumentationPage
{
val
CARETroubleshooting
=
new
DocumentationPage
{
override
def
id
=
"CARETroubleshooting"
def
name
=
"CARE Troubleshooting"
...
...
@@ -388,7 +388,7 @@ object DocumentationPages {
}
}
def
sampling
=
new
DocumentationPage
{
val
sampling
=
new
DocumentationPage
{
def
name
=
"Samplings"
override
def
title
=
Some
(
name
)
...
...
@@ -400,7 +400,7 @@ object DocumentationPages {
def
content
=
scalatex
.
documentation
.
language
.
Sampling
()
}
def
transition
=
new
DocumentationPage
{
val
transition
=
new
DocumentationPage
{
def
name
=
"Transitions"
override
def
title
=
Some
(
name
)
...
...
@@ -412,7 +412,7 @@ object DocumentationPages {
def
content
=
scalatex
.
documentation
.
language
.
Transition
()
}
def
hook
=
new
DocumentationPage
{
val
hook
=
new
DocumentationPage
{
def
name
=
"Hooks"
override
def
title
=
Some
(
name
)
...
...
@@ -424,7 +424,7 @@ object DocumentationPages {
def
content
=
scalatex
.
documentation
.
language
.
Hook
()
}
def
environment
=
new
DocumentationPage
{
val
environment
=
new
DocumentationPage
{
def
name
=
"Environments"
override
def
title
=
Some
(
name
)
...
...
@@ -437,7 +437,7 @@ object DocumentationPages {
lazy
val
envIntro
=
Some
(
PageIntro
(
scalatex
.
documentation
.
language
.
environment
.
EnvironmentIntro
(),
Some
(
scalatex
.
documentation
.
language
.
Environment
())))
def
multithread
=
new
DocumentationPage
{
val
multithread
=
new
DocumentationPage
{
override
def
id
=
"MultiThread"
def
name
=
"Multi-threads"
...
...
@@ -453,7 +453,7 @@ object DocumentationPages {
override
def
intro
=
envIntro
}
def
ssh
=
new
DocumentationPage
{
val
ssh
=
new
DocumentationPage
{
def
name
=
"SSH"
override
def
title
=
Some
(
name
)
...
...
@@ -467,7 +467,7 @@ object DocumentationPages {
override
def
intro
=
envIntro
}
def
egi
=
new
DocumentationPage
{
val
egi
=
new
DocumentationPage
{
def
name
=
"EGI"
override
def
title
=
Some
(
name
)
...
...
@@ -481,7 +481,7 @@ object DocumentationPages {
override
def
intro
=
envIntro
}
def
cluster
=
new
DocumentationPage
{
val
cluster
=
new
DocumentationPage
{
def
name
=
"Clusters"
override
def
title
=
Some
(
name
)
...
...
@@ -495,7 +495,7 @@ object DocumentationPages {
override
def
intro
=
envIntro
}
def
desktopGrid
=
new
DocumentationPage
{
val
desktopGrid
=
new
DocumentationPage
{
override
def
id
=
"DesktopGrid"
def
name
=
"Desktop Grid"
...
...
@@ -568,7 +568,7 @@ object DocumentationPages {
}
}
def
tutorial
=
new
DocumentationPage
{
lazy
val
tutorial
=
new
DocumentationPage
{
def
name
=
"Tutorials"
override
def
title
=
Some
(
name
)
...
...
@@ -577,12 +577,12 @@ object DocumentationPages {
def
details
=
Seq
()
/*++
marketEntries.filter(_.tags.exists(_ == Tags.tutorial)).flatMap(MD.generatePage(_))*/
def
content
=
scalatex
.
documentation
.
language
.
Tutorial
()
def
helloWorld
=
new
DocumentationPage
{
println
(
"marketEntries "
+
marketEntries
.
size
)
marketEntries
.
filter
(
_
.
tags
.
exists
(
_
==
Tags
.
tutorial
)).
flatMap
(
MD
.
generatePage
(
_
))
val
helloWorld
=
new
DocumentationPage
{
override
def
id
=
"HelloWord"
def
name
=
"Hello World"
...
...
@@ -596,7 +596,7 @@ object DocumentationPages {
def
content
=
Pages
.
gettingStarted
.
content
}
def
resume
=
new
DocumentationPage
{
val
resume
=
new
DocumentationPage
{
override
def
id
=
"ResumeWorkflow"
def
name
=
"Resume workflow"
...
...
@@ -610,7 +610,7 @@ object DocumentationPages {
def
content
=
scalatex
.
documentation
.
language
.
tutorial
.
Resume
()
}
def
headlessNetLogo
=
new
DocumentationPage
{
val
headlessNetLogo
=
new
DocumentationPage
{
override
def
id
=
"NetlogoHeadless"
def
name
=
"NetLogo Headless"
...
...
@@ -624,7 +624,7 @@ object DocumentationPages {
def
content
=
scalatex
.
documentation
.
language
.
tutorial
.
HeadlessNetLogo
()
}
def
netLogoGA
=
new
DocumentationPage
{
val
netLogoGA
=
new
DocumentationPage
{
override
def
id
=
"GAwithNetLogo"
def
name
=
"GA with NetLogo"
...
...
@@ -638,7 +638,7 @@ object DocumentationPages {
def
content
=
scalatex
.
documentation
.
language
.
tutorial
.
NetLogoGA
()
}
def
capsule
=
new
DocumentationPage
{
val
capsule
=
new
DocumentationPage
{
def
name
=
"Capsule"
override
def
title
=
Some
(
name
)
...
...
@@ -651,135 +651,116 @@ object DocumentationPages {
}
}
// def market = new DocumentationPage {
// def children: Seq[DocumentationPage] = pages
// def name: String = "Market Place"
// override def title = Some(name)
// def content = scalatex.documentation.Market()
//
// def themes: Seq[Market.Tag] =
// marketEntries.flatMap(_.entry.tags).distinct.sortBy(_.label.toLowerCase)
//
// def allEntries =
// new DocumentationPage {
// def children: Seq[DocumentationPage] = Seq()
// def name: String = "All"
// override def title = Some(name)
// def content = tagContent("All", marketEntries))
// }
//
// def pages = allEntries :: (themes map documentationPage).toList
//
// def documentationPage(t: Market.Tag) =
// new DocumentationPage {
// def children: Seq[DocumentationPage] = Seq()
// def name: String = t.label
// override def title = Some(name)
// def content = tagContent(t.label, marketEntries.filter(_.entry.tags.contains(t))))
// }
//
// def tagContent(label: String, entries: Seq[GeneratedMarketEntry]) =
// Seq(
// h1(label),
// ul(
// entries.sortBy(_.entry.name.toLowerCase).map {
// de ⇒ li(entryContent(de))
// }: _*
// )
// )
//
// def entryContent(deployedMarketEntry: GeneratedMarketEntry) = {
// def title: Modifier =
// deployedMarketEntry.viewURL match {
// case None ⇒ deployedMarketEntry.entry.name
// case Some(l) ⇒ a(deployedMarketEntry.entry.name, href := l)
// }
//
// def content =
// Seq[Modifier](
// deployedMarketEntry.readme.map {
// rm ⇒ RawFrag(txtmark.Processor.process(rm))
// }.getOrElse(p("No README.md available yet.")),
// a("Packaged archive", href := deployedMarketEntry.archive), " (can be imported in OpenMOLE)"
// ) ++ deployedMarketEntry.viewURL.map(u ⇒ br(a("Source repository", href := u)))
//
// Seq(
// title,
// p(div(id := "market-entry")(content: _*))
// )
// }
val
market
=
new
DocumentationPage
{
override
def
content
:
Text.all.Frag
=
div
(
tagContent
(
marketEntries
))
}
override
def
children
:
Seq
[
DocumentationPage
]
=
Seq
()
def
development
=
new
DocumentationPage
{
def
name
=
"Development"
override
def
name
:
String
=
"Market"
override
def
title
=
Some
(
name
)
override
def
details
:
Seq
[
Page
]
=
Seq
(
)
def
children
=
Seq
(
compilation
,
documentationWebsite
,
plugin
,
branching
,
webserver
)
def
tagContent
(
entries
:
Seq
[
GeneratedMarketEntry
])
=
ul
(
entries
.
sortBy
(
_
.
entry
.
name
.
toLowerCase
).
map
{
de
⇒
li
(
entryContent
(
de
))
}
:
_
*
)
def
content
=
scalatex
.
documentation
.
Development
()
def
entryContent
(
deployedMarketEntry
:
GeneratedMarketEntry
)
=
{
def
title
:
Modifier
=
deployedMarketEntry
.
viewURL
match
{
case
None
⇒
deployedMarketEntry
.
entry
.
name
case
Some
(
l
)
⇒
a
(
deployedMarketEntry
.
entry
.
name
,
href
:=
l
)
}
def
details
=
Seq
()
def
content
=
Seq
[
Modifier
](
deployedMarketEntry
.
readme
.
map
{
rm
⇒
RawFrag
(
txtmark
.
Processor
.
process
(
rm
))
}.
getOrElse
(
p
(
"No README.md available yet."
)),
a
(
"Packaged archive"
,
href
:=
deployedMarketEntry
.
archive
),
" (can be imported in OpenMOLE)"
)
++
deployedMarketEntry
.
viewURL
.
map
(
u
⇒
br
(
a
(
"Source repository"
,
href
:=
u
)))
def
compilation
=
new
DocumentationPage
{
def
name
=
"Compilation"
div
(
scalatags
.
Text
.
all
.
id
:=
"market-entry"
)(
content
:
_
*
)
}
def
themes
:
Seq
[
Market.Tag
]
=
{
marketEntries
.
flatMap
(
_
.
entry
.
tags
).
distinct
.
sortBy
(
_
.
label
.
toLowerCase
)
}
}
def
development
=
new
DocumentationPage
{
def
name
=
"Development"
override
def
title
=
Some
(
name
)
def
children
=
Seq
()
def
children
=
Seq
(
compilation
,
documentationWebsite
,
plugin
,
branching
,
webserver
)
def
content
=
scalatex
.
documentation
.
Development
()
def
details
=
Seq
()
def
co
ntent
=
scalatex
.
documentation
.
development
.
Compilation
()
}
def
co
mpilation
=
new
DocumentationPage
{
def
name
=
"Compilation"
def
documentationWebsite
=
new
DocumentationPage
{
def
name
=
"Documentation"
override
def
title
=
Some
(
name
)
override
def
title
=
Some
(
name
)
def
children
=
Seq
(
)
def
children
=
Seq
()
def
details
=
Seq
()
def
details
=
Seq
()
def
content
=
scalatex
.
documentation
.
development
.
Compilation
()
}
def
content
=
scalatex
.
documentation
.
development
.
Documentation
Website
()
}