Skip to content

Commit

Permalink
Evo : Adding a timetable generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
dboissin committed Jul 18, 2011
1 parent 4636ce2 commit c7a3a2d
Show file tree
Hide file tree
Showing 17 changed files with 348 additions and 12 deletions.
29 changes: 29 additions & 0 deletions src/main/scala/poc/resources/Snippets.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package poc.resources

import java.util.GregorianCalendar
import java.util.Calendar
import java.util.Date
import java.text.SimpleDateFormat

object Snippets {

def generateTimetable(year: Int, month: Int, day: Int): String = {
val cal = new GregorianCalendar(year, month - 1, day, 8, 30)

def listDate(calendar: Calendar, idxDay: Int, idxHalfHour: Int): List[Date] = (idxDay, idxHalfHour) match {
case (6, 8) => calendar.getTime::Nil
case (d, 23) =>
val c = calendar.clone().asInstanceOf[Calendar]
c.add(Calendar.MINUTE, 60 * 12 + 30)
calendar.getTime::listDate(c, d + 1, 0)
case (d, hh) =>
val c = calendar.clone().asInstanceOf[Calendar]
c.add(Calendar.MINUTE, 30)
calendar.getTime::listDate(c, d, hh + 1)
}

val df = new SimpleDateFormat("yyyyMMddHHmm")
val dates = listDate(cal, 0, 0) map (d => df.format(d.getTime))
dates reduceLeft(_ + ", " + _)
}
}
2 changes: 1 addition & 1 deletion src/main/scala/poc/resources/TimetableView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import java.util.Date
case class TimetableView (
name: String,
workingTime: List[Date],
editable: Boolean
weekStartDateIdx: Option[String]
) extends DefaultRepresentations {
}

4 changes: 3 additions & 1 deletion src/main/scala/poc/service/impl/TimetableServiceImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package poc.service.impl
import poc.resources.TimetableView
import poc.service.TimetableService
import java.util.Date
import java.text.SimpleDateFormat

class TimetableServiceImpl extends TimetableService {

def cashierTimetable(year: String, week: String, name: String): TimetableView = {
println("TimetableServiceImpl - cashierTimetable method")
TimetableView(name, new Date()::Nil, false)
val startWeekIdx = new SimpleDateFormat("yyyyMMdd").format(new Date().getTime())
TimetableView(name, new Date()::Nil, Some(startWeekIdx)) //None)
}

}
1 change: 0 additions & 1 deletion src/main/webapp/WEB-INF/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
-@ val it: TimetableResource
- import Snippets._

%html
%body
%h1 Timetable index

#{generateTimetable(2011, 7, 18)}

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-@import val it: TimetableView

%html

%head
%script{:type => "text/javascript",
:src => "/js/jquery-1.5.1.min.js"}
Expand All @@ -19,9 +18,11 @@
#{workingTime.head}

%p
%span(id="select-result") Empty selection
%span(id="select-result") Empty selection

/ TODO refactor code below in a snippet object
%ol(id="selectable")
- for(i <- 1 to 48)
%li(class="ui-widget-content" id={"ih-" + i} )
- for(i <- 8 to 20)
- for(j <- 0 to 1)
%li(class="ui-widget-content" id={weekStartDateIdx.get + String.format("%02d", int2Integer(i)) + String.format("%02d", int2Integer((j * 30)))})

69 changes: 69 additions & 0 deletions src/main/webapp/WEB-INF/scalate/layouts/default.scaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
-#
-# Copyright (C) 2009-2011 the original author or authors.
-# See the notice.md file distributed with this work for additional
-# information regarding copyright ownership.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#

-@ var body: String
-@ var title : String = "Scalate Sample"
- response.setContentType("text/html")

-# Only include the console if it's available and the engine is in dev mode.
- val include_console = engine.isDevelopmentMode && engine.resourceLoader.exists("/org/fusesource/scalate/console/console_head.scaml")

!!! Basic
%html(lang="en")
%head
%meta(http-equiv="Content-Type" content="text/html; charset=utf-8")
%meta(name="description" content="description goes here")
%meta(name="keywords" content="keywords,goes,here")
%meta(name="author" content="Your Name")

- if (include_console)
= include("/org/fusesource/scalate/console/console_head.scaml")

%link(href={uri("/css/style.css")} rel="stylesheet" type="text/css")

- if (include_console)
%link(href={uri("/css/scalate/console.css")} rel="stylesheet" type="text/css")

%title
= title

