Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openmole
gate
Commits
96f90045
Commit
96f90045
authored
Jul 30, 2014
by
Mathieu leclaire
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor and remove scaladget dependency
parent
4dcd9577
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
9 deletions
+92
-9
index.html.template
client/src/main/resources/index.html.template
+0
-0
logback.xml
client/src/main/resources/logback.xml
+0
-0
Client.scala
client/src/main/scala/fr/iscpif/client/Client.scala
+6
-4
JsRxTags.scala
client/src/main/scala/fr/iscpif/client/JsRxTags.scala
+80
-0
ScalaTraJSTagsWireRxBuild.scala
project/ScalaTraJSTagsWireRxBuild.scala
+4
-5
MyScalatraServlet.scala
server/src/main/scala/fr/iscpif/app/MyScalatraServlet.scala
+2
-0
No files found.
ui
/src/main/resources/index.html.template
→
client
/src/main/resources/index.html.template
View file @
96f90045
File moved
ui
/src/main/resources/logback.xml
→
client
/src/main/resources/logback.xml
View file @
96f90045
File moved
ui/src/main/scala/fr/iscpif/ui
/Client.scala
→
client/src/main/scala/fr/iscpif/client
/Client.scala
View file @
96f90045
package
ui
package
client
import
java.util.UUID
import
org.scalajs.dom
import
org.scalajs.dom.HTMLElement
...
...
@@ -13,11 +15,10 @@ import org.scalajs.dom.extensions.Ajax
import
scala.Some
import
shared._
import
autowire._
import
fr.iscpif.scaladget.JsRxTags._
import
JsRxTags._
@JSExport
object
Plo
t
{
object
Clien
t
{
val
helloValue
=
Var
(
0
)
...
...
@@ -43,6 +44,7 @@ object Post extends autowire.Client[Web] {
override
def
callRequest
(
req
:
Request
)
:
Future
[
String
]
=
{
val
url
=
req
.
path
.
mkString
(
"/"
)
println
(
" URL "
+
url
)
dom
.
extensions
.
Ajax
.
post
(
url
=
"http://localhost:8080/"
+
url
,
data
=
upickle
.
write
(
req
.
args
)
...
...
client/src/main/scala/fr/iscpif/client/JsRxTags.scala
0 → 100644
View file @
96f90045
/*
* Copyright (C) 21/07/14 mathieu
*
* 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/>.
*/
package
client
import
scala.collection.
{
SortedMap
,
mutable
}
import
scalatags.JsDom._
import
scala.util.
{
Failure
,
Success
,
Random
}
import
all._
import
rx._
import
rx.core.
{
Propagator
,
Obs
}
import
org.scalajs.dom
import
org.scalajs.dom.
{
Element
,
DOMParser
}
import
scala.scalajs.js
/**
* A minimal binding between Scala.Rx and Scalatags and Scala-Js-Dom
*/
object
JsRxTags
{
/**
* Wraps reactive strings in spans, so they can be referenced/replaced
* when the Rx changes.
*/
implicit
def
RxStr
[
T
](
r
:
Rx
[
T
])(
implicit
f
:
T
=>
Modifier
)
:
Modifier
=
{
rxMod
(
Rx
(
span
(
r
())))
}
/**
* Sticks some Rx into a Scalatags fragment, which means hooking up an Obs
* to propagate changes into the DOM via the element's ID. Monkey-patches
* the Obs onto the element itself so we have a reference to kill it when
* the element leaves the DOM (e.g. it gets deleted).
*/
implicit
def
rxMod
[
T
<:
dom.HTMLElement
](
r
:
Rx
[
HtmlTag
])
:
Modifier
=
{
def
rSafe
=
r
.
toTry
match
{
case
Success
(
v
)
=>
v
.
render
case
Failure
(
e
)
=>
span
(
e
.
toString
,
backgroundColor
:=
"red"
).
render
}
var
last
=
rSafe
Obs
(
r
,
skipInitial
=
true
)
{
val
newLast
=
rSafe
last
.
parentElement
.
replaceChild
(
newLast
,
last
)
last
=
newLast
}
bindElement
(
last
)
}
implicit
def
RxAttrValue
[
T:
scalatags.JsDom.AttrValue
]
=
new
scalatags
.
JsDom
.
AttrValue
[
Rx
[
T
]]
{
def
apply
(
t
:
Element
,
a
:
Attr
,
r
:
Rx
[
T
])
:
Unit
=
{
Obs
(
r
)
{
implicitly
[
scalatags.JsDom.AttrValue
[
T
]].
apply
(
t
,
a
,
r
())
}
}
}
implicit
def
RxStyleValue
[
T:
scalatags.JsDom.StyleValue
]
=
new
scalatags
.
JsDom
.
StyleValue
[
Rx
[
T
]]
{
def
apply
(
t
:
Element
,
s
:
Style
,
r
:
Rx
[
T
])
:
Unit
=
{
Obs
(
r
)
{
implicitly
[
scalatags.JsDom.StyleValue
[
T
]].
apply
(
t
,
s
,
r
())
}
}
}
}
project/ScalaTraJSTagsWireRxBuild.scala
View file @
96f90045
...
...
@@ -14,9 +14,9 @@ object ScalaTraJSTagsWireRxBuild extends Build {
lazy
val
shared
=
project
.
in
(
file
(
"./shared"
))
.
settings
(
scalaVersion
:=
ScalaVersion
)
lazy
val
ui
=
Project
(
"
ui
"
,
file
(
"./
ui
"
),
lazy
val
client
=
Project
(
"
client
"
,
file
(
"./
client
"
),
settings
=
Defaults
.
defaultSettings
++
jsManagerSettings
++
Seq
(
version
:=
Version
,
scalaVersion
:=
ScalaVersion
,
...
...
@@ -26,7 +26,6 @@ object ScalaTraJSTagsWireRxBuild extends Build {
"com.lihaoyi"
%%%
"autowire"
%
"0.1.2"
,
"com.scalatags"
%%%
"scalatags"
%
"0.3.8"
,
"com.scalarx"
%%%
"scalarx"
%
"0.2.5"
,
"fr.iscpif"
%%%
"scaladget"
%
"0.1.0-SNAPSHOT"
,
"org.scala-lang.modules.scalajs"
%%%
"scalajs-dom"
%
"0.6"
,
"org.scala-lang.modules.scalajs"
%%%
"scalajs-jquery"
%
"0.6"
),
...
...
@@ -38,7 +37,7 @@ object ScalaTraJSTagsWireRxBuild extends Build {
lazy
val
server
=
Project
(
"server"
,
file
(
"./server"
),
settings
=
Defaults
.
defaultSettings
++
ScalatraPlugin
.
scalatraWithJRebel
++
jsManagerSettings
++
Seq
(
settings
=
Defaults
.
defaultSettings
++
ScalatraPlugin
.
scalatraWithJRebel
++
Seq
(
organization
:=
Organization
,
name
:=
Name
,
version
:=
Version
,
...
...
server/src/main/scala/fr/iscpif/app/MyScalatraServlet.scala
View file @
96f90045
package
fr.iscpif.app
import
java.util.UUID
import
org.scalatra._
import
scala.concurrent.ExecutionContext.Implicits.global
import
autowire._
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment