add literal, html, and markdown link previews

This commit is contained in:
AJ ONeal 2015-01-21 13:55:23 -07:00
parent ac54f466c5
commit 0c2123542f
2 changed files with 49 additions and 18 deletions

View File

@ -104,22 +104,6 @@
</div> </div>
</div> </div>
<div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label">URL</label>
<div class="col-lg-10">
<input
required="required"
disabled
ng-model="Post.selected.url"
ng-change="Post.onChange()"
type="text"
class="form-control"
id="inputPostAbsPath"
placeholder="i.e. https://blog.me.co/posts/my-first-post/"
>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label">Source Path</label> <label for="inputPostAbsPath" class="col-lg-2 control-label">Source Path</label>
<div class="col-lg-10"> <div class="col-lg-10">
@ -152,6 +136,50 @@
</div> </div>
</div> </div>
<div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label">Links</label>
<div class="col-lg-10">
<p class="help-block"
><a ng-href="{{Post.selected.url}}"><span
ng-bind="Post.selected.url"></span></a>
</p>
<input
required="required"
ng-model="Post.selected.markdown"
ng-change="Post.onChange()"
type="text"
class="form-control"
id="inputPostMarkdown"
placeholder="i.e. [My First Post](/articles/my-first-post.html)"
>
<input
required="required"
ng-model="Post.selected.ahref"
ng-change="Post.onChange()"
type="text"
class="form-control"
id="inputPostAhref"
placeholder="i.e. <a href='/articles/my-first-post.html'>My First Post</a>"
>
</div>
</div>
<!--div class="form-group">
<label for="inputPostAbsPath" class="col-lg-2 control-label">URL</label>
<div class="col-lg-10">
<input
required="required"
disabled
ng-model="Post.selected.url"
ng-change="Post.onChange()"
type="text"
class="form-control"
id="inputPostAbsPath"
placeholder="i.e. https://blog.me.co/posts/my-first-post/"
>
</div>
</div-->
<!-- <!--
<div class="form-group"> <div class="form-group">
<label for="select" class="col-lg-2 control-label">Selects</label> <label for="select" class="col-lg-2 control-label">Selects</label>

View File

@ -73,6 +73,7 @@ angular.module('myApp.post', ['ngRoute'])
; ;
post.yml.title = post.yml.title || ''; post.yml.title = post.yml.title || '';
selected.title = post.yml.title;
post.yml.description = post.yml.description || ''; post.yml.description = post.yml.description || '';
scope.slug = post.yml.title.toLowerCase() scope.slug = post.yml.title.toLowerCase()
@ -107,6 +108,8 @@ angular.module('myApp.post', ['ngRoute'])
if (scope.env.explicitIndexes && /\/$/.test(selected.url)) { if (scope.env.explicitIndexes && /\/$/.test(selected.url)) {
selected.url += 'index.html'; selected.url += 'index.html';
} }
selected.markdown = '[' + selected.title + '](' + selected.url + ')';
selected.ahref = '<a href="' + selected.url + '">' + selected.title + '</a>';
selected.abspath = window.path.join(scope.blogdir, selected.path); selected.abspath = window.path.join(scope.blogdir, selected.path);
selected.sourcepath = window.path.join(scope.blogdir, (selected.collection || 'posts'), scope.slug + '.' + selected.format); selected.sourcepath = window.path.join(scope.blogdir, (selected.collection || 'posts'), scope.slug + '.' + selected.format);
}; };