Skip to content
Permalink
Browse files

Tweaked file info on dashboard

  • Loading branch information...
davidmerfield committed Mar 9, 2019
1 parent 8702626 commit 5a9e6ada4efefdae2a25760d2302e21204f57837
@@ -5,52 +5,74 @@ var basename = require("path").basename;
var dirname = require("path").dirname;
var joinpath = require("path").join;
var moment = require("moment");
require("moment-timezone");
require("moment-timezone");

var Entry = require("entry");
var IgnoredFiles = require("../../../models/ignoredFiles");
var extname = require("path").extname;
var Metadata = require("metadata");
var REASONS = {
PREVIEW: "a preview",
TOO_LARGE: "too large",
PUBLIC_FILE: "a public file",
WRONG_TYPE: "not a file Blot can process"
PREVIEW: "it is a preview",
TOO_LARGE: "it is too large",
PUBLIC_FILE: "it is a public file",
WRONG_TYPE: "it is not a file Blot can process"
};

var kind = require('./kind');
var kind = require("./kind");

module.exports = function(blog, path, callback) {
var blogID = blog.id;
var local = localPath(blogID, path);

stat(local, function(err, stat) {
if (err) return callback(err);

Metadata.get(blogID, path, function(err, casePresevedName) {
if (err) return callback(err);

IgnoredFiles.getStatus(blogID, path, function(err, ignored) {
if (err) return callback(err);

Entry.get(blogID, path, function(entry) {
if (ignored) ignored = REASONS[ignored] || "was ignored";

if (ignored || !entry) {
if (path.toLowerCase().indexOf("/templates/") === 0) {
ignored = "it is part of a template";
} else if (
path.split("/").filter(function(n) {
return n[0] === "_";
}).length
) {
ignored =
"it is inside a folder whose name begins with an underscore";
} else if (require("path").basename(path)[0] === "_") {
ignored = "its name begins with an underscore";
} else {
ignored = REASONS[ignored] || "it was ignored";
}
}

stat.kind = kind(path);
stat.path = path;
stat.name = casePresevedName || basename(path);
stat.created = moment.utc(stat.ctime).tz(blog.timeZone).calendar(null, {
sameDay: '[Today], h:mm A',
lastDay: '[Yesterday], h:mm A',
lastWeek: 'LL, h:mm A',
sameElse: 'LL, h:mm A'
});
stat.modified = moment.utc(stat.mtime).tz(blog.timeZone).calendar(null, {
sameDay: '[Today], h:mm A',
lastDay: '[Yesterday], h:mm A',
lastWeek: 'LL, h:mm A',
sameElse: 'LL, h:mm A'
});
stat.created = moment
.utc(stat.ctime)
.tz(blog.timeZone)
.calendar(null, {
sameDay: "[Today], h:mm A",
lastDay: "[Yesterday], h:mm A",
lastWeek: "LL, h:mm A",
sameElse: "LL, h:mm A"
});
stat.modified = moment
.utc(stat.mtime)
.tz(blog.timeZone)
.calendar(null, {
sameDay: "[Today], h:mm A",
lastDay: "[Yesterday], h:mm A",
lastWeek: "LL, h:mm A",
sameElse: "LL, h:mm A"
});

stat.updated = moment.utc(stat.mtime).from(moment.utc());
stat.size = humanFileSize(stat.size);
@@ -66,11 +88,10 @@ module.exports = function(blog, path, callback) {
// Replace with case-preserving
entry.name = stat.name;

entry.date = moment
.utc(entry.dateStamp)
.tz(blog.timeZone)
.format("MMMM Do YYYY, h:mma");

entry.date = moment
.utc(entry.dateStamp)
.tz(blog.timeZone)
.format("MMMM Do YYYY, h:mma");

if (
entry.page &&
@@ -1,44 +1,50 @@
{{^entry}}
<tr>
<td>Ignored:</td>
<td>This file is not a post because {{ignored}}.</td>
</tr>
{{/entry}}


{{#entry}}

<span class="line-item">
<span class="lab">Title:</span>
<span class="val">{{title}}</span>
</span>
<tr>
<td>Title:</td>
<td>{{title}}</td>
</tr>

{{^draft}}{{^scheduled}}
<span class="line-item">
<span class="lab">URL:</span>
<span class="val"><a href="{{blog.url}}{{url}}">{{{url}}}</a></span>
</span>
<tr>
<td>URL:</td>
<td><a href="{{blog.url}}{{url}}">{{{url}}}</a></td>
</tr>
{{/scheduled}}{{/draft}}


<span class="line-item">
<span class="lab">Date:</span>
<span class="val">{{#scheduled}}Scheduled for publication {{toNow}} on {{date}}{{/scheduled}}{{^scheduled}}{{date}}{{/scheduled}}</span>
</span>
<tr>
<td>Date:</td>
<td>{{#scheduled}}Scheduled for publication {{toNow}} on {{date}}{{/scheduled}}{{^scheduled}}{{date}}{{/scheduled}}</td>
</tr>

<span class="line-item">
<span class="lab">Draft:</span>
<span class="val">{{#draft}}Yes{{/draft}}{{^draft}}No{{/draft}}</span>
</span>
<tr>
<td>Draft:</td>
<td>{{#draft}}Yes{{/draft}}{{^draft}}No{{/draft}}</td>
</tr>

<span class="line-item">
<span class="lab">Page:</span>
<span class="val">{{#page}}Yes {{/page}}{{^page}}No{{/page}}</span>
</span>
<tr>
<td>Page:</td>
<td>{{#page}}Yes {{/page}}{{^page}}No{{/page}}</td>
</tr>

<!--
<span class="line-item">
<span class="lab">Why:</span>
<span class="val">{{name}} became a blog post because it a type of file Blot can process</span>
</span>
<tr>
<td>Why:</td>
<td>{{name}} became a blog post because it a type of file Blot can process</td>
</td>
-->
<!--
{{^scheduled}}
Draft that will be dated: <span style="float:right">{{date}}</span>
Draft that will be dated: <span style="float:right">{{date}}</td>
{{/scheduled}}
{{#scheduled}}
@@ -48,7 +54,7 @@
{{^scheduled}}
Published: <span style="float:right">{{date}}</span>
Published: <span style="float:right">{{date}}</td>
{{/scheduled}}
{{#scheduled}}
@@ -60,15 +66,15 @@


<!--
<span class="line-item">
<span class="lab">Created:</span>
<span class="val">Plain text document</span>
</span>
<span class="line-item">
<span class="lab">Modified:</span>
<span class="val">Plain text document</span>
</span> -->
<tr>
<td>Created:</td>
<td>Plain text document</td>
</td>
<tr>
<td>Modified:</td>
<td>Plain text document</td>
</td> -->


{{/entry}}
@@ -1,8 +1,13 @@
<style type="text/css">
tr {border: none;}
td {vertical-align: top;}
td:first-child {color: rgb(158, 154, 152);padding-right: 20px}
</style>
<div style="padding:0 20px">

{{#folder.stat}}
{{#folder.stat}}

<span style="line-height:36px">
<span style="line-height:36px">
{{#entry}}
<img src="/images/file-post.svg" style="margin-right:4px;vertical-align:text-bottom;" width="16">
{{/entry}}
@@ -12,15 +17,14 @@

<span>
<a href="{{blog.url}}{{path}}" style="color:#365899;text-decoration:none">{{name}}</a>
<span style="float:right;color:rgb(158, 154, 152)">{{size}}</span>
</span>
</span>
<span style="display:block;color:rgb(158, 154, 152);margin-left:24px;margin-top:-6px;margin-bottm:">Modified: {{updated}}</span>
<!-- <span style="float:right;color:rgb(158, 154, 152)">{{size}}</span>
--> </span>
</span>
<!-- <span style="display:block;color:rgb(158, 154, 152);margin-left:24px;margin-top:-6px;margin-bottm:">Modified: {{updated}}</span>
--> </span>
<div class="clear" style="margin:11px 0;border-bottom:1px solid rgba(0,0,0,0.05)"></div>


<!--
<!--
<span class="line-item">
{{#entry}}<a class="val external" style="margin-top:20px;margin-bottom:10px" href="{{blog.url}}{{{url}}}" >Visit
@@ -36,18 +40,13 @@
{{/page}}
<span class="square">&rarr;</span></a>{{/entry}}
</span> -->
</span> -->

{{^entry}}
<span class="line-item">
<span class="lab">Ignored:</span>
<span class="val">This file is not a blog post because it is <a href="/publishing">{{ignored}}</a>. You can however <a href="">embed this file or link to it</a>.</span>
</span>
{{/entry}}

{{> entry}}

{{> stat}}
<table>
{{> entry}}

{{/folder.stat}}
{{> stat}}
</table>
{{/folder.stat}}
</div>
@@ -1,42 +1,35 @@

{{#stat}}


<span class="line-item">
<span class="lab">Where:</span>
<span class="val">{{path}}</span>
</span>

<span class="line-item">
<span class="lab">Kind:</span>
<span class="val">{{kind}}</span>
</span>

<span class="line-item">
<span class="lab">Size:</span>
<span class="val">{{size}}</span>
</span>

<span class="line-item">
<span class="lab">Created:</span>
<span class="val">{{created}}</span>
</span>

<span class="line-item">
<span class="lab">Modified:</span>
<span class="val">{{modified}}</span>
</span>
<!--
<span class="lab">Kind:</span>
<span class="val">Plain text document</span>
<tr>
<td>Where:</td>
<td>{{path}}</td>
</tr>

<tr>
<td>Kind:</td>
<td>{{kind}}</td>
</tr>

<tr>
<td>Size:</td>
<td>{{size}}</td>
</tr>

<tr>
<td>Created:</td>
<td>{{created}}</td>
</tr>

<tr>
<td>Modified:</td>
<td>{{modified}}</td>
</tr>
<!-- <td>Kind:</td>
<td>Plain text document</td>
<span class="file"></span> <a class="" href="{{blog.url}}{{path}}">{{name}}</a>
<span class="file"></td> <a class="" href="{{blog.url}}{{path}}">{{name}}</a>
<hr>
<span style="float:right">{{size}}</span>
Modified {{updated}} -->



{{/stat}}
<span style="float:right">{{size}}</td>
Modified {{updated}} -->{{/stat}}

0 comments on commit 5a9e6ad

Please sign in to comment.
You can’t perform that action at this time.