wiki-plugin-mech 0.1.20 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client/mech.js +34 -1
  2. package/package.json +1 -1
package/client/mech.js CHANGED
@@ -584,6 +584,37 @@
584
584
  }
585
585
  }
586
586
 
587
+ function roster_emit({elem,command,state}) {
588
+ if(!state.neighborhood) return trouble(elem,`ROSTER expected a neighborhood, like from NEIGHBORS.`)
589
+ inspect(elem,'neighborhood',state)
590
+ const infos = state.neighborhood
591
+ const sites = infos
592
+ .map(info => info.domain)
593
+ .filter(uniq)
594
+ const any = array => array[Math.floor(Math.random()*array.length)]
595
+ console.log(infos)
596
+ const items = [
597
+ {type:'roster', text:"Mech\n"+sites.join("\n")},
598
+ {type:'activity', text:`ROSTER Mech\nSINCE 30 days`}]
599
+ elem.innerHTML = command + ` ⇒ ${sites.length} sites`
600
+ state.items = items
601
+ }
602
+
603
+ function lineup_emit({elem,command,state}) {
604
+ const items = [...document.querySelectorAll('.page')]
605
+ .map(div => {
606
+ const $page = $(div)
607
+ const page = $page.data('data')
608
+ const site = $page.data('site') || location.host
609
+ const slug = $page.attr('id').split('_')[0]
610
+ const title = page.title || 'Empty'
611
+ const text = page.story[0]?.text||'empty'
612
+ return {type:'reference',site,slug,title,text}
613
+ })
614
+ elem.innerHTML = command + ` ⇒ ${items.length} pages`
615
+ state.items = items
616
+ }
617
+
587
618
 
588
619
  // C A T A L O G
589
620
 
@@ -608,7 +639,9 @@
608
639
  SLEEP: {emit:sleep_emit},
609
640
  TOGETHER:{emit:together_emit},
610
641
  GET: {emit:get_emit},
611
- DELTA: {emit:delta_emit}
642
+ DELTA: {emit:delta_emit},
643
+ ROSTER: {emit:roster_emit},
644
+ LINEUP: {emit:lineup_emit}
612
645
  }
613
646
 
614
647
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-plugin-mech",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "description": "Federated Wiki - Mechanism Scripting Plugin",
5
5
  "keywords": [
6
6
  "mech",