add option for turning header on and off

This commit is contained in:
fenwick67 2017-05-01 22:47:15 -05:00
parent 85d65f1c56
commit 54dc7a5be0
4 changed files with 22 additions and 10 deletions

View file

@ -39,6 +39,13 @@ app.get('/api/feed',function(req,res){
if (req.query.theme){
opts.theme = req.query.theme;
}
if (req.query.header){
if (req.query.header.toLowerCase() == 'no' || req.query.header.toLowerCase() == 'false'){
opts.header = false;
}else{
opts.header = true;
}
}
var req = request.get(feedUrl);
convert(req,opts,function(er,data){

View file

@ -75,6 +75,7 @@ function buildUp(jsonObj,opts){
// assign opts to the obj
jsonObj.opts = opts||{};
console.log(opts);
// iterate through the items
jsonObj.items = jsonObj.items.filter(function(item){

View file

@ -18,15 +18,16 @@
<% } %>
</head>
<body>
<div class="meta">
<div class="title">
<a target="_top" href="<%= meta.link %>">
<%- meta.title %>'s Feed on Mastodon
</a>
<% if (opts.header !== false){ %>
<div class="meta">
<div class="title">
<a target="_top" href="<%= meta.link %>">
<%- meta.title %>'s Feed on Mastodon
</a>
</div>
<div class="description"><%- meta.description %></div>
</div>
<div class="description"><%- meta.description %></div>
</div>
<% } %>
<div class="container">
<% items.forEach(function(item){ %>
<div class="item">

View file

@ -18,6 +18,7 @@
<option value="light">light</option>
</select>
</label><br>
<label>Show header?<input id="header" type="checkbox" checked></label><br>
<button value="generate">Generate</button>
</form>
<br>
@ -25,7 +26,7 @@
<label>Use this markup in your HTML: <br><textarea id="result" placeholder="result will go here"></textarea></label>
<br>
<h4>Live Preview:</h4>
<iframe id="frame" allowfullscreen sandbox="allow-top-navigation allow-scripts" width="400" height="800" src="/api/feed?url=https%3A%2F%2Foctodon.social%2Fusers%2Ffenwick67.atom&theme=dark&size=100"></iframe>
<iframe id="frame" allowfullscreen sandbox="allow-top-navigation allow-scripts" width="400" height="800" src="/api/feed?url=https%3A%2F%2Foctodon.social%2Fusers%2Ffenwick67.atom&theme=dark&size=100&header=true"></iframe>
<script>
window.genUrl = function genUrl(){
function val(id){
@ -34,7 +35,9 @@ window.genUrl = function genUrl(){
var inUrl = 'https://' + val('urlin') + '/users/'+val('usernamein')+'.atom';
var iframeUrl = window.location.protocol + '//'+ window.location.hostname +((window.location.port && window.location.port!=80)?(':'+window.location.port):'') +"/api/feed?url="+encodeURIComponent(inUrl)+"&theme="+val('theme')+'&size='+val('size');
var iframeUrl = window.location.protocol + '//'+ window.location.hostname +((window.location.port && window.location.port!=80)?(':'+window.location.port):'')
+"/api/feed?url="+encodeURIComponent(inUrl)+"&theme="+val('theme')+'&size='+val('size')
+ "&header="+(document.getElementById('header').checked.toString());
document.getElementById('result').value = '<iframe allowfullscreen sandbox="allow-top-navigation allow-scripts" width="'+val('width')+'" height="'+val('height')+'" src="'+iframeUrl+'"></iframe>';