mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-04 12:22:47 +00:00 
			
		
		
		
	Simplify News aggregation
This commit is contained in:
		@@ -196,30 +196,35 @@
 | 
				
			|||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  function mastodonStatusToHtml(status) {
 | 
					  function mastodonStatusToElement(status) {
 | 
				
			||||||
    let date = new Date(status.created_at).toLocaleString('en-US')
 | 
					    let date = new Date(status.created_at).toLocaleString('en-US');
 | 
				
			||||||
    return htmlString = `
 | 
					    let newsElement = Utils.HTMLToElement(
 | 
				
			||||||
      <div class="row">
 | 
					      `
 | 
				
			||||||
        <div class="col s11">
 | 
					        <div class="row">
 | 
				
			||||||
          <div class="card white-text" style="background-color:#5D50E7; border-radius:10px;">
 | 
					          <div class="col s11">
 | 
				
			||||||
            <div class="card-content">
 | 
					            <div class="card white-text" style="background-color:#5D50E7; border-radius:10px;">
 | 
				
			||||||
              <span class="card-title">New Actitvity on Mastodon</span>
 | 
					              <div class="card-content">
 | 
				
			||||||
              <p><i>Published on ${date}</i></p>
 | 
					                <span class="card-title">New Actitvity on Mastodon</span>
 | 
				
			||||||
              <br>
 | 
					                <p><i>Published on ${date}</i></p>
 | 
				
			||||||
              <p>${status.content}</p>
 | 
					                <br>
 | 
				
			||||||
 | 
					                <p>${status.content}</p>
 | 
				
			||||||
 | 
					              </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
 | 
					          <div class="col s1">
 | 
				
			||||||
 | 
					            <img src="https://joinmastodon.org/logos/logo-purple.svg" alt="Mastodon" class="responsive-img hide-on-small-only" style="width:70%; margin-top:30px;">
 | 
				
			||||||
 | 
					          </div>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="col s1">
 | 
					      `
 | 
				
			||||||
          <img src="https://joinmastodon.org/logos/logo-purple.svg" alt="Mastodon" class="responsive-img hide-on-small-only" style="width:70%; margin-top:30px;">
 | 
					    );
 | 
				
			||||||
        </div>
 | 
					    return newsElement;
 | 
				
			||||||
    `.trim();
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  function bisBlogsEntryToHtml(entry) {
 | 
					
 | 
				
			||||||
    let date = new Date(entry.published).toLocaleString('en-US')
 | 
					  function bisBlogsEntryToElement(entry) {
 | 
				
			||||||
    let bisBlogHTMLElement = document.createElement('div');
 | 
					    let date = new Date(entry.published).toLocaleString('en-US');
 | 
				
			||||||
    bisBlogHTMLElement.classList.add('row');
 | 
					    let newsElement = Utils.HTMLToElement(
 | 
				
			||||||
    bisBlogHTMLElement.innerHTML = `
 | 
					      `
 | 
				
			||||||
 | 
					        <div class="row">
 | 
				
			||||||
          <div class="col s1">
 | 
					          <div class="col s1">
 | 
				
			||||||
            <img src="https://blogs.uni-bielefeld.de/blog/uniintern/resource/themabilder/unilogo-square.svg" alt="Bielefeld University Blogs" class="responsive-img hide-on-small-only" style="width:70%; margin-top:40px;">
 | 
					            <img src="https://blogs.uni-bielefeld.de/blog/uniintern/resource/themabilder/unilogo-square.svg" alt="Bielefeld University Blogs" class="responsive-img hide-on-small-only" style="width:70%; margin-top:40px;">
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
@@ -233,30 +238,31 @@
 | 
				
			|||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
      `.trim();
 | 
					        </div>
 | 
				
			||||||
    let bisBlogImages = bisBlogHTMLElement.querySelectorAll('img');
 | 
					      `
 | 
				
			||||||
    bisBlogImages.forEach((img) => {
 | 
					    );
 | 
				
			||||||
      img.classList.add('responsive-img');
 | 
					    let newsImageElements = newsElement.querySelectorAll('img');
 | 
				
			||||||
    });
 | 
					    for (let newsImageElement of newsImageElements) {
 | 
				
			||||||
    return bisBlogHTMLElement.outerHTML;
 | 
					      newsImageElement.classList.add('responsive-img');
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return newsElement;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let aggregatedNewsElement = document.querySelector('#aggregated-news');
 | 
					  let aggregatedNewsElement = document.querySelector('#aggregated-news');
 | 
				
			||||||
  aggregateNews().then((aggregatedNews) => {
 | 
					  aggregateNews().then((aggregatedNews) => {
 | 
				
			||||||
    for (let item of aggregatedNews) {
 | 
					    for (let item of aggregatedNews) {
 | 
				
			||||||
      let itemHtmlString;
 | 
					      let newsElement;
 | 
				
			||||||
      switch (item.source) {
 | 
					      switch (item.source) {
 | 
				
			||||||
        case 'mastodon':
 | 
					        case 'mastodon':
 | 
				
			||||||
          console.log(item);
 | 
					          newsElement = mastodonStatusToElement(item);
 | 
				
			||||||
          itemHtmlString = mastodonStatusToHtml(item);
 | 
					 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        case 'big-blogs':
 | 
					        case 'big-blogs':
 | 
				
			||||||
          itemHtmlString = bisBlogsEntryToHtml(item);
 | 
					          newsElement = bisBlogsEntryToElement(item);
 | 
				
			||||||
          break;
 | 
					          break;
 | 
				
			||||||
        default:
 | 
					        default:
 | 
				
			||||||
          throw new Error('Unknown source');
 | 
					          throw new Error('Unknown source');
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      aggregatedNewsElement.insertAdjacentHTML('beforeend', itemHtmlString);
 | 
					      aggregatedNewsElement.appendChild(newsElement);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
</script>
 | 
					</script>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user