<body>
<nav class='navbar navbar-default navbar-fixed-top'>
<div class='container-fluid'>
- <div class='col-xs-3 navbar-header'>
- <a class='navbar-brand' ng-href='/'>Nitdoc</a>
+ <div class='col-xs-3'>
+ <div class='navbar-header'>
+ <a class='navbar-brand' ng-href='/'>Nitdoc</a>
+ </div>
+ <ul class="nav navbar-nav">
+ <li><a href="/docdown?edit=true">DocDown</a></li>
+ </ul>
</div>
<div class='col-xs-7'>
<form ng-controller='SearchCtrl as searchCtrl' >
<script src='/javascripts/entities.js'></script>
<script src='/javascripts/ui.js'></script>
<script src='/javascripts/index.js'></script>
+ <script src='/javascripts/docdown.js'></script>
</body>
</html>
--- /dev/null
+/*
+ * Copyright 2016 Alexandre Terrasa <alexandre@moz-code.org>.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function() {
+ angular
+ .module('docdown', ['model', 'ngSanitize'])
+
+ .controller('DocdownCtrl', ['$routeParams', '$sce', '$scope', '$location', 'DocDown', function($routeParams, $sce, $scope, $location, DocDown) {
+
+ this.updateSnippet = function() {
+ this.updateLink();
+ this.updateHtml();
+ }
+
+ this.updateLink = function() {
+ $scope.link = $location.protocol()+ '://' + $location.host() + ':' +
+ $location.port() + $location.path() + '?snippet=' +
+ encodeURIComponent(btoa($scope.markdown));
+ }
+
+ this.updateHtml = function() {
+ DocDown.postMarkdown($scope.markdown,
+ function(data) {
+ $scope.html = $sce.trustAsHtml(data);
+ }, function(err) {
+ $scope.error = err;
+ });
+ };
+
+ this.editMode = function(isEdit) {
+ $scope.edit = isEdit;
+ }
+
+ $scope.markdown = 'Type some markdown...';
+ if($location.search().snippet) {
+ $scope.markdown = atob($location.search().snippet);
+ }
+ $scope.edit = false;
+ if($location.search().edit) {
+ $scope.edit = Boolean($location.search().edit);
+ }
+
+ this.updateSnippet();
+ }])
+})();
},
}
}])
+
+ .factory('DocDown', [ '$http', function($http) {
+ return {
+ postMarkdown: function(md, cb, cbErr) {
+ $http.post(apiUrl + '/docdown', md)
+ .success(cb)
+ .error(cbErr);
+ }
+ }
+ }])
})();
*/
(function() {
- angular.module('nitweb', ['ngRoute', 'ngSanitize', 'angular-loading-bar', 'entities', 'index'])
+ angular.module('nitweb', ['ngRoute', 'ngSanitize', 'angular-loading-bar', 'entities', 'docdown', 'index'])
.config(['cfpLoadingBarProvider', function(cfpLoadingBarProvider) {
cfpLoadingBarProvider.includeSpinner = false;
}])
controller: 'IndexCtrl',
controllerAs: 'indexCtrl'
})
+ .when('/docdown', {
+ templateUrl: 'views/docdown.html',
+ controller: 'DocdownCtrl',
+ controllerAs: 'docdownCtrl'
+ })
.when('/doc/:id', {
templateUrl: 'views/doc.html',
controller: 'EntityCtrl',
--- /dev/null
+<div class='container-fluid'>
+ <div class='page-header'>
+ <h2>Docdown snippets</h2>
+ <p class='text-muted'>Sharable documentation snippets.</p>
+ <div class="input-group">
+ <span ng-if='edit' class="input-group-btn">
+ <button class='btn btn-success' ng-click='docdownCtrl.editMode(false)'>
+ <span class='glyphicon glyphicon-link' /> View
+ </button>
+ </span>
+ <span ng-if='!edit' class="input-group-btn">
+ <button class='btn btn-success' ng-click='docdownCtrl.editMode(true)'>
+ <span class='glyphicon glyphicon-edit' /> Edit
+ </button>
+ </span>
+ <input class='form-control' type='text' ng-model='link' />
+ </div>
+ </div>
+ <div class='row'>
+ <div ng-show='edit' class='col-xs-6'>
+ <div class='card'>
+ <textarea ng-model='markdown' ng-model-options='{ debounce: 100 }' ng-change='docdownCtrl.updateSnippet()' class='form-control' rows='20'></textarea>
+ </div>
+ </div>
+ <div ng-class='edit ? "col-xs-6" : "col-xs-12"'>
+ <div class='card'>
+ <div class='card-body nitdoc'>
+ <div ng-bind-html='html' />
+ </div>
+ </div>
+ </div>
+ </div>
+</div>