-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from webtide/add-blog
initial support for blog cards
- Loading branch information
Showing
13 changed files
with
182 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
|
||
const toHash = (object) => object && !object.$$is_hash ? Opal.hash2(Object.keys(object), object) : object | ||
|
||
const toProc = (fn) => Object.defineProperty(fn, '$$arity', { value: fn.length }) | ||
|
||
function register (registry, { file } = {}) { | ||
if (!registry) return this.register('feed', createExtensionGroup()) | ||
registry.$groups().$store('feed', toProc(createExtensionGroup(file))) | ||
return registry | ||
} | ||
|
||
function createExtensionGroup (file) { | ||
return function () { | ||
this.blockMacro('feed', function () { | ||
this.process((parent, target, attrs) => { | ||
if (file) file.asciidoc.attributes['page-has-feeds'] = '' | ||
let currentParent = parent | ||
let sect | ||
if ('title' in attrs) { | ||
const title = attrs.title | ||
delete attrs.title | ||
attrs.role = `${attrs.role || ''} card-section`.trimStart() | ||
currentParent.append((sect = this.$create_section(parent, title, toHash(attrs)))) | ||
currentParent = sect | ||
} | ||
const dataset = { feed: target } | ||
if ('max' in attrs) dataset.max = attrs.max | ||
const dataAttrlist = Object.entries(dataset).reduce((accum, [name, val]) => `${accum} data-${name}="${val}"`, '') | ||
const container = this.createPassBlock(currentParent, `<div class="card-entries"${dataAttrlist}></div>`, {}) | ||
if (!sect) return container | ||
sect.append(container) | ||
}) | ||
}) | ||
} | ||
} | ||
|
||
module.exports = { register, createExtensionGroup } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
= Home | ||
// page-has-feeds is automatically set by the feed block macro when used with Antora; must be set manually in the UI preview | ||
:page-has-feeds: | ||
|
||
== Blog Entries | ||
|
||
.Jetty Blogs | ||
feed::https://webtide.com/blog/feed/[id=jetty-feed,max=6] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
.card-entries { | ||
display: grid; | ||
/* grid-template-columns: repeat(auto-fill, 230px); */ | ||
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); | ||
grid-gap: 1rem; | ||
margin-top: 1rem; | ||
} | ||
|
||
.card-block { | ||
max-height: 15rem; | ||
height: 15rem; | ||
hyphens: initial; | ||
} | ||
|
||
.card-block .card-link { | ||
color: inherit; | ||
text-decoration: none; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-around; | ||
padding: 1.2rem; | ||
height: 100%; | ||
width: 100%; | ||
border: 1.5px solid var(--color-card-border); | ||
border-radius: 0.25em; | ||
position: relative; | ||
} | ||
|
||
.card-block .card-link::before { | ||
transition: all 0.2s, transform 0.2s; | ||
transform: translateY(0); | ||
position: relative; | ||
box-shadow: none; | ||
top: 0; | ||
} | ||
|
||
.card-block .card-link:hover { | ||
border: 2px solid var(--color-net-id); | ||
background-color: var(--color-net-id); | ||
color: var(--color-focused); | ||
transform: translateY(-3px); | ||
top: -3px; | ||
box-shadow: 0 10px 20px 0 var(--color-card-shadow); | ||
transition: all 0.3s ease-in-out; | ||
} | ||
|
||
.card-block .card-title { | ||
font-size: calc(20 / var(--rem-base) * 1rem); | ||
line-height: 1.4; | ||
text-align: center; | ||
overflow: hidden; | ||
font-weight: var(--body-font-weight-bold); | ||
} | ||
|
||
.card-block .card-content p { | ||
font-size: calc(16 / var(--rem-base) * 1rem); | ||
line-height: 1.3; | ||
} | ||
|
||
.card-block .overflow { | ||
--max-lines: 5; | ||
|
||
max-height: calc(1.4rem * var(--max-lines)); | ||
overflow: hidden; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
;(function () { | ||
'use strict' | ||
|
||
var feeds = [].slice.call(document.querySelectorAll('.doc [data-feed]')) | ||
if (!feeds.length) return | ||
|
||
var template = document.getElementById('card-entry') | ||
if (!(template && (template = template.content.querySelector('.card-block')))) return | ||
|
||
var XMLHttpRequest = window.XMLHttpRequest | ||
|
||
feeds.forEach(insertFeed) | ||
|
||
function insertFeed (feed) { | ||
try { | ||
var url = feed.dataset.feed | ||
var max = Number(feed.dataset.max) || Infinity | ||
var xhr = new XMLHttpRequest() | ||
xhr.open('GET', url) | ||
xhr.addEventListener('load', function () { | ||
var items = [].slice.call(this.responseXML.querySelectorAll('item'), 0, max) | ||
items.forEach(function (item) { | ||
var entry = template.cloneNode(true) | ||
entry.querySelector('.card-link').setAttribute('href', item.querySelector('link').textContent) | ||
entry.querySelector('.card-title').innerHTML = item.querySelector('title').innerHTML | ||
entry.querySelector('.card-content p').innerHTML = item.querySelector('description').textContent | ||
feed.appendChild(entry) | ||
}) | ||
}) | ||
} catch (e) { | ||
console.error('Failed to retrieve feed: ' + url + '.', e) | ||
} | ||
xhr.send(null) | ||
} | ||
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template id="card-entry" class="hidden"> | ||
<div class="card-block"> | ||
<a class="card-link"> | ||
<div class="card-title"></div> | ||
<div class="card-content overflow"> | ||
<p></p> | ||
</div> | ||
</a> | ||
</div> | ||
</template> | ||
<script src="{{{uiRootPath}}}/js/feeds.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters