mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
clean lib
This commit is contained in:
@@ -1,20 +0,0 @@
|
|||||||
import React, { PropTypes } from 'react'
|
|
||||||
const electron = require('electron')
|
|
||||||
const shell = electron.shell
|
|
||||||
|
|
||||||
export default class ExternalLink extends React.Component {
|
|
||||||
handleClick (e) {
|
|
||||||
shell.openExternal(this.props.href)
|
|
||||||
e.preventDefault()
|
|
||||||
}
|
|
||||||
|
|
||||||
render () {
|
|
||||||
return (
|
|
||||||
<a onClick={e => this.handleClick(e)} {...this.props}/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ExternalLink.propTypes = {
|
|
||||||
href: PropTypes.string
|
|
||||||
}
|
|
||||||
@@ -4,7 +4,7 @@ import keygen from './keygen'
|
|||||||
function getClientKey () {
|
function getClientKey () {
|
||||||
let clientKey = localStorage.getItem('clientKey')
|
let clientKey = localStorage.getItem('clientKey')
|
||||||
if (!_.isString(clientKey) || clientKey.length !== 40) {
|
if (!_.isString(clientKey) || clientKey.length !== 40) {
|
||||||
clientKey = keygen()
|
clientKey = keygen(20)
|
||||||
setClientKey(clientKey)
|
setClientKey(clientKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
const electron = require('electron')
|
|
||||||
const shell = electron.shell
|
|
||||||
|
|
||||||
export default function (e) {
|
|
||||||
shell.openExternal(e.currentTarget.href)
|
|
||||||
e.preventDefault()
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
'use strict'
|
|
||||||
|
|
||||||
var _ = require('lodash')
|
|
||||||
|
|
||||||
const TEXT_FILTER = 'TEXT_FILTER'
|
|
||||||
const FOLDER_FILTER = 'FOLDER_FILTER'
|
|
||||||
const TAG_FILTER = 'TAG_FILTER'
|
|
||||||
|
|
||||||
export default function search (articles, search) {
|
|
||||||
let filters = search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^#$/)).map(key => {
|
|
||||||
if (key.match(/^in:.+$/)) {
|
|
||||||
return {type: FOLDER_FILTER, value: key.match(/^in:(.+)$/)[1]}
|
|
||||||
}
|
|
||||||
if (key.match(/^#(.+)/)) {
|
|
||||||
return {type: TAG_FILTER, value: key.match(/^#(.+)$/)[1]}
|
|
||||||
}
|
|
||||||
return {type: TEXT_FILTER, value: key}
|
|
||||||
})
|
|
||||||
// let folderFilters = filters.filter(filter => filter.type === FOLDER_FILTER)
|
|
||||||
let textFilters = filters.filter(filter => filter.type === TEXT_FILTER)
|
|
||||||
let tagFilters = filters.filter(filter => filter.type === TAG_FILTER)
|
|
||||||
|
|
||||||
if (textFilters.length > 0) {
|
|
||||||
articles = textFilters.reduce((articles, textFilter) => {
|
|
||||||
return articles.filter(article => {
|
|
||||||
return article.title.match(new RegExp(textFilter.value, 'i')) || article.content.match(new RegExp(textFilter.value, 'i'))
|
|
||||||
})
|
|
||||||
}, articles)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tagFilters.length > 0) {
|
|
||||||
articles = tagFilters.reduce((articles, tagFilter) => {
|
|
||||||
return articles.filter(article => {
|
|
||||||
return _.find(article.Tags, tag => tag.name.match(new RegExp(tagFilter.value, 'i')))
|
|
||||||
})
|
|
||||||
}, articles)
|
|
||||||
}
|
|
||||||
|
|
||||||
return articles
|
|
||||||
}
|
|
||||||
@@ -7,7 +7,6 @@ const defaultConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validate (config) {
|
function validate (config) {
|
||||||
console.log(config)
|
|
||||||
if (!_.isObject(config)) return false
|
if (!_.isObject(config)) return false
|
||||||
if (!_.isNumber(config.zoom) || config.zoom < 0) return false
|
if (!_.isNumber(config.zoom) || config.zoom < 0) return false
|
||||||
if (!_.isBoolean(config.isSideNavFolded)) return false
|
if (!_.isBoolean(config.isSideNavFolded)) return false
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import ReactDOM from 'react-dom'
|
import ReactDOM from 'react-dom'
|
||||||
import ExternalLink from 'browser/components/ExternalLink'
|
|
||||||
|
|
||||||
export default class ContactTab extends React.Component {
|
export default class ContactTab extends React.Component {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
@@ -13,7 +12,7 @@ export default class ContactTab extends React.Component {
|
|||||||
<div className='ContactTab content'>
|
<div className='ContactTab content'>
|
||||||
<div className='title'>Contact</div>
|
<div className='title'>Contact</div>
|
||||||
<p>
|
<p>
|
||||||
- Issues: <ExternalLink href='https://github.com/BoostIO/Boostnote/issues'>https://github.com/BoostIO/Boostnote/issues</ExternalLink>
|
- Issues: <a href='https://github.com/BoostIO/Boostnote/issues'>https://github.com/BoostIO/Boostnote/issues</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
<link rel="stylesheet" href="../node_modules/highlight.js/styles/xcode.css" id="hljs-css">
|
<link rel="stylesheet" href="../node_modules/highlight.js/styles/xcode.css" id="hljs-css">
|
||||||
<link rel="shortcut icon" href="../resources/favicon.ico">
|
<link rel="shortcut icon" href="../resources/favicon.ico">
|
||||||
<title>Boostnote</title>
|
<title>Boostnote</title>
|
||||||
<link rel="stylesheet" href="../resources/katex.min.css">
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@@ -65,13 +64,12 @@
|
|||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
electron.webFrame.setZoomLevelLimits(1, 1)
|
electron.webFrame.setZoomLevelLimits(1, 1)
|
||||||
var version = electron.remote.app.getVersion()
|
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
var scriptUrl = _.find(electron.remote.process.argv, a => a === '--hot')
|
var scriptUrl = _.find(electron.remote.process.argv, (a) => a === '--hot')
|
||||||
? 'http://localhost:8080/assets/main.js'
|
? 'http://localhost:8080/assets/main.js'
|
||||||
: '../compiled/main.js'
|
: '../compiled/main.js'
|
||||||
var scriptEl = document.createElement('script')
|
var scriptEl = document.createElement('script')
|
||||||
scriptEl.setAttribute("type","text/javascript")
|
scriptEl.setAttribute("type", "text/javascript")
|
||||||
scriptEl.setAttribute("src", scriptUrl)
|
scriptEl.setAttribute("src", scriptUrl)
|
||||||
document.body.appendChild(scriptEl)
|
document.body.appendChild(scriptEl)
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user