%body
#navigation
.wrapper
%ul
- if (requestUri.startsWith("/index."))
%li
%span Home
- else
%li
%a(href={uri("/")})
Home
%li
%a(href="http://scalate.fusesource.org/")
Documentation

#content
.wrapper
!~~ body

#footer
.wrapper
%br
- if (include_console)
= include("/org/fusesource/scalate/console/console.scaml")

70 changes: 70 additions & 0 deletions src/main/webapp/css/scalate/console.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (C) 2009-2011 the original author or authors.
* See the notice.md file distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#scalate-console {
position:fixed;
top:40px;
right:10px;
background: #FDFCAD;
padding:10px;
border: 1px solid #BDBD81;
font-family:Arial,Verdana,Helvetica,sans-serif;
font-size: 80%;
max-width: 400px;
}

#scalate-console .archetypes ul, #scalate-console .templates ul, #scalate-console .resources ul, #scalate-console .layouts ul {
padding-left:20px;
overflow: auto;
}

#scalate-console .toggle {
text-align: right;
}

#scalate-console .toggle img {
vertical-align: middle;
}

#scalate-console div.attributes {
margin: 10px;
overflow: auto;
background: white;
}

#scalate-console div.attributes table th {
text-align: left;
color: #993333;
}
#scalate-console div.attributes table td {
padding:2px;
border-top: 1px solid #BDBD81;
}

#scalate-console div.body {
margin: 10px;
overflow: auto;
max-height: 300px;
background: white;
}

#scalate-console div.systemProperties {
margin: 10px;
overflow: auto;
max-height: 300px;
background: white;
}
137 changes: 137 additions & 0 deletions src/main/webapp/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**
* Copyright (C) 2009-2011 the original author or authors.
* See the notice.md file distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
body, html {
font-family:Arial,Verdana,Helvetica,sans-serif;
color: #666666;
}
body, html, table, tr, td, tbody {
padding:0;
margin:0;
vertical-align: top;
}
body {
padding-top: 20px;
}

h1, h2, h3, h4, h5, h6 {
overflow: visible;
color: #993333;
}

/*
h1 {
margin-top: 0em;
margin-bottom: 2em;
}
*/

p { margin-bottom:0px; }

a {
color: #990000;
font-weight:bold;
text-decoration: none;
}

a:hover {
color: #ff3333;
text-decoration: underline;
}

img {
border: none;
/*
padding-right:2em
*/
}

.wrapper { min-width: 762px; width: 762px; margin: 0 auto; }

#navigation { width: 100%; float: left;
font-family: Helvetica,Verdana,Arial,sans-serif;
background: black;
text-align:center; padding: 8px;
color: #b55;
font-size: 10pt;
font-weight: bold;
position: absolute;
top: 0px;
}
#navigation a { color: white; }
#navigation ul { display: block; margin:0; padding:0; }
#navigation li { list-style-type: none; display: inline; margin:0 5px 0 5px;}

#overview { width: 100%; padding-top:20px}
#overview div.message {
font-size: 11pt;
margin-top: -20px;
padding-left: 120px;
width: 350px;
}
#overview div.message h1{ margin-bottom: 5px; display:none; }
#overview div.message p{ margin-top: 0px; padding-bottom:14px; }

#content { width: 100%; float: left; }
#content .wrapper { min-width: 700px; width: 700px; margin: 0 auto; padding-top: 1em}
#content div.left {
float:left;
width:200px;
text-align:right;
font-size: 18pt;
clear:both;
}
#content h1 {
font-size: 18pt;
}
#content div.right {
float:right;
width:450px;
text-align:left;
}

#blog { width: 100%; float: left; }
#blog .wrapper { min-width: 600px; width: 600px; margin: 0 auto; }
#blog h1 {
font-family: HelveticaNeue,"Helvetica Neue",Helvetica,Arial,Verdana,sans-serif;
font-size: 18pt; color: #993333;
}
#blog h2 {
border-bottom: thin dashed #DDD;
font-size: 16pt;
margin-bottom: 5px;
}
#blog div.post p {
padding-left: 10px;
}
#blog div.post .details {
padding-top: 5px;
color: #ccc;
font-size: 10pt;
font-family: HelveticaNeue,"Helvetica Neue",Helvetica,Arial,Verdana,sans-serif;
}

#content .post h2 {
margin-bottom:5px;
}
#content .post .details {
color: #ccc;
font-size: 10pt;
font-family: HelveticaNeue,"Helvetica Neue",Helvetica,Arial,Verdana,sans-serif;
margin-top:0px;
}

Loading

0 comments on commit c7a3a2d

Please sign in to comment.