add option for turning header on and off
This commit is contained in:
parent
85d65f1c56
commit
54dc7a5be0
7
index.js
7
index.js
|
@ -39,6 +39,13 @@ app.get('/api/feed',function(req,res){
|
||||||
if (req.query.theme){
|
if (req.query.theme){
|
||||||
opts.theme = 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);
|
var req = request.get(feedUrl);
|
||||||
convert(req,opts,function(er,data){
|
convert(req,opts,function(er,data){
|
||||||
|
|
|
@ -75,6 +75,7 @@ function buildUp(jsonObj,opts){
|
||||||
|
|
||||||
// assign opts to the obj
|
// assign opts to the obj
|
||||||
jsonObj.opts = opts||{};
|
jsonObj.opts = opts||{};
|
||||||
|
console.log(opts);
|
||||||
|
|
||||||
// iterate through the items
|
// iterate through the items
|
||||||
jsonObj.items = jsonObj.items.filter(function(item){
|
jsonObj.items = jsonObj.items.filter(function(item){
|
||||||
|
|
|
@ -18,15 +18,16 @@
|
||||||
<% } %>
|
<% } %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="meta">
|
<% if (opts.header !== false){ %>
|
||||||
<div class="title">
|
<div class="meta">
|
||||||
<a target="_top" href="<%= meta.link %>">
|
<div class="title">
|
||||||
<%- meta.title %>'s Feed on Mastodon
|
<a target="_top" href="<%= meta.link %>">
|
||||||
</a>
|
<%- meta.title %>'s Feed on Mastodon
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="description"><%- meta.description %></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="description"><%- meta.description %></div>
|
<% } %>
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<% items.forEach(function(item){ %>
|
<% items.forEach(function(item){ %>
|
||||||
<div class="item">
|
<div class="item">
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
<option value="light">light</option>
|
<option value="light">light</option>
|
||||||
</select>
|
</select>
|
||||||
</label><br>
|
</label><br>
|
||||||
|
<label>Show header?<input id="header" type="checkbox" checked></label><br>
|
||||||
<button value="generate">Generate</button>
|
<button value="generate">Generate</button>
|
||||||
</form>
|
</form>
|
||||||
<br>
|
<br>
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
<label>Use this markup in your HTML: <br><textarea id="result" placeholder="result will go here"></textarea></label>
|
<label>Use this markup in your HTML: <br><textarea id="result" placeholder="result will go here"></textarea></label>
|
||||||
<br>
|
<br>
|
||||||
<h4>Live Preview:</h4>
|
<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>
|
<script>
|
||||||
window.genUrl = function genUrl(){
|
window.genUrl = function genUrl(){
|
||||||
function val(id){
|
function val(id){
|
||||||
|
@ -34,7 +35,9 @@ window.genUrl = function genUrl(){
|
||||||
|
|
||||||
var inUrl = 'https://' + val('urlin') + '/users/'+val('usernamein')+'.atom';
|
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>';
|
document.getElementById('result').value = '<iframe allowfullscreen sandbox="allow-top-navigation allow-scripts" width="'+val('width')+'" height="'+val('height')+'" src="'+iframeUrl+'"></iframe>';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue