git ssb

16+

Dominic / patchbay



Commit db909573b9d8f25be1fb33a819dee9ecdccbdaf6

replace mcss loader with a dedicated function

mix irving committed on 12/31/2016, 5:26:26 AM
Parent: 32f3b3b65f755773019450067162f65fffd00e6f

Files changed

modules_basic/about.jschanged
modules_basic/message-author.jschanged
modules_basic/message-backlinks.jschanged
modules_basic/message.jschanged
modules_basic/timestamp.jschanged
get-style-for-module.jsadded
modules_basic/about.jsView
@@ -1,8 +1,7 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var h = require('../h')
4-var when = require('@mmckegg/mutant/when')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
3 +const when = require('@mmckegg/mutant/when')
54
65 exports.needs = {
76 blob_url: 'first',
87 markdown: 'first'
@@ -17,9 +16,9 @@
1716 exports.create = function (api) {
1817 return {
1918 message_content,
2019 message_content_mini,
21- mcss: () => fs.readFileSync(Path.join(__dirname, 'about.mcss'), 'utf8')
20 + mcss: getStyleForModule(__filename)
2221 }
2322
2423 function message_content (msg) {
2524 if (msg.value.content.type !== 'about') return
modules_basic/message-author.jsView
@@ -1,8 +1,7 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var h = require('../h')
4-var when = require('@mmckegg/mutant/when')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
3 +const when = require('@mmckegg/mutant/when')
54
65 exports.needs = {
76 avatar_link: 'first',
87 avatar_image: 'first',
@@ -17,9 +16,9 @@
1716
1817 exports.create = function (api) {
1918 return {
2019 message_author,
21- mcss: () => fs.readFileSync(Path.join(__dirname, 'message-author.mcss'))
20 + mcss: getStyleForModule(__filename)
2221 }
2322
2423 function message_author (msg, opts = {}) {
2524 var { size = 'small' } = opts
modules_basic/message-backlinks.jsView
@@ -1,7 +1,6 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var h = require('../h')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
43
54 exports.gives = {
65 message_backlinks: true,
76 mcss: true
@@ -9,9 +8,9 @@
98
109 exports.create = function (api) {
1110 return {
1211 message_backlinks,
13- mcss: () => fs.readFileSync(Path.join(__dirname, 'message-backlinks.mcss'))
12 + mcss: getStyleForModule(__filename)
1413 }
1514
1615 function message_backlinks (msg) {
1716 var links = []
modules_basic/message.jsView
@@ -1,9 +1,8 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var pull = require('pull-stream')
4-var u = require('../util')
5-var h = require('../h')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const pull = require('pull-stream')
3 +const u = require('../util')
4 +const h = require('../h')
65
76 exports.needs = {
87 avatar_name: 'first',
98 avatar_link: 'first',
@@ -24,9 +23,9 @@
2423
2524 exports.create = function (api) {
2625 return {
2726 message_render,
28- mcss: () => fs.readFileSync(Path.join(__dirname, 'message.mcss'))
27 + mcss: getStyleForModule(__filename)
2928 }
3029
3130 function message_render (msg, sbot) {
3231 var content = api.message_content_mini(msg)
modules_basic/timestamp.jsView
@@ -1,8 +1,7 @@
1-var fs = require('fs')
2-var Path = require('path')
3-var h = require('../h')
4-var human = require('human-time')
1 +const getStyleForModule = require('../get-style-for-module')
2 +const h = require('../h')
3 +const human = require('human-time')
54
65 exports.needs = {}
76
87 exports.gives = {
@@ -17,9 +16,9 @@
1716 }, 60e3)
1817
1918 return {
2019 timestamp,
21- mcss: () => fs.readFileSync(Path.join(__dirname, 'timestamp.mcss'))
20 + mcss: getStyleForModule(__filename)
2221 }
2322
2423 function updateTimestampEl (el) {
2524 var timestamp = Number(el.getAttribute('data-timestamp'))
get-style-for-module.jsView
@@ -1,0 +1,8 @@
1 +const fs = require('fs')
2 +
3 +module.exports = (filename) => () => {
4 + const mcssPath = filename.replace(/js$/, 'mcss')
5 +
6 + return fs.readFileSync(mcssPath, 'utf8')
7 +}
8 +

Built with git-ssb-web