Permalink
Browse files

standardize!

  • Loading branch information...
mmckegg committed Oct 26, 2017
1 parent b68094a commit b7084484d5f38609520442861cc067351128dfa4
View
@@ -19,7 +19,6 @@ var windows = {
var ssbConfig = null
var quitting = false
electron.app.on('ready', () => {
setupContext('ssb', {
server: !(process.argv.includes('-g') || process.argv.includes('--use-global-ssb'))
@@ -81,7 +80,7 @@ function openMainWindow () {
height: windowState.height,
titleBarStyle: 'hidden-inset',
autoHideMenuBar: true,
title: "Patchwork",
title: 'Patchwork',
show: true,
backgroundColor: '#EEE',
webPreferences: {
View
@@ -39,17 +39,6 @@ function nextStepper (createStream, opts, range) {
})
}
function get (obj, path) {
if (!obj) return undefined
if (typeof path === 'string') return obj[path]
if (Array.isArray(path)) {
for (var i = 0; obj && i < path.length; i++) {
obj = obj[path[i]]
}
return obj
}
}
function clone (obj) {
var _obj = {}
for (var k in obj) _obj[k] = obj[k]
View
@@ -19,7 +19,7 @@ module.exports = function Window (config, path, opts) {
var config = ${JSON.stringify(config)}
var data = ${JSON.stringify(opts.data)}
var title = ${JSON.stringify(opts.title || "Patchwork" )}
var title = ${JSON.stringify(opts.title || 'Patchwork')}
document.documentElement.querySelector('head').appendChild(
h('title', title)
View
@@ -93,8 +93,8 @@ module.exports = function (config) {
})
]),
h('span.nav', [
tab(i18n("Public"), '/public'),
tab(i18n("Private"), '/private'),
tab(i18n('Public'), '/public'),
tab(i18n('Private'), '/private'),
dropTab(i18n('More'), [
getSubscribedChannelMenu,
[i18n('Gatherings'), '/gatherings'],
@@ -104,7 +104,7 @@ module.exports = function (config) {
])
]),
h('span.appTitle', [
h('span.title', i18n("Patchwork")),
h('span.title', i18n('Patchwork')),
api.app.html.progressNotifier()
]),
h('span', [ api.app.html.search(api.app.navigate) ]),
@@ -13,7 +13,7 @@ exports.needs = nest({
replicate: 'first',
migration: 'first'
},
'intl.sync.i18n':'first'
'intl.sync.i18n': 'first'
})
exports.create = function (api) {
@@ -2,8 +2,6 @@ var h = require('mutant/h')
var nest = require('depnest')
var addSuggest = require('suggest-box')
var appRoot = require('app-root-path');
exports.needs = nest({
'profile.async.suggest': 'first',
'channel.async.suggest': 'first',
@@ -52,7 +50,7 @@ exports.create = function (api) {
var value = searchBox.value.trim()
if (value.startsWith('/') || value.startsWith('?') || value.startsWith('@') || value.startsWith('#') || value.startsWith('%')) {
if (value.startsWith('@') && value.length < 30) {
return // probably not a key
// probably not a key
} else if (value.length > 2) {
setView(value)
}
@@ -26,15 +26,16 @@ exports.create = (api) => {
})
}
function portInUse (port, callback) {
function portInUse (port, cb) {
/* eslint-disable standard/no-callback-literal */
// super hacky check!
var server = net.createServer(function (socket) {})
server.listen(port, '127.0.0.1')
server.on('error', function (e) {
callback(true)
cb(true)
})
server.on('listening', function (e) {
server.close()
callback(false)
cb(false)
})
}
View
@@ -31,7 +31,7 @@ exports.create = function (api) {
var canGoForward = Value(false)
var canGoBack = Value(false)
var currentView = Value(defaultViews && defaultViews[0] || null)
var currentView = Value((defaultViews && defaultViews[0]) || null)
var viewCollection = dictToCollection(views)
var html = h('div.main', map(viewCollection, (item) => {
@@ -273,7 +273,7 @@ function many (ids, fn, intl) {
fn(featuredIds[0]), ', ',
fn(featuredIds[1]), ', ',
fn(featuredIds[2]), intl(' and '),
ids.length - 3, intl(' others'),
ids.length - 3, intl(' others')
]
} else if (ids.length === 4) {
return [
@@ -14,7 +14,7 @@ exports.needs = nest({
'about.obs.latestValue': 'first',
'blob.html.input': 'first',
'blob.sync.url': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.create = function (api) {
View
@@ -5,7 +5,7 @@ var electron = require('electron')
exports.needs = nest({
'sheet.display': 'first',
'invite.async.accept': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest('invite.sheet')
@@ -6,7 +6,7 @@ exports.needs = nest({
'message.html.render': 'first',
'sbot.async.publish': 'first',
'keys.sync.id': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest('message.async.publish')
@@ -9,7 +9,7 @@ exports.needs = nest({
author: 'first'
},
'profile.html.person': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest('message.html.backlinks')
@@ -16,7 +16,7 @@ exports.needs = nest({
'message.async.publish': 'first',
'emoji.sync.names': 'first',
'emoji.sync.url': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest('message.html.compose')
@@ -66,7 +66,7 @@ exports.create = function (api) {
var fileInput = api.blob.html.input(file => {
const megabytes = file.size / 1024 / 1024
if (megabytes >= 5) {
const rounded = Math.floor(megabytes*100)/100
const rounded = Math.floor(megabytes * 100) / 100
warningMessage.set([
h('i.fa.fa-exclamation-triangle'),
h('strong', file.name),
@@ -6,7 +6,7 @@ exports.needs = nest({
'message.html.compose': 'first',
'message.async.publish': 'first',
'feed.html.rollup': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest({
@@ -9,7 +9,7 @@ exports.needs = nest({
'sbot.pull.log': 'first',
'message.async.publish': 'first',
'keys.sync.id': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest('page.html.render')
@@ -13,45 +13,44 @@ exports.needs = nest({
exports.gives = nest('page.html.render')
exports.create = function(api){
exports.create = function (api) {
const i18n = api.intl.sync.i18n
return nest('page.html.render', function page(path){
return nest('page.html.render', function page (path) {
if (path !== '/channels') return
var id = api.keys.sync.id()
var channels = api.channel.obs.recent()
var subscribedChannels = api.channel.obs.subscribed(id)
var loading = computed(subscribedChannels.sync, x => !x)
return h('div', { classList: 'Scroller'}, [
when(loading, [ h('Loading') ]),
h('div', {
classList: 'AllChannels',
hidden: loading
}, [
map(channels, (channel) => {
var subscribed = subscribedChannels.has(channel)
return h('a.channel', {
href: `#${channel}`,
classList: [
when(subscribed, '-subscribed')
]
}, [
h('span.name', '#' + channel),
when(subscribed,
return h('div', { classList: 'Scroller' }, [
when(loading, [ h('Loading') ]),
h('div', {
classList: 'AllChannels',
hidden: loading
}, [
map(channels, (channel) => {
var subscribed = subscribedChannels.has(channel)
return h('a.channel', {
href: `#${channel}`,
classList: [
when(subscribed, '-subscribed')
]
}, [
h('span.name', '#' + channel),
when(subscribed,
h('a.-unsubscribe', {
'ev-click': send(unsubscribe, channel)
}, i18n('Unsubscribe')),
h('a.-subscribe', {
'ev-click': send(subscribe, channel)
}, i18n('Subscribe'))
)
])
}, {maxTime: 5, idle: true})
])
])
}, {maxTime: 5, idle: true})
])
])
function subscribe (id) {
api.message.async.publish({
type: 'channel',
@@ -9,7 +9,7 @@ exports.needs = nest({
'keys.sync.id': 'first',
'contact.obs.following': 'first',
'sbot.pull.stream': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest('page.html.render')
@@ -1,4 +1,3 @@
var { h, when } = require('mutant')
var nest = require('depnest')
exports.needs = nest({
@@ -30,7 +30,7 @@ exports.needs = nest({
},
'keys.sync.id': 'first',
'settings.obs.get': 'first',
'intl.sync.i18n': 'first',
'intl.sync.i18n': 'first'
})
exports.gives = nest({
@@ -138,8 +138,8 @@ exports.create = function (api) {
h('button -pub -full', {
'ev-click': api.invite.sheet
}, i18n('+ Join Pub')),
when(loading, [ h("Loading") ], [
when(computed(channels, x => x.length), h('h2', i18n("Active Channels"))),
when(loading, [ h('Loading') ], [
when(computed(channels, x => x.length), h('h2', i18n('Active Channels'))),
h('div', {
classList: 'ChannelList',
hidden: loading
View
@@ -1,6 +1,6 @@
var nest = require('depnest')
var pull = require('pull-stream')
var {Struct, Dict, Value, computed, watch, onceTrue} = require('mutant')
var {Struct, Dict, Value, computed, watch} = require('mutant')
exports.gives = nest({
'progress.obs': [
@@ -20,12 +20,6 @@ exports.create = function (api) {
var syncStatus = null
var progress = null
setInterval(() => {
onceTrue(api.sbot.obs.connection(), sbot => {
sbot.progress
})
}, 1000)
return nest({
'progress.obs': {
replicate () {
@@ -31,7 +31,7 @@ exports.create = function (api) {
value.set(TimeIntl(timestamp))
}
function TimeIntl(timestamp) {
function TimeIntl (timestamp) {
return api.intl.sync.time(Time(timestamp))
}
}
@@ -1,6 +1,4 @@
var h = require('mutant/h')
var nest = require('depnest')
var extend = require('xtend')
exports.needs = nest({
'message.html': {
View
@@ -6,7 +6,7 @@
"description": "A decentralized messaging and sharing app built on top of Secure Scuttlebutt (SSB).",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "standard",
"start": "electron index.js",
"postinstall": "npm run rebuild",
"rebuild": "cross-script npm rebuild --runtime=electron \"--target=$(electron -v)\" \"--abi=$(electron --abi)\" --disturl=https://atom.io/download/atom-shell"
@@ -3,7 +3,7 @@
var nest = require('depnest')
var pull = require('pull-stream')
var { Value, Dict, Struct, computed, resolve, throttle } = require('mutant')
var { Value, Dict, Struct, computed, throttle } = require('mutant')
exports.needs = nest({
'sbot.pull.stream': 'first'
Oops, something went wrong.

0 comments on commit b708448

Please sign in to comment.