Skip to content

Commit 746df92

Browse files
committed
行動データ, contact form, default articleに英語文追加, Intro fix
1 parent 8428588 commit 746df92

12 files changed

Lines changed: 356 additions & 11 deletions

File tree

browser/finder/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import FinderList from './FinderList'
88
import FinderDetail from './FinderDetail'
99
import { selectArticle, searchArticle, refreshData } from './actions'
1010
import _ from 'lodash'
11+
import activityRecord from 'boost/activityRecord'
1112

1213
import remote from 'remote'
1314
var hideFinder = remote.getGlobal('hideFinder')
@@ -46,6 +47,7 @@ class FinderMain extends React.Component {
4647
if (e.keyCode === 13) {
4748
let { activeArticle } = this.props
4849
clipboard.writeText(activeArticle.content)
50+
activityRecord.emit('FINDER_COPY')
4951
hideFinder()
5052
e.preventDefault()
5153
}
@@ -174,6 +176,7 @@ var store = createStore(reducer)
174176

175177
window.onfocus = e => {
176178
store.dispatch(refreshData())
179+
activityRecord.emit('FINDER_OPEN')
177180
}
178181

179182
ReactDOM.render((

browser/main/HomePage/ArticleDetail.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import linkState from 'boost/linkState'
1212
import FolderMark from 'boost/components/FolderMark'
1313
import TagLink from 'boost/components/TagLink'
1414
import TagSelect from 'boost/components/TagSelect'
15+
import activityRecord from 'boost/activityRecord'
1516

1617
var modeOptions = aceModes.map(function (mode) {
1718
return {
@@ -93,6 +94,7 @@ export default class ArticleDetail extends React.Component {
9394
let { dispatch, activeArticle } = this.props
9495

9596
dispatch(destroyArticle(activeArticle.key))
97+
activityRecord.emit('ARTICLE_DESTROY')
9698
this.setState({openDeleteConfirmMenu: false})
9799
}
98100

@@ -182,7 +184,12 @@ export default class ArticleDetail extends React.Component {
182184

183185
delete newArticle.status
184186
newArticle.updatedAt = new Date()
185-
if (newArticle.createdAt == null) newArticle.createdAt = new Date()
187+
if (newArticle.createdAt == null) {
188+
newArticle.createdAt = new Date()
189+
activityRecord.emit('ARTICLE_CREATE')
190+
} else {
191+
activityRecord.emit('ARTICLE_UPDATE')
192+
}
186193

187194
dispatch(updateArticle(newArticle))
188195
dispatch(switchMode(IDLE_MODE))

browser/main/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import ReactDOM from 'react-dom'
1010
require('../styles/main/index.styl')
1111
import { openModal } from 'boost/modal'
1212
import Tutorial from 'boost/components/modal/Tutorial'
13+
import activityRecord from 'boost/activityRecord'
14+
15+
activityRecord.init()
1316

1417
let routes = (
1518
<Route path='/' component={MainPage}>

browser/styles/main/HomeContainer/lib/Preferences.styl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,70 @@ iptFocusBorderColor = #369DCD
119119
&.error
120120
color errorTextColor
121121
background-color errorBackgroundColor
122+
&.ContactTab
123+
&.done
124+
.message
125+
margin-top 75px
126+
margin-bottom 15px
127+
text-align center
128+
font-size 22px
129+
.checkIcon
130+
margin-bottom 15px
131+
font-size 144px
132+
color brandColor
133+
text-align center
134+
.control
135+
text-align center
136+
button
137+
border solid 1px borderColor
138+
border-radius 5px
139+
background-color white
140+
padding 15px 15px
141+
font-size 14px
142+
&:hover
143+
background-color darken(white, 10%)
144+
&.form
145+
padding 10px
146+
.title
147+
font-size 18px
148+
color brandColor
149+
margin-top 10px
150+
margin-bottom 10px
151+
.description
152+
margin-bottom 15px
153+
.iptGroup
154+
margin-bottom 10px
155+
input, textarea
156+
border-radius 5px
157+
border 1px solid borderColor
158+
font-size 14px
159+
outline none
160+
padding 10px 15px
161+
width 100%
162+
&:focus
163+
border-color iptFocusBorderColor
164+
textarea
165+
resize vertical
166+
min-height 150px
167+
.formControl
168+
clearfix()
169+
.alert
170+
float right
171+
padding 10px 15px
172+
margin 0 5px 0
173+
font-size 14px
174+
line-height normal
175+
button
176+
padding 10px 15px
177+
background-color brandColor
178+
color white
179+
font-size 14px
180+
border-radius 5px
181+
border none
182+
float right
183+
&:hover
184+
background-color lighten(brandColor, 10%)
185+
122186
&.AppSettingTab
123187
.description
124188
marked()

browser/styles/main/HomeContainer/lib/Tutorial.styl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ slideBgColor4 = #00B493
109109
.slide3
110110
background-color slideBgColor3
111111
.content
112+
font-size 18px
112113
&>img
113-
margin-top 45px
114+
margin-top 25px
114115
.slide4
115116
background-color slideBgColor4
116117
.content

lib/activityRecord.js

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import _ from 'lodash'
2+
import moment from 'moment'
3+
import keygen from 'boost/keygen'
4+
import dataStore from 'boost/dataStore'
5+
import { request, WEB_URL } from 'boost/api'
6+
7+
function isSameDate (a, b) {
8+
a = moment(a).utcOffset(+540).format('YYYYMMDD')
9+
b = moment(b).utcOffset(+540).format('YYYYMMDD')
10+
11+
return a === b
12+
}
13+
14+
export function init () {
15+
let records = getAllRecords()
16+
if (records == null) {
17+
saveAllRecords([])
18+
}
19+
20+
postRecords()
21+
if (window != null) {
22+
window.addEventListener('online', postRecords)
23+
window.setInterval(postRecords, 1000 * 60 * 60 * 24)
24+
}
25+
}
26+
27+
export function getClientKey () {
28+
let clientKey = localStorage.getItem('clientKey')
29+
if (!_.isString(clientKey) || clientKey.length !== 40) {
30+
clientKey = keygen()
31+
localStorage.setItem('clientKey', clientKey)
32+
}
33+
34+
return clientKey
35+
}
36+
37+
export function getAllRecords () {
38+
return JSON.parse(localStorage.getItem('activityRecords'))
39+
}
40+
41+
export function saveAllRecords (records) {
42+
localStorage.setItem('activityRecords', JSON.stringify(records))
43+
}
44+
45+
/*
46+
Post all records(except today)
47+
and remove all posted records
48+
*/
49+
export function postRecords (data) {
50+
let records = getAllRecords()
51+
records = records.filter(record => {
52+
return !isSameDate(new Date(), record.date)
53+
})
54+
55+
if (records.length === 0) {
56+
console.log('No records to post')
57+
return
58+
}
59+
60+
console.log('posting...', records)
61+
let input = {
62+
clientKey: getClientKey(),
63+
records
64+
}
65+
return request.post(WEB_URL + 'apis/activity')
66+
.send(input)
67+
.then(res => {
68+
let records = getAllRecords()
69+
let todayRecord = _.find(records, record => {
70+
return isSameDate(new Date(), record.date)
71+
})
72+
if (todayRecord != null) saveAllRecords([todayRecord])
73+
else saveAllRecords([])
74+
})
75+
.catch(err => {
76+
console.error(err)
77+
})
78+
}
79+
80+
export function emit (type, data) {
81+
let records = getAllRecords()
82+
83+
let index = _.findIndex(records, record => {
84+
return isSameDate(new Date(), record.date)
85+
})
86+
87+
let todayRecord
88+
if (index < 0) {
89+
todayRecord = {date: new Date()}
90+
records.push(todayRecord)
91+
}
92+
else todayRecord = records[index]
93+
console.log(type)
94+
switch (type) {
95+
case 'ARTICLE_CREATE':
96+
case 'ARTICLE_UPDATE':
97+
case 'ARTICLE_DESTROY':
98+
case 'FOLDER_CREATE':
99+
case 'FOLDER_UPDATE':
100+
case 'FOLDER_DESTROY':
101+
case 'FINDER_OPEN':
102+
case 'FINDER_COPY':
103+
todayRecord[type] = todayRecord[type] == null
104+
? 1
105+
: todayRecord[type] + 1
106+
107+
break
108+
}
109+
110+
let storeData = dataStore.getData()
111+
todayRecord.FOLDER_COUNT = _.isArray(storeData.folders) ? storeData.folders.length : 0
112+
todayRecord.ARTICLE_COUNT = _.isArray(storeData.articles) ? storeData.articles.length : 0
113+
114+
saveAllRecords(records)
115+
}
116+
117+
export default {
118+
init,
119+
emit,
120+
getClientKey,
121+
postRecords
122+
}

lib/api.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import superagent from 'superagent'
22
import superagentPromise from 'superagent-promise'
3-
import { API_URL } from '../config'
43
import auth from 'boost/auth'
54

6-
const request = superagentPromise(superagent, Promise)
5+
export const API_URL = 'http://boost-api4.elasticbeanstalk.com/'
6+
// export const WEB_URL = 'http://b00st.io/'
7+
export const WEB_URL = 'http://localhost:3333/'
8+
9+
export const request = superagentPromise(superagent, Promise)
710

811
export function login (input) {
912
return request
@@ -163,6 +166,9 @@ export function sendEmail (input) {
163166
}
164167

165168
export default {
169+
API_URL,
170+
WEB_URL,
171+
request,
166172
login,
167173
signup,
168174
updateUserInfo,

0 commit comments

Comments
 (0)