first commit
This commit is contained in:
commit
823ecdd500
26 files changed
+2110
No files matched your search
+24
@@ -0,0 +1,24 @@
|
|||||||
|
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Folders
|
||||||
|
_obj
|
||||||
|
_test
|
||||||
|
|
||||||
|
# Architecture specific extensions/prefixes
|
||||||
|
*.[568vq]
|
||||||
|
[568vq].out
|
||||||
|
|
||||||
|
*.cgo1.go
|
||||||
|
*.cgo2.c
|
||||||
|
_cgo_defun.c
|
||||||
|
_cgo_gotypes.go
|
||||||
|
_cgo_export.*
|
||||||
|
|
||||||
|
_testmain.go
|
||||||
|
|
||||||
|
*.exe
|
||||||
|
*.test
|
||||||
|
*.prof
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2014 didier amyot
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"gopkg.in/mgo.v2/bson"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
Api structure
|
||||||
|
|
||||||
|
/weblabs
|
||||||
|
POST: create a new weblab. The payload must be
|
||||||
|
{
|
||||||
|
"name": "web lab frendly name",
|
||||||
|
"cases": ["case_name_1", "case_name_2", ..., "case_name_n"],
|
||||||
|
"probabilities": [prob_1, prob_2, ..., prob_n], // the sum must be 1
|
||||||
|
"private": false,
|
||||||
|
}
|
||||||
|
GET:
|
||||||
|
returns the list of all the created weblabs
|
||||||
|
|
||||||
|
/weblabs/<id>
|
||||||
|
GET: returns the weblab as
|
||||||
|
|
||||||
|
/weblabs/<id>/history
|
||||||
|
GET: get the history
|
||||||
|
*/
|
||||||
|
|
||||||
|
// the smallest value that makes two floats the same.
|
||||||
|
const epsilon float64 = 0.000000001
|
||||||
|
|
||||||
|
type Cases struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Probability float64 `json:"probability"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type WeblabDefinition struct {
|
||||||
|
Id bson.ObjectId `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Cases []*Cases `json:"cases"`
|
||||||
|
Private bool `json:"private"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WeblabDefinition) verifyCasesStructure() error {
|
||||||
|
names := make(map[string]bool)
|
||||||
|
for _, c := range w.Cases {
|
||||||
|
if c.Probability+epsilon < 0 {
|
||||||
|
return errors.New("probability cannot be less 0")
|
||||||
|
}
|
||||||
|
if c.Probability-epsilon > 1 {
|
||||||
|
return errors.New("probability cannot be greater 0")
|
||||||
|
}
|
||||||
|
c.Name = strings.Trim(c.Name, " \t\n\r")
|
||||||
|
if c.Name == "" {
|
||||||
|
return errors.New("weblab cannot have empty names")
|
||||||
|
}
|
||||||
|
names[c.Name] = true
|
||||||
|
}
|
||||||
|
if len(names) != len(w.Cases) {
|
||||||
|
return errors.New("multiple weblab cannot have the same name")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *WeblabDefinition) VerifyProbabilitySum() {
|
||||||
|
|
||||||
|
}
|
||||||
|
func (w *WeblabDefinition) Verify() error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateNewWeblab(w http.ResponseWriter, request *http.Request) {
|
||||||
|
d := json.NewDecoder(request.Body)
|
||||||
|
wab := new(WeblabDefinition)
|
||||||
|
if err := d.Decode(d); err != nil {
|
||||||
|
w.WriteHeader(400)
|
||||||
|
fmt.Fprint(w, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wab.Id = bson.NewObjectId()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
|
||||||
|
mgo "gopkg.in/mgo.v2"
|
||||||
|
goyaml "gopkg.in/yaml.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const PARAM_FILE string = "params.yml"
|
||||||
|
|
||||||
|
type Params struct {
|
||||||
|
Port int `yaml:"port,omitempty"`
|
||||||
|
Host string `yaml:"host,omitempty"`
|
||||||
|
Mongo *MongoParams `yaml:"mongo,omitempty"`
|
||||||
|
MongoClient *mgo.Session `yaml:"-"`
|
||||||
|
DB *mgo.Database `yaml:"-"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MongoParams struct {
|
||||||
|
Url string `yaml:"url,omitempty"`
|
||||||
|
DatabaseName string `yaml:"database_name,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Params) LoadFromYamlFile(fileName string) error {
|
||||||
|
data, err := ioutil.ReadFile(fileName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return this.LoadFromYamlData(data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Params) LoadFromYamlData(data []byte) error {
|
||||||
|
var err error
|
||||||
|
p := new(Params)
|
||||||
|
if err = goyaml.Unmarshal(data, p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.Host != "" {
|
||||||
|
this.Host = p.Host
|
||||||
|
}
|
||||||
|
if p.Port > 0 {
|
||||||
|
this.Port = p.Port
|
||||||
|
}
|
||||||
|
if p.Mongo == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if p.Mongo.Url != "" {
|
||||||
|
this.Mongo.Url = p.Mongo.Url
|
||||||
|
}
|
||||||
|
if p.Mongo.DatabaseName != "" {
|
||||||
|
this.Mongo.DatabaseName = p.Mongo.DatabaseName
|
||||||
|
}
|
||||||
|
if p.Mongo.DatabaseName != "" {
|
||||||
|
this.Mongo.DatabaseName = p.Mongo.DatabaseName
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Params) initMongo() error {
|
||||||
|
var err error
|
||||||
|
this.MongoClient, err = mgo.Dial(this.Mongo.Url)
|
||||||
|
this.DB = this.MongoClient.DB(this.Mongo.DatabaseName)
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDefaultParams() *Params {
|
||||||
|
mongoParams := &MongoParams{
|
||||||
|
Url: "localhost:27017",
|
||||||
|
DatabaseName: "union",
|
||||||
|
}
|
||||||
|
return &Params{7777, "localhost", mongoParams, nil, nil}
|
||||||
|
}
|
||||||
|
|
||||||
|
var params = GetDefaultParams()
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
if err := params.LoadFromYamlFile(PARAM_FILE); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if err := params.initMongo(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
# This is union web site params' file. The file is in yaml format. The file
|
||||||
|
# should be auto-documented
|
||||||
|
|
||||||
|
|
||||||
|
# the port where the union web site will run
|
||||||
|
port: 1999
|
||||||
|
|
||||||
|
# the host name. 0.0.0.0 to share the service with everyone on the network.
|
||||||
|
# localhost for running on localhost without the possibility to share the
|
||||||
|
# service
|
||||||
|
host: 0.0.0.0 #localhost
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# all the params relative to mongodb
|
||||||
|
mongo:
|
||||||
|
# the url where to get mongodb
|
||||||
|
url: localhost:27017
|
||||||
|
|
||||||
|
# the name of the database to use
|
||||||
|
database_name: amazon_union
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
const yaml_params = `
|
||||||
|
---
|
||||||
|
|
||||||
|
port: 9999
|
||||||
|
|
||||||
|
host: 0.0.0.0 #localhost
|
||||||
|
|
||||||
|
# all the params relative to mongodb
|
||||||
|
mongo:
|
||||||
|
# the url where to get mongodb
|
||||||
|
url: localhost:1234
|
||||||
|
|
||||||
|
# the name of the database to use
|
||||||
|
database_name: geography
|
||||||
|
|
||||||
|
# the name of the collection where all the street can be found
|
||||||
|
street_collection: quebec_street_map
|
||||||
|
|
||||||
|
|
||||||
|
# the collection where all the heat map point will be stored
|
||||||
|
heat_map_collection: quebec_heat_map # quebec_heat_map
|
||||||
|
`
|
||||||
|
|
||||||
|
func TestLoadFromYamlData(t *testing.T) {
|
||||||
|
p := GetDefaultParams()
|
||||||
|
if err := p.LoadFromYamlData([]byte(yaml_params)); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if p.Port != 9999 {
|
||||||
|
t.Error("port")
|
||||||
|
}
|
||||||
|
if p.Host != "0.0.0.0" {
|
||||||
|
t.Error("host")
|
||||||
|
}
|
||||||
|
if p.Mongo.Url != "localhost:1234" {
|
||||||
|
t.Error("mongo.url")
|
||||||
|
}
|
||||||
|
if p.Mongo.Url != "localhost:1234" {
|
||||||
|
t.Error("mongo.url")
|
||||||
|
}
|
||||||
|
if p.Mongo.DatabaseName != "geography" {
|
||||||
|
t.Error("mongo.DatabaseName")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
)
|
||||||
|
|
||||||
|
func createMuxRouter() http.Handler {
|
||||||
|
r := mux.NewRouter()
|
||||||
|
serveStatic(r.PathPrefix("/").Subrouter())
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
r := createMuxRouter()
|
||||||
|
http.Handle("/", r)
|
||||||
|
address := params.Host + ":" + strconv.Itoa(params.Port)
|
||||||
|
fmt.Println("server running at", address)
|
||||||
|
if err := http.ListenAndServe(address, createMuxRouter()); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
logs/*
|
||||||
|
!.gitkeep
|
||||||
|
node_modules/
|
||||||
|
bower_components/
|
||||||
|
tmp
|
||||||
|
.DS_Store
|
||||||
|
.idea
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "angular-requirejs-seed",
|
||||||
|
"description": "AngularJS seed project modified for requireJS support.",
|
||||||
|
"version": "0.2.0",
|
||||||
|
"homepage": "https://github.com/tnajdek/angular-requirejs-seed",
|
||||||
|
"license": "MIT",
|
||||||
|
"ignore": [
|
||||||
|
"**/.*",
|
||||||
|
"node_modules",
|
||||||
|
"bower_components",
|
||||||
|
"test",
|
||||||
|
"tests"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"angular": "~1.2.1",
|
||||||
|
"angular-route": "~1.2.1",
|
||||||
|
"angular-scenario": "~1.2.1",
|
||||||
|
"angular-mocks": "~1.2.1",
|
||||||
|
"requirejs": "~2.1.9",
|
||||||
|
"requirejs-text": "~2.0.10",
|
||||||
|
"foundation": "zurb/bower-foundation",
|
||||||
|
"html5-boilerplate": "~4.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
define [
|
||||||
|
"angular"
|
||||||
|
"filters"
|
||||||
|
"services"
|
||||||
|
"directives"
|
||||||
|
"controllers"
|
||||||
|
"angularRoute"
|
||||||
|
], (angular, filters, services, directives, controllers) ->
|
||||||
|
|
||||||
|
# Declare app level module which depends on filters, and services
|
||||||
|
angular.module "myApp", [
|
||||||
|
"ngRoute"
|
||||||
|
"myApp.filters"
|
||||||
|
"myApp.services"
|
||||||
|
"myApp.directives"
|
||||||
|
"myApp.controllers"
|
||||||
|
]
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
define ["angular", "services"], (angular) ->
|
||||||
|
|
||||||
|
# Controllers
|
||||||
|
|
||||||
|
# Sample controller where service is being used
|
||||||
|
|
||||||
|
# More involved example where controller is required from an external file
|
||||||
|
controllers = angular.module("myApp.controllers", ["myApp.services"])
|
||||||
|
|
||||||
|
controllers.controller("MyCtrl1", [
|
||||||
|
"$scope"
|
||||||
|
"$injector"
|
||||||
|
($scope, $injector) ->
|
||||||
|
require ["controllers/myctrl1"], (myctrl1) ->
|
||||||
|
|
||||||
|
# injector method takes an array of modules as the first argument
|
||||||
|
# if you want your controller to be able to use components from
|
||||||
|
# any of your other modules, make sure you include it together with 'ng'
|
||||||
|
# Furthermore we need to pass on the $scope as it's unique to this controller
|
||||||
|
$injector.invoke(myctrl1, this, {$scope: $scope})
|
||||||
|
|
||||||
|
return
|
||||||
|
])
|
||||||
|
|
||||||
|
controllers.controller( "MyCtrl2", [
|
||||||
|
"$scope"
|
||||||
|
"$injector"
|
||||||
|
($scope, $injector) ->
|
||||||
|
require ["controllers/myctrl2"], (myctrl2) ->
|
||||||
|
|
||||||
|
# injector method takes an array of modules as the first argument
|
||||||
|
# if you want your controller to be able to use components from
|
||||||
|
# any of your other modules, make sure you include it together with 'ng'
|
||||||
|
# Furthermore we need to pass on the $scope as it's unique to this controller
|
||||||
|
$injector.invoke(myctrl2, this, {$scope: $scope})
|
||||||
|
|
||||||
|
return
|
||||||
|
])
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
define [], ->
|
||||||
|
[
|
||||||
|
"$scope"
|
||||||
|
"$http"
|
||||||
|
($scope, $http) ->
|
||||||
|
|
||||||
|
# You can access the scope of the controller from here
|
||||||
|
$scope.welcomeMessage = "hey this is myctrl1.coffee!"
|
||||||
|
$scope.okay = "okay?"
|
||||||
|
|
||||||
|
# because this has happened asynchroneusly we've missed
|
||||||
|
# Angular's initial call to $apply after the controller has been loaded
|
||||||
|
# hence we need to explicityly call it at the end of our Controller constructor
|
||||||
|
$scope.$apply()
|
||||||
|
]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
define [], ->
|
||||||
|
[
|
||||||
|
"$scope"
|
||||||
|
"$http"
|
||||||
|
($scope, $http) ->
|
||||||
|
|
||||||
|
# You can access the scope of the controller from here
|
||||||
|
$scope.welcomeMessage = "hey this is myctrl2.coffee!"
|
||||||
|
|
||||||
|
# because this has happened asynchroneusly we've missed
|
||||||
|
# Angular's initial call to $apply after the controller has been loaded
|
||||||
|
# hence we need to explicityly call it at the end of our Controller constructor
|
||||||
|
$scope.$apply()
|
||||||
|
]
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
define [
|
||||||
|
"angular"
|
||||||
|
"services"
|
||||||
|
], (angular, services) ->
|
||||||
|
|
||||||
|
# Directives
|
||||||
|
angular.module("myApp.directives", ["myApp.services"]).directive "appVersion", [
|
||||||
|
"version"
|
||||||
|
(version) ->
|
||||||
|
return (scope, elm, attrs) ->
|
||||||
|
elm.text version
|
||||||
|
return
|
||||||
|
]
|
||||||
|
return
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
define ["angular", "services"], (angular, services) ->
|
||||||
|
|
||||||
|
# Filters
|
||||||
|
angular.module("myApp.filters", ["myApp.services"]).filter "interpolate", [
|
||||||
|
"version"
|
||||||
|
(version) ->
|
||||||
|
return (text) ->
|
||||||
|
String(text).replace /\%VERSION\%/g, version
|
||||||
|
]
|
||||||
|
return
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
require.config
|
||||||
|
paths:
|
||||||
|
angular: "/bower_components/angular/angular"
|
||||||
|
angularRoute: "/bower_components/angular-route/angular-route"
|
||||||
|
angularMocks: "/bower_components/angular-mocks/angular-mocks"
|
||||||
|
text: "/bower_components/requirejs-text/text"
|
||||||
|
|
||||||
|
shim:
|
||||||
|
angular:
|
||||||
|
exports: "angular"
|
||||||
|
|
||||||
|
angularRoute: ["angular"]
|
||||||
|
angularMocks:
|
||||||
|
deps: ["angular"]
|
||||||
|
exports: "angular.mock"
|
||||||
|
|
||||||
|
priority: ["angular"]
|
||||||
|
|
||||||
|
|
||||||
|
#http://code.angularjs.org/1.2.1/docs/guide/bootstrap#overview_deferred-bootstrap
|
||||||
|
window.name = "NG_DEFER_BOOTSTRAP!"
|
||||||
|
require ["angular", "app", "routes"], (angular, app, routes) ->
|
||||||
|
$html = angular.element(document.getElementsByTagName("html")[0])
|
||||||
|
angular.element().ready ->
|
||||||
|
angular.resumeBootstrap [app["name"]]
|
||||||
|
return
|
||||||
|
|
||||||
|
return
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
define [
|
||||||
|
"angular"
|
||||||
|
"app"
|
||||||
|
], (angular, app) ->
|
||||||
|
app.config [
|
||||||
|
"$routeProvider"
|
||||||
|
($routeProvider) ->
|
||||||
|
$routeProvider.when "/view1",
|
||||||
|
templateUrl: "/partials/partial1.html"
|
||||||
|
controller: "MyCtrl1"
|
||||||
|
|
||||||
|
$routeProvider.when "/view2",
|
||||||
|
templateUrl: "/partials/partial2.html"
|
||||||
|
controller: "MyCtrl2"
|
||||||
|
|
||||||
|
$routeProvider.otherwise redirectTo: "/view1"
|
||||||
|
]
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
define ["angular"], (angular) ->
|
||||||
|
|
||||||
|
# Services
|
||||||
|
|
||||||
|
# Demonstrate how to register services
|
||||||
|
# In this case it is a simple value service.
|
||||||
|
angular.module("myApp.services", []).value "version", "0.1"
|
||||||
|
return
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
var bower = require('gulp-bower');
|
||||||
|
var gulp = require('gulp');
|
||||||
|
var coffee = require('gulp-coffee');
|
||||||
|
var help = require('gulp-task-listing');
|
||||||
|
var clean = require('gulp-clean');
|
||||||
|
var sass = require('gulp-sass');
|
||||||
|
|
||||||
|
|
||||||
|
gulp.task('help', help);
|
||||||
|
|
||||||
|
gulp.task('bower', function() {
|
||||||
|
return bower()
|
||||||
|
.pipe(gulp.dest('bower_components/'))
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('sass', ['bower'], function () {
|
||||||
|
return gulp.src('./scss/*.scss')
|
||||||
|
.pipe(sass({includePaths: ['bower_components/foundation/scss']}))
|
||||||
|
.pipe(gulp.dest('./css'));
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('coffee', ['bower'], function() {
|
||||||
|
return gulp.src('coffee/**/*.coffee')
|
||||||
|
.pipe(coffee({bare: true}))
|
||||||
|
.pipe(gulp.dest('js/'))
|
||||||
|
});
|
||||||
|
|
||||||
|
gulp.task('clean', function(){
|
||||||
|
return gulp.src(["js/", "bower_components/", "css/"], {read: false})
|
||||||
|
.pipe(clean())
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
gulp.task('default', ['bower', 'sass', 'coffee']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
gulp.task('dev', ['bower', 'coffee'], function(){
|
||||||
|
gulp.watch('coffee/**/*.coffee', ['coffee']);
|
||||||
|
gulp.watch('./scss/*.scss', ['sass']);
|
||||||
|
});
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" ng-app="myApp" class="no-js">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>Angular-RequireJS sample app</title>
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<link rel="stylesheet" href="/css/style.css"/>
|
||||||
|
<script src="/bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>AngularJS + RequireJS</h1>
|
||||||
|
<ul class="menu">
|
||||||
|
<li><a href="#/view1">view1</a></li>
|
||||||
|
<li><a href="#/view2">view2</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<div ng-view></div>
|
||||||
|
|
||||||
|
<div>AngularJS + RequireJS seed app: v<span app-version></span></div>
|
||||||
|
<script data-main="/js/main" src="/bower_components/requirejs/require.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"gulp": "~3.8.9",
|
||||||
|
"gulp-bower": "0.0.7",
|
||||||
|
"gulp-clean": "~0.3.1",
|
||||||
|
"gulp-coffee": "~2.2.0",
|
||||||
|
"gulp-sass": "^1.2.4",
|
||||||
|
"gulp-task-listing": "~0.3.0",
|
||||||
|
"node-sass": "~1.2.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<p>This is the partial for view 1.</p>
|
||||||
|
<p>
|
||||||
|
Getting version from the scope: {{ scopedAppVersion }}
|
||||||
|
</p>
|
||||||
|
<h1>{{ okay }}</h1>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<p>This is the partial for view 2.</p>
|
||||||
|
<p>
|
||||||
|
{{ welcomeMessage }}
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Showing of 'interpolate' filter:
|
||||||
|
{{ 'Current version is v%VERSION%.' | interpolate }}
|
||||||
|
</p>
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,40 @@
|
|||||||
|
@import "settings";
|
||||||
|
@import "foundation";
|
||||||
|
|
||||||
|
// Or selectively include components
|
||||||
|
// @import
|
||||||
|
// "foundation/components/accordion",
|
||||||
|
// "foundation/components/alert-boxes",
|
||||||
|
// "foundation/components/block-grid",
|
||||||
|
// "foundation/components/breadcrumbs",
|
||||||
|
// "foundation/components/button-groups",
|
||||||
|
// "foundation/components/buttons",
|
||||||
|
// "foundation/components/clearing",
|
||||||
|
// "foundation/components/dropdown",
|
||||||
|
// "foundation/components/dropdown-buttons",
|
||||||
|
// "foundation/components/flex-video",
|
||||||
|
// "foundation/components/forms",
|
||||||
|
// "foundation/components/grid",
|
||||||
|
// "foundation/components/inline-lists",
|
||||||
|
// "foundation/components/joyride",
|
||||||
|
// "foundation/components/keystrokes",
|
||||||
|
// "foundation/components/labels",
|
||||||
|
// "foundation/components/magellan",
|
||||||
|
// "foundation/components/orbit",
|
||||||
|
// "foundation/components/pagination",
|
||||||
|
// "foundation/components/panels",
|
||||||
|
// "foundation/components/pricing-tables",
|
||||||
|
// "foundation/components/progress-bars",
|
||||||
|
// "foundation/components/reveal",
|
||||||
|
// "foundation/components/side-nav",
|
||||||
|
// "foundation/components/split-buttons",
|
||||||
|
// "foundation/components/sub-nav",
|
||||||
|
// "foundation/components/switch",
|
||||||
|
// "foundation/components/tables",
|
||||||
|
// "foundation/components/tabs",
|
||||||
|
// "foundation/components/thumbs",
|
||||||
|
// "foundation/components/tooltips",
|
||||||
|
// "foundation/components/top-bar",
|
||||||
|
// "foundation/components/type",
|
||||||
|
// "foundation/components/offcanvas",
|
||||||
|
// "foundation/components/visibility";
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"path"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
)
|
||||||
|
|
||||||
|
const STATIC_DIR_PATH = "static/"
|
||||||
|
|
||||||
|
func serveStatic(router *mux.Router) {
|
||||||
|
handler := func(w http.ResponseWriter, request *http.Request) {
|
||||||
|
vars := mux.Vars(request)
|
||||||
|
filepath := "/" + vars["path"]
|
||||||
|
w.Header().Set("Cache-Control", "public, max-age=43200")
|
||||||
|
http.ServeFile(w, request, path.Join(STATIC_DIR_PATH, filepath))
|
||||||
|
}
|
||||||
|
router.HandleFunc("/{path:.*}", handler)
|
||||||
|
}
|
||||||
Reference in new issue
Block a user