rule.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. ---
  2. layout: default
  3. # This is where most of the code for CommunityRule lives
  4. # Follow comments below in various sections for further explanation
  5. ---
  6. <style type="text/css">
  7. /* CLASSES */
  8. .editable { /* All editable fields */
  9. padding: 10px 10px 10px 10px;
  10. min-height: 1.5em;
  11. font-family: serif;
  12. border-bottom: 1px dashed gray;
  13. }
  14. .question {
  15. color: gray;
  16. }
  17. /* TOOLTIP
  18. https://www.w3schools.com/css/tryit.asp?filename=trycss_tooltip_right
  19. This could bear substantial improvement. */
  20. .button {
  21. position: relative;
  22. display: inline-block;
  23. float: right;
  24. border: 1px solid gray;
  25. color: gray;
  26. background-color: white;
  27. text-align: center;
  28. border-radius: 6px;
  29. padding: 0 5px 0 5px;
  30. }
  31. .button .tooltiptext {
  32. visibility: hidden;
  33. width: 250px;
  34. border: 1px solid black;
  35. background-color: white;
  36. text-align: center;
  37. border-radius: 6px;
  38. padding: 5px 0;
  39. /* Position the tooltip */
  40. position: absolute;
  41. z-index: 1;
  42. right: 100%;
  43. }
  44. .button:hover {
  45. background-color: lightgray;
  46. }
  47. .button:hover .tooltiptext {
  48. visibility: visible;
  49. }
  50. /* pushButton
  51. These are the major functional buttons*/
  52. .pushButton {
  53. border: 1px solid gray;
  54. color: gray;
  55. background-color: white;
  56. text-align: center;
  57. border-radius: 6px;
  58. padding: 5px;
  59. font-size: 1.2em;
  60. }
  61. .pushButton:hover {
  62. background-color: lightgray;
  63. }
  64. .plus { /* The maximize/minimize button */
  65. font-size: 1em;
  66. }
  67. .icons {
  68. /* icons are from https://github.com/tabler/tabler-icons */
  69. margin: 0 5px 0 0;
  70. }
  71. /* Various IDs */
  72. #rulebox {
  73. border: 1px solid lightgray;
  74. padding: 20px;
  75. margin: 20px 0 30px 0;
  76. }
  77. #rulebox h2 {
  78. font-family: serif;
  79. }
  80. #communityname {
  81. font-weight: bold;
  82. }
  83. #editToggle {
  84. float: right;
  85. clear: both;
  86. }
  87. #toggleDisplayMode {
  88. margin: 0 0 10px 0;
  89. display: none;
  90. }
  91. #publishRule {
  92. margin: 0 0 10px 0;
  93. }
  94. #structure {
  95. font-size: 1.3em;
  96. }
  97. #attribution {
  98. font-family: serif;
  99. font-size: .8em;
  100. text-align: right;
  101. }
  102. </style>
  103. <script>
  104. // Enter JavaScript-land!
  105. // First, some functions, followed by initialization commands
  106. // toggleVisible(id)
  107. // Toggles the visibility of a given element by given ID
  108. function toggleVisible(id) {
  109. var x = document.getElementById(id);
  110. if (x.style.display === "none") {
  111. x.style.display = "block";
  112. } else {
  113. x.style.display = "none";
  114. }
  115. }
  116. // classDisplayAll(className, value)
  117. // Assigns given display value to all elements with a given className
  118. function classDisplayAll(className, value) {
  119. var elements = document.getElementsByClassName(className);
  120. for (var i = 0; i < elements.length; i++) {
  121. elements[i].style.display = value;
  122. }
  123. }
  124. // toggleEditMode()
  125. // Toggles whether editable fields are editable or not
  126. // and removes editing tools.
  127. function toggleEditMode() {
  128. if (editMode === true) {
  129. editMode = false;
  130. classDisplayAll("section","block");
  131. classDisplayAll("button","none");
  132. classDisplayAll("question","none");
  133. var editableFields = document.getElementsByClassName("editable");
  134. for (var i = 0; i < editableFields.length; i++) {
  135. editableFields[i].contentEditable = "false";
  136. editableFields[i].style.borderStyle = "none";
  137. if (editableFields[i].innerHTML === "") {
  138. editableFields[i].style.display = "none";
  139. }
  140. }
  141. document.getElementById("editToggle").innerHTML = "Customize";
  142. } else {
  143. editMode = true;
  144. classDisplayAll("button","block");
  145. classDisplayAll("question","block");
  146. classDisplayAll("editable","block");
  147. classDisplayAll("section","none");
  148. var editableFields = document.getElementsByClassName("editable");
  149. for (var i = 0; i < editableFields.length; i++) {
  150. editableFields[i].style.borderStyle = "none none dashed none";
  151. editableFields[i].contentEditable = "true";
  152. }
  153. document.getElementById("editToggle").innerHTML = "Preview";
  154. }
  155. }
  156. // toggleDisplayMode()
  157. // toggles full displayMode, the Rule-only display for a published Rule
  158. // first, initialize variable:
  159. var displayMode = false;
  160. function toggleDisplayMode() {
  161. if (displayMode == false) {
  162. editMode = true;
  163. toggleEditMode(); // turns off editMode
  164. classDisplayAll("site-nav","none");
  165. classDisplayAll("post-header","none");
  166. classDisplayAll("site-footer","none");
  167. document.getElementById("attribution").style.display = "block";
  168. document.getElementById("toggleDisplayMode").style.display = "inline-block";
  169. document.getElementById("publishRule").style.display = "none";
  170. displayMode = true;
  171. } else {
  172. toggleEditMode() // turns on editMode
  173. classDisplayAll("site-nav","block");
  174. classDisplayAll("post-header","block");
  175. classDisplayAll("site-footer","block");
  176. document.getElementById("attribution").style.display = "none";
  177. document.getElementById("toggleDisplayMode").style.display = "none";
  178. document.getElementById("publishRule").style.display = "inline-block";
  179. displayMode = false;
  180. }
  181. }
  182. // textOutput()
  183. // Produces Markdown rendition of Rule
  184. function textOutput() {
  185. var filename = 'CommunityRule.txt';
  186. var content = '# CommunityRule: ' + document.getElementById('communityname').innerHTML + '\n\n';
  187. var elements = document.getElementsByClassName('output');
  188. for (var i = 1; i < elements.length; i++) {
  189. if (elements[i].innerHTML != '') {
  190. if (elements[i].classList.contains("subhead")) {
  191. content += '## ';
  192. }
  193. content += elements[i].innerHTML + '\n\n';
  194. }
  195. }
  196. content += document.getElementById('attributionMD').innerHTML;
  197. content = content.replace(/(<([^>]+)>)/ig,''); // strips stray tags
  198. // Starting here, see https://stackoverflow.com/a/33542499
  199. var blob = new Blob([content], {type: 'text/plain'});
  200. if(window.navigator.msSaveOrOpenBlob) {
  201. window.navigator.msSaveBlob(blob, filename);
  202. }
  203. else{
  204. var elem = window.document.createElement('a');
  205. elem.href = window.URL.createObjectURL(blob);
  206. elem.download = filename;
  207. document.body.appendChild(elem);
  208. elem.click();
  209. document.body.removeChild(elem);
  210. URL.revokeObjectURL();
  211. }
  212. var myFile = new Blob([fileContent], {type: 'text/plain'});
  213. window.URL = window.URL || window.webkitURL; document.getElementById('download').setAttribute('href',window.URL.createObjectURL(myFile));
  214. document.getElementById('download').setAttribute('download', fileName);
  215. }
  216. // BEGIN Publish tools, via SteinHQ.com
  217. // publishRule()
  218. // Publishes existing fields to new page, /create/?rule=[ruleID]
  219. // Opens new page in Display mode
  220. function publishRule() {
  221. var time = new Date();
  222. var timestamp = time.getTime();
  223. // TKTK: Check if ruleID exists; while yes, replace and repeat
  224. var rule = [{
  225. ruleID: timestamp,
  226. timestamp: time.toISOString(),
  227. }];
  228. var fields = document.getElementsByClassName("editable");
  229. for (var i = 0; i < fields.length; i++) {
  230. var key = fields[i].id;
  231. var value = fields[i].innerHTML.replace(/(<([^>]+)>)/ig,"");
  232. rule[0][key] = value;
  233. }
  234. const store = new SteinStore(
  235. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  236. );
  237. store.append("rules", rule).then(data => {
  238. window.open("/create/?r=" + timestamp, "_self", false);
  239. });
  240. }
  241. // displayRule(ID)
  242. // Displays content based on ID
  243. function displayRule(ID) {
  244. const store = new SteinStore(
  245. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  246. );
  247. store.read("rules", { search: { ruleID: ID } }).then(data => {
  248. // only runs when we have the data from Goog:
  249. var rule = data[0];
  250. var fields = document.getElementsByClassName("editable");
  251. for (var i = 0; i < fields.length; i++) {
  252. var key = fields[i].id;
  253. var value = rule[key];
  254. if (typeof value === "undefined") {
  255. value = "";
  256. }
  257. document.getElementById(key).innerHTML = value;
  258. }
  259. displayMode = false;
  260. toggleDisplayMode();
  261. document.title = rule['communityname'] + " / CommunityRule";
  262. });
  263. }
  264. // END Publish tools
  265. // FINALLY, Page loading
  266. // First, grab the current URL
  267. var urlParams = new URLSearchParams(window.location.search);
  268. // Determine if it is a published Rule
  269. if (urlParams.has('r')) {
  270. // If so, grab the Rule from database and enter displayMode
  271. var rID = urlParams.get('r');
  272. displayRule(rID);
  273. } else {
  274. // Otherwise, open in editMode as default
  275. var editMode = true;
  276. // switch out of editMode in special cases
  277. window.onload = function() {
  278. if ((window.location.href.indexOf("/templates/") != -1) ||
  279. (window.location.href.indexOf("/about/") != -1)) {
  280. toggleEditMode();
  281. }
  282. }
  283. }
  284. </script>
  285. <article class="post">
  286. <header class="post-header">
  287. <h1 class="post-title" id="title">
  288. {{ page.title }}
  289. </h1>
  290. <button class="pushButton" id="editToggle" onclick="toggleEditMode()">
  291. Preview</button>
  292. <div class="post-content">
  293. {{ content }}
  294. </div>
  295. </header>
  296. <div id="rulebox">
  297. <span class="question">What is the community’s name?</span>
  298. <h1 contenteditable="true" class="editable output" id="communityname">{{ page.community-name }}</h1>
  299. <h2 id="basics">
  300. <img src="{% link assets/tabler_icons/info-circle.svg %}"
  301. class="icons" />
  302. <span class="subhead output">Basics</span>
  303. <button onclick="toggleVisible('s1')" class="button plus"> + </button>
  304. </h2>
  305. <div class="section" id="s1" style="display:none">
  306. <span class="question">What is the basic structure of the community?</span>
  307. <div class="button">Modules
  308. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/federation/">federation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/friendship/">friendship</a>, <a target="_blank" href="https://democraticmediums.info/mediums/membership/">membership</a>, <a target="_blank" href="https://democraticmediums.info/mediums/multicameralism/">multicameralism</a>, <a target="_blank" href="https://democraticmediums.info/mediums/ritual/">ritual</a>, <a target="_blank" href="https://democraticmediums.info/mediums/separation_of_powers/">separation of powers</a>, <a target="_blank" href="https://democraticmediums.info/mediums/stake_weight/">stake weight</a></span>
  309. </div>
  310. <p contenteditable="true" class="editable output" id="structure">{{ page.structure }}</p>
  311. <span class="question">What is the community’s mission?</span>
  312. <p contenteditable="true" class="editable output" id="mission">{{ page.mission }}</p>
  313. <span class="question">What core values does it hold?</span>
  314. <div class="button">Modules
  315. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/secrecy/">secrecy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/solidarity/">solidarity</a>, <a target="_blank" href="https://democraticmediums.info/mediums/transparency/">transparency</a></span>
  316. </div>
  317. <p contenteditable="true" class="editable output" id="values">{{ page.values }}</p>
  318. <span class="question">What are the basic rights that this Rule guarantees?</span>
  319. <p contenteditable="true" class="editable output" id="rights">{{ page.rights }}</p>
  320. </div><!--hiding section s1-->
  321. <h2 id="participants">
  322. <img src="{% link assets/tabler_icons/user.svg %}"
  323. class="icons" />
  324. <span class="subhead output">Participants</span>
  325. <button onclick="toggleVisible('s2')" class="button plus"> + </button>
  326. </h2>
  327. <div class="section" id="s2" style="display:none">
  328. <span class="question">How does someone become a member?</span>
  329. <div class="button">Modules
  330. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/do-ocracy/">do-ocracy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/friendship/">friendship</a>, <a target="_blank" href="https://democraticmediums.info/mediums/membership/">membership</a>, <a target="_blank" href="https://democraticmediums.info/mediums/reputation/">reputation</a></span>
  331. </div>
  332. <p contenteditable="true" class="editable output" id="membership">{{ page.membership }}</p>
  333. <span class="question">How are members suspended or removed?</span>
  334. <div class="button">Modules
  335. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/exclusion/">exclusion</a>, <a target="_blank" href="https://democraticmediums.info/mediums/friendship/">friendship</a>, <a target="_blank" href="https://democraticmediums.info/mediums/reputation/">reputation</a></span>
  336. </div>
  337. <p contenteditable="true" class="editable output" id="removal">{{ page.removal }}</p>
  338. </div><!--hiding section s2-->
  339. <h2 id="policies">
  340. <img src="{% link assets/tabler_icons/news.svg %}"
  341. class="icons" />
  342. <span class="subhead output">Policies</span>
  343. <button onclick="toggleVisible('s3')" class="button plus"> + </button>
  344. </h2>
  345. <div class="section" id="s3" style="display:none">
  346. <span class="question">Who has the capacity to decide on policies, and how do they do so?</span>
  347. <div class="button">Modules
  348. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/disapproval_voting/">disapproval voting</a>, <a target="_blank" href="https://democraticmediums.info/mediums/do-ocracy/">do-ocracy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/holographic_consensus/">holographic consensus</a>, <a target="_blank" href="https://democraticmediums.info/mediums/referendum/">referendum</a>, <a target="_blank" href="https://democraticmediums.info/mediums/representation/">representation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/sortition/">sortition</a></span>
  349. </div>
  350. <p contenteditable="true" class="editable output" id="decision">{{ page.decision }}</p>
  351. <span class="question">Where do community members deliberate about potential policies?</span>
  352. <div class="button">Modules
  353. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/caucus/">caucus</a>, <a target="_blank" href="https://democraticmediums.info/mediums/coalition/">coalition</a>, <a target="_blank" href="https://democraticmediums.info/mediums/board/">board</a>, <a target="_blank" href="https://democraticmediums.info/mediums/debate/">debate</a>, <a target="_blank" href="https://democraticmediums.info/mediums/lobbying/">lobbying</a>, <a target="_blank" href="https://democraticmediums.info/mediums/recess/">recess</a>, <a target="_blank" href="https://democraticmediums.info/mediums/secrecy/">secrecy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/transparency/">transparency</a></span>
  354. </div>
  355. <p contenteditable="true" class="editable output" id="deliberation">{{ page.deliberation }}</p>
  356. <span class="question">How are policies implemented?</span>
  357. <div class="button">Modules
  358. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/exclusion/">exclusion</a>, <a target="_blank" href="https://democraticmediums.info/mediums/lazy_consensus/">lazy consensus</a>, <a target="_blank" href="https://democraticmediums.info/mediums/restorative_justice/">restorative justice</a></span>
  359. </div>
  360. <p contenteditable="true" class="editable output" id="implementation">{{ page.implementation }}</p>
  361. <span class="question">Who oversees the implementation of policies?</span>
  362. <div class="button">Modules
  363. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/board/">board</a>, <a target="_blank" href="https://democraticmediums.info/mediums/disapproval_voting/">disapproval voting</a>, <a target="_blank" href="https://democraticmediums.info/mediums/judiciary/">jury</a>, <a target="_blank" href="https://democraticmediums.info/mediums/precedent/">precedent</a>, <a target="_blank" href="https://democraticmediums.info/mediums/refusal/">refusal</a>, <a target="_blank" href="https://democraticmediums.info/mediums/rough_consensus/">rough consensus</a></span>
  364. </div>
  365. <p contenteditable="true" class="editable output" id="oversight">{{ page.oversight }}</p>
  366. <span class="question">What limits are there on member roles and policies?</span>
  367. <div class="button">Modules
  368. <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/fact_finding/">fact-finding</a>, <a target="_blank" href="https://democraticmediums.info/mediums/ranked_choice/">ranked choice</a>, <a target="_blank" href="https://democraticmediums.info/mediums/representation/">representation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/reputation/">reputation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/sortition/">sortition</a>, <a target="_blank" href="https://democraticmediums.info/mediums/term_limit/">term limits</a></span>
  369. </div>
  370. <p contenteditable="true" class="editable output" id="limits">{{ page.limits }}</p>
  371. </div><!--hiding section s3-->
  372. <h2 id="evolution">
  373. <img src="{% link assets/tabler_icons/adjustments.svg %}"
  374. class="icons" />
  375. <span class="subhead output">Evolution</span>
  376. <button onclick="toggleVisible('s4')" class="button plus"> + </button>
  377. </h2>
  378. <div class="section" id="s4" style="display:none">
  379. <span class="question">Where do we maintain our policies and records?</span>
  380. <p contenteditable="true" class="editable output" id="records">{{ page.records }}</p>
  381. <span class="question">How can this Rule be modified?</span>
  382. <p contenteditable="true" class="editable output" id="modification">{{ page.modification }}</p>
  383. </div><!--hiding section s4-->
  384. <div id="attribution" style="display:none;">
  385. <br />
  386. <p><a href="http://communityrule.info">
  387. <img src="https://img.shields.io/badge/CommunityRule-derived-000000" alt="CommunityRule derived"></a></p>
  388. <p>Created with <a href="http://communityrule.info">CommunityRule</a><br />
  389. <a href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons BY-SA</a></p>
  390. <p><strong>The Publish feature is experimental. Rules may be removed without notice</strong></p>
  391. </div>
  392. <div id="attributionMD" style="display:none;">
  393. ---
  394. [![CommunityRule derived]({% link assets/CommunityRule-derived-000000.svg %})](http://communityrule.info)
  395. Created with [CommunityRule](http://communityrule.info)
  396. [Creative Commons BY-SA](http://creativecommons.org/licenses/by-sa/4.0/).
  397. </div>
  398. </div><!--#rulebox-->
  399. <button class="pushButton" id="publishRule" onclick="publishRule()">Publish</button>
  400. <button class="pushButton" id="toggleDisplayMode" onclick="toggleDisplayMode()">Fork</button>
  401. <button class="pushButton" onclick="textOutput()">Markdown</button>
  402. </article>