Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuya Otsuka committed Nov 21, 2016
1 parent fb97958 commit 5d61a39
Show file tree
Hide file tree
Showing 78 changed files with 1,284 additions and 675 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Created by https://www.gitignore.io/api/node,librarian-chef

build
build/

### Node ###
# Logs
Expand Down Expand Up @@ -159,3 +159,4 @@ fabric.properties


.idea/
.vscode/
20 changes: 11 additions & 9 deletions assets/css/normalize.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,16 @@

html,
body {
min-width : 100%;
min-height : 100%;
width : 100%;
height: 100%;
font-family: Ruda, sans-serif;
-webkit-font-smoothing : antialiased;
-moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
line-height: 1.1;
.root {
width : 100%;
height: 100%;
}

h1,
Expand All @@ -50,3 +46,9 @@ h5,
h6 {
font-size: 16px;
}

input,
select,
textarea {
font-size: 1em;
}
Binary file removed assets/images/sample.jpg
Binary file not shown.
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "neeco",
"version": "1.0.0",
"scripts": {
"build": "npm run build:development",
"build:development": "webpack -d",
"build:production": "NODE_ENV=production webpack -p",
"postinstall": "npm run postinstall:production",
"postinstall:development": "webpack -d",
"postinstall:production": "webpack -p",
"start": "browser-sync start --config bs-config.js"
},
"license": "ISC",
Expand All @@ -17,13 +17,11 @@
"connect-history-api-fallback": "^1.2.0",
"css-loader": "^0.23.1",
"html-webpack-plugin": "^2.19.0",
"react": "^15.1.0",
"react-dom": "^15.1.0",
"react-router": "^2.5.1",
"style-loader": "^0.13.1",
"webpack": "^1.13.1",
"whatwg-fetch": "^1.0.0"
},
"dependencies": {
"react": "^15.1.0",
"react-dom": "^15.1.0",
"react-router": "^2.5.1"
}
}
24 changes: 24 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Authentication from "neeco/views/Authentication"
import EventsView from "neeco/views/pages/EventsView"
import FilesView from "neeco/views/pages/FilesView"
import NewEventView from "neeco/views/pages/NewEventView"
import PasswordSettingsView from "neeco/views/pages/PasswordSettingsView"
import SettingsView from "neeco/views/pages/SettingsView"
import TopView from "neeco/views/pages/TopView"
import React from "react"
import {render} from "react-dom"
import {Router, Route, browserHistory} from "react-router"

render(
<Router history={browserHistory}>
<Route component={Authentication}>
<Route path="/" component={TopView} />
<Route path="/events" component={EventsView} />
<Route path="/files" component={FilesView} />
<Route path="/new_event" component={NewEventView} />
<Route path="/settings" component={SettingsView} />
<Route path="/settings/password" component={PasswordSettingsView} />
</Route>
</Router>,
document.querySelector(".root")
)
16 changes: 16 additions & 0 deletions src/neeco/api/auth/createToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import toFormData from "neeco/core/toFormData"
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/token"

export default ({userName, password}) =>
fetch(uri, {
method : "POST",
body : toFormData({
number : userName,
password: password
})
})
.then(response => response.json())
.then(x => Promise.resolve(x.token))
17 changes: 0 additions & 17 deletions src/neeco/api/auth/login.js

This file was deleted.

14 changes: 14 additions & 0 deletions src/neeco/api/auth/recreateToken.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/token/refresh"

export default ({token}) =>
fetch(uri, {
method : "GET",
headers: {
authorization: "Bearer " + token
}
})
.then(response => response.json())
.then(x => Promise.resolve(x.token))
25 changes: 25 additions & 0 deletions src/neeco/api/event/getEvents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import toURIQuery from "neeco/core/toURIQuery"
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/events/own"

export default ({token, offset, limit}) =>
fetch(uri + "?" + toURIQuery({
keyword: "test",
page : "1",
per : limit,
}), {
method : "GET",
headers: {
authorization: "Bearer " + token
}
})
.then(response => response.json())
.then(({events}) => Promise.resolve(
events.map((x) => ({
id : x.id,
title : x.title,
description: x.body
}))
))
31 changes: 31 additions & 0 deletions src/neeco/api/event/postEvent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import toFormData from "neeco/core/toFormData"
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/events"

