make CWs work

This commit is contained in:
fenwick67 2018-09-29 17:29:17 -05:00
parent 4409c90979
commit 25dfe192d6
6 changed files with 115 additions and 12 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
node_modules
node_modules
*.atom

View file

@ -173,14 +173,17 @@ function buildUp(jsonObj,opts){
item.isReply = true;
}
if(item.categories){
item.hasCw = item.categories.indexOf('nsfw') > -1;
if(item.hasCw){
item.cw = item.summary;
}
if(item.summary){
item.hasCw = true;
item.cw = item.summary;
}
if(item['activity:object'] && item['activity:object'].summary && item['activity:object'].summary['#']){
item.hasCw = true;
item.cw = item['activity:object'].summary['#'];
}
// get a pagination ID for an entry
item.paginationId = false;
if (item['atom:link']){
@ -198,6 +201,7 @@ function buildUp(jsonObj,opts){
// href looks like this in pleroma (and we should ignore): https://social.fenwick.pizza/objects/1e2fa906-378c-43f8-98fa-271aae455758
var href = link['@']['href'];
if (!href){return}
item.atomHref = href;
var match = href.match(/\/\d+.atom/);
if(!match){return}
var id = match[0].replace(/\D/g,'');

View file

@ -55,9 +55,17 @@
<div class="author-fullname"> <%= item.author.fullName %> </div>
</div>
</div>
<% if (item.hasCw){ %>
<% var cwId = (item.cw+item.atomHref).replace(/\W+/g,'') %>
<span class="cw"><%- item.cw %></span>
<input type="checkbox" class="showmore" id="<%- cwId %>">
<label class="button" for="<%- cwId %>">Show</label>
<% } %>
<div class="item-content">
<%- item.content %>
</div>
<% if (item.enclosures.length > 0){ %>
<div class="enclosures">
<% for (var i = 0; i < item.enclosures.length; i ++){ var e = item.enclosures[i] %>
@ -73,6 +81,7 @@
<% } %>
</div>
<% } %>
<div class="date"><%= item.stringDate %></div>
</div>
<% }); %>

View file

@ -46,11 +46,12 @@ a * {
border-top: solid 1px #626d80; }
.item-content,
.cw,
.title {
font-size: 1.1rem;
font-weight: lighter; }
.item-content * {
.item-content *, .cw {
margin: 1rem 0;
line-height: 1.4rem; }
@ -124,4 +125,31 @@ a * {
text-decoration: none;
background: #2b90d9;
color: #ffffff;
font-weight: 400; }
font-weight: 400;
cursor: pointer;
text-transform: uppercase; }
label.button {
padding: 0.25rem 0.5rem;
margin: 0.4rem;
background: #626d80;
color: #282c37;
font-size: 0.8rem; }
input[type=checkbox] {
position: absolute;
left: -9999px; }
label {
-webkit-appearance: push-button;
-moz-appearance: button;
cursor: pointer; }
input[type=checkbox]:checked ~ label::after {
content: " Less"; }
input[type=checkbox]:not(:checked) ~ label::after {
content: " More"; }
input[type=checkbox]:not(:checked) ~ div {
display: none; }

View file

@ -46,11 +46,12 @@ a * {
border-top: solid 1px #8494ab; }
.item-content,
.cw,
.title {
font-size: 1.1rem;
font-weight: lighter; }
.item-content * {
.item-content *, .cw {
margin: 1rem 0;
line-height: 1.4rem; }
@ -124,7 +125,34 @@ a * {
text-decoration: none;
background: #2b90d9;
color: #282c37;
font-weight: 400; }
font-weight: 400;
cursor: pointer;
text-transform: uppercase; }
label.button {
padding: 0.25rem 0.5rem;
margin: 0.4rem;
background: #8494ab;
color: #ffffff;
font-size: 0.8rem; }
input[type=checkbox] {
position: absolute;
left: -9999px; }
label {
-webkit-appearance: push-button;
-moz-appearance: button;
cursor: pointer; }
input[type=checkbox]:checked ~ label::after {
content: " Less"; }
input[type=checkbox]:not(:checked) ~ label::after {
content: " More"; }
input[type=checkbox]:not(:checked) ~ div {
display: none; }
.item-content,
.description,

View file

@ -64,13 +64,14 @@ a * {
}
.item-content,
.cw,
.title {
font-size: 1.1rem;
font-weight:lighter;
}
.item-content * {
.item-content *,.cw{
margin: 1rem 0;
line-height:1.4rem;
}
@ -154,4 +155,36 @@ a * {
background:$link;
color:$fg;
font-weight:400;
cursor: pointer;
text-transform: uppercase;
user-select: none;
}
label.button{
padding: 0.25rem 0.5rem;
margin:0.4rem;
background:$dimmer;
color:$bg;
font-size:0.8rem;
}
// checkbox hack stuff
input[type=checkbox] {
position: absolute;
left: -9999px;
}
label {
-webkit-appearance: push-button;
-moz-appearance: button;
cursor: pointer;
}
input[type=checkbox]:checked ~ label::after{
content:" Less";
}
input[type=checkbox]:not(:checked) ~ label::after{
content:" More";
}
input[type=checkbox]:not(:checked) ~ div{
display:none;
}