Changes for page Nice Display
Last modified by Benjamin Fischer on 2025/03/26 13:19
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -11,7 +11,6 @@ 11 11 'URL': {"type": "hidden"}, 12 12 "content": {"type": "hidden"}, 13 13 "tags": {"sortable": false, "filterable": false, "html": true, "headerClass": "tagsCol"}, 14 - "doc.date": {"filterable": false, "displayName": "Last Updated"}, 15 15 '_actions': {"actions":["view","edit"]} 16 16 }) 17 17 #set ($options = { ... ... @@ -20,9 +20,9 @@ 20 20 'tagCloud': true, 21 21 'rowCount': 15, 22 22 'maxPages': 10, 23 - 'selectedColumn': ' doc.date',22 + 'selectedColumn': 'affiliation', 24 24 'defaultOrder': 'asc' 25 25 }) 26 -#set ($columns = ['affiliation', 'URL', "content", "tags", "tags", "tags", "doc.date",'_actions'])27 -#livetable('research _groups' $columns $columnsProperties $options)25 +#set ($columns = ['affiliation', 'URL', "content", "tags", "tags", "tags", '_actions']) 26 +#livetable('research groups' $columns $columnsProperties $options) 28 28 {{/velocity}}
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,12 +1,12 @@ 1 -const tabName = "research _groups";1 +const tabName = "research groups"; 2 2 const tagCols = [ 3 - ["Community", "KAT", "KET", "KfB", "KFN", "KFS", "KFSI", "KHuK", "RDS", "beyond ErUM"] ,4 - ["Experiment", "CMS", "ATLAS", "Belle2", "CTA", "Auger" , "SKA", "IceCube"],3 + ["Community", "KAT", "KET", "KfB", "KFN", "KFS", "KFSI", "KHuK", "RDS", "beyond ErUM"] 4 + ["Experiment", "CMS", "ATLAS", "Belle2", "CTA", "Auger"], 5 5 ["Tags", true], 6 6 ] 7 7 8 8 document.observe('xwiki:livetable:loading', () => { 9 - const mats = document.getElementById(ta bName);9 + const mats = document.getElementById(tagName); 10 10 11 11 // coulmn data sources 12 12 const conf = JSON.parse(mats.dataset.settings); ... ... @@ -28,7 +28,7 @@ 28 28 ); 29 29 30 30 // handle clicks for tags 31 - document.getElementById(`${ta bName}-display`).addEventListener("click", ev => {31 + document.getElementById(`${tagName}-display`).addEventListener("click", ev => { 32 32 if (ev.button) return; // only left click 33 33 if (ev.target.nodeName !== "SPAN") return; 34 34 if (!ev.target.classList.contains("ltTag")) return; ... ... @@ -44,20 +44,36 @@ 44 44 }) 45 45 }); 46 46 47 -document.observe(`xwiki:livetable:${tabName}:receivedEntries`, ({memo: {data}}) => { 47 +document.observe(`xwiki:livetable:${tagName}:receivedEntries`, ({memo: {data}}) => { 48 + debugger; 49 + return; 48 48 for (const row of data.rows) { 49 - const a = new Element("a", { href: row.URL }); 50 - a.innerHTML = row.affiliation_value.split("\n").map((a, i) => i ? a : `<b class="wikiexternallink">${a}</b>`).join("<br/>"); 51 - a.title = row.doc_title; 52 - if (row.content !== "-") { 53 - a.dataset.content = row.content; 54 - a.dataset.toggle = "popover"; 55 - } 51 + const ol = new DOMParser().parseFromString(row.doc_location, "text/xml").documentElement; 52 + const li = ol.children; 56 56 57 - row.affiliation = a.outerHTML; 54 + li[0].remove(); // remove "Event" 55 + for (let i = 1; i < li.length - 1; i++) // intermediate 56 + li[i].textContent = li[i].textContent; // remove link 58 58 59 - row.doc_date = row.doc_date.replace("/", "-"); 58 + const a = li[li.length - 1].children[0]; 59 + const u = new URL(row.link_value); 60 + let icon; 61 + if (u.hostname.includes("github")) icon = "github"; 62 + if (u.hostname.includes("gitlab")) icon = "gitlab"; 63 + if (u.hostname.includes("google")) icon = "google"; 64 + if (u.pathname.endsWith(".pdf")) icon = "file-pdf-o"; 65 + if (icon) { 66 + const s = a.ownerDocument.createElement("span"); 67 + s.textContent = " "; 68 + s.setAttribute("class", `fa fa-${icon}`); 69 + s.setAttribute("style", "padding-right: .3em;"); 70 + a.insertBefore(s, a.firstChild); 71 + } 72 + a.setAttribute("class", "wikiexternallink"); 73 + a.setAttribute("href", u.href); 60 60 75 + row.doc_location = ol.outerHTML; 76 + 61 61 // tags 62 62 const tags = new Set(row.tags_value.slice(1, -1).split(", ")); 63 63 tagCols.forEach(([name, ...want], i) => ... ... @@ -70,20 +70,5 @@ 70 70 } 71 71 }); 72 72 73 -require(['jquery', 'bootstrap'], function($) { 74 - document.styleSheets[0].insertRule(`#mainContentArea .popover {max-width: 50%;}`) 75 75 76 - const ttApply = () => { 77 - $(`#${tabName} [data-toggle="popover"]`).popover({ 78 - html: true, 79 - container: `#mainContentArea`, 80 - trigger: "hover", 81 - }); 82 - }; 83 83 84 - document.observe(`xwiki:livetable:${tabName}:displayComplete`, ttApply); 85 - ttApply(); 86 -}); 87 - 88 - 89 -