export default ({
token,
title,
start_time,
end_time,
location,
description,
image
}) =>
fetch(uri, {
method : "POST",
headers: {
"authorization": "Bearer " + token
},
body : toFormData({
title : title,
started_at : start_time,
ended_at : end_time,
venue : location,
body : description,
event_image : image,
entry_upper_limit: 10,
})
})
.then(response => response.ok)
21 changes: 21 additions & 0 deletions src/neeco/api/file/getFolders.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import toURIQuery from "neeco/core/toURIQuery"
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/folders"

export default ({token}) =>
fetch(uri, {
method : "GET",
headers: {
authorization: "Bearer " + token
}
})
.then(response => response.json())
.then(({folders}) => Promise.resolve(
folders.map((x) => ({
id : x.id,
name : x.name,
updatedAt: x.updated_at
}))
))
6 changes: 3 additions & 3 deletions src/neeco/api/me.js → src/neeco/api/user/getCurrentUser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/users"
var uri = environment.api.host + "/user"

export default ({token}) =>
fetch(uri, {
Expand All @@ -12,9 +12,9 @@ export default ({token}) =>
})
.then(response => response.json())
.then(user => Promise.resolve({
id : user.user_id,
id : user.id,
number : user.number,
name : user.name,
image : user.image_path,
image : user.image,
college: user.college
}))
20 changes: 20 additions & 0 deletions src/neeco/api/user/getUserOfID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/users"

export default ({token, id}) =>
fetch(uri + "/" + id, {
method : "GET",
headers: {
authorization: "Bearer " + token
}
})
.then(response => response.json())
.then(user => Promise.resolve({
id : user.id,
number : user.number,
name : user.name,
image : user.image,
college: user.college
}))
24 changes: 24 additions & 0 deletions src/neeco/api/user/getUsers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/users"

export default ({token}) =>
fetch(uri, {
method : "GET",
headers: {
authorization: "Bearer " + token
}
})
.then(response => response.json())
.then({users} => Promise.resolve(
users.map(
x => ({
id : x.id,
number : x.number,
name : x.name,
image : x.image,
college: x.college
})
)
))
17 changes: 17 additions & 0 deletions src/neeco/api/user/updateImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import toFormData from "neeco/core/toFormData"
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/user/image"

export default ({token, image}) =>
fetch(uri, {
method : "PATCH",
headers: {
"authorization": "Bearer " + token
},
body : toFormData({
image: image
})
})
.then(response => response.ok)
17 changes: 17 additions & 0 deletions src/neeco/api/user/updateNote.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import toFormData from "neeco/core/toFormData"
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/user/note"

export default ({token, note}) =>
fetch(uri, {
method : "PATCH",
headers: {
"authorization": "Bearer " + token
},
body : toFormData({
note: note
})
})
.then(response => response.ok)
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import toFormData from "neeco/core/toFormData"
import environment from "neeco/environment"
import "whatwg-fetch"

var uri = environment.api.host + "/users/password"
var uri = environment.api.host + "/user/password"

export default ({token, password, newPassword}) =>
fetch(uri, {
method : "PATCH",
headers: {
"Content-Type" : "application/json",
"authorization": "Bearer " + token
},
body : JSON.stringify({
"current_password": password,
"new_password" : newPassword
body : toFormData({
current_password: password,
new_password : newPassword
})
})
.then(response => response.ok)
8 changes: 8 additions & 0 deletions src/neeco/core/toFormData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default (a) => {
var b = new FormData()

for (var i in a)
b.append(i, a[i])

return b
}
8 changes: 8 additions & 0 deletions src/neeco/core/toURIQuery.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default (a) => {
var b = ""

for (var i in a)
b += encodeURIComponent(i) + "='" + encodeURIComponent(a[i]) + "'&"

return b.slice(0, -1)
}
Loading

0 comments on commit 5d61a39

Please sign in to comment.