Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:kgiszewski/UmbracoBookshelf
Browse files Browse the repository at this point in the history
Conflicts:
	config/meta.json
	src/Properties/AssemblyInfo.cs
  • Loading branch information
kgiszewski committed Jun 26, 2017
2 parents bc4075e + cf4d334 commit 8d40c11
Show file tree
Hide file tree
Showing 26 changed files with 605 additions and 67 deletions.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# UmbracoBookshelf
![Bookshelf](https://github.com/kgiszewski/UmbracoBookshelf/blob/master/assets/logo.png)

##Demo Video##

Click the image below to see it in action.

[![Bookshelf](http://img.youtube.com/vi/zunbKOPPf8U/0.jpg)](http://www.youtube.com/watch?v=zunbKOPPf8U)

Bookshelf will allow users to create, display and share learning resources quickly through the Umbraco backoffice.

Bookshelf works by reading markdown files from the `UmbracoBookshelf` folder of your website.
Expand Down Expand Up @@ -42,3 +48,55 @@ MIT licensed, use it and abuse it.
Umbraco Bookshelf is maintained by Kevin Giszewski.

http://twitter.com/kevingiszewski

##Uninstall##

To uninstall, you will need to make sure you remove these files either manually or via Nuget `uninstall-package umbracobookshelf`

~/App_Plugins/UmbracoBookshelf
~/bin/UmbracoBookshelf.dll

And edit these files:

```
~/config/dashboard.config
Remove this element:
<section alias="UmbracoBookshelfSection">
<areas>
<area>UmbracoBookshelf</area>
</areas>
<tab caption="Library">
<control>/app_plugins/umbracobookshelf/backoffice/dashboards/library.html</control>
</tab>
</section>
```

```
~/config/ExamineIndex.config
Remove this element:
<IndexSet SetName="BookshelfIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Bookshelf">
<IndexUserFields>
<add Name="id" />
<add Name="book" />
<add Name="path" />
<add Name="title" />
<add Name="text" />
<add Name="url" />
</IndexUserFields>
</IndexSet>
```

```
~/config/ExamineSettings.config
Remove these two elements:
<add name="BookshelfIndexer" type="Examine.LuceneEngine.Providers.SimpleDataIndexer, Examine" dataService="UmbracoBookshelf.Examine.BookshelfExamineDataService,UmbracoBookshelf" indexTypes="Bookshelf" />
<add name="BookshelfSearcher" type="Examine.LuceneEngine.Providers.LuceneSearcher, Examine" analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" />
```
2 changes: 1 addition & 1 deletion config/meta.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "UmbracoBookshelf",
"version": "0.9.0",
"version": "0.10.6",
"url": "http://github.com/kgiszewski/umbracobookshelf",
"author": "Kevin Giszewski and Tom Fulton for the auto-packager stuffs",
"authorUrl": "http://giszewski.com/",
Expand Down
2 changes: 1 addition & 1 deletion config/package.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<iconUrl>http://github.com/kgiszewski/umbracobookshelf/raw/master/assets/logo.png</iconUrl>
<licenseUrl><%= licenseUrl %></licenseUrl>
<dependencies>
<dependency id="UmbracoCms.Core" version="7.2.0" />
<dependency id="UmbracoCms.Core" version="7.3.0" />
</dependencies>
</metadata>
</package>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h1 class="ng-binding">{{model.filePath}}</h1>
<div class="bookshelf-toolbar-right span3 text-right">
<div ng-show="isEditing">
<button class="btn btn btn-default" ng-click="toggleEdit();">Hide Editor</button>
<button ng-show="dirty" class="btn btn btn-success" ng-click="save()" ng-disabled="isSaving">Save</button>
<button ng-show="dirty" class="btn btn btn-success" hotkey="ctrl+s" ng-click="save()" ng-disabled="isSaving">Save</button>
</div>
<div ng-hide="isEditing || config.disableEditing">
<button class="btn btn btn-default" style="float: right;" ng-click="toggleEdit();">Edit</button>
Expand All @@ -36,17 +36,16 @@ <h1 class="ng-binding">{{model.filePath}}</h1>
</div>
</umb-header>
<umb-tab-view>
<umb-tab id="tab1" rel="content">
<umb-tab id="tab1" rel="content" style="display: block;">
<div id="bookshelf-canvas" class="umb-pane row">
<div ng-show="isEditing" class="span6" style="padding-right: 20px;">
<textarea auto-grow ng-model="model.content" class="span12" style="height: 100%; margin-bottom: 10px;" ng-change="makeDirty()"></textarea>
<textarea auto-grow insert-md ng-model="model.content" class="span12" style="height: 100%; margin-bottom: 10px;" ng-change="makeDirty()"></textarea>
</div>

<div class="bookshelf-markup" ng-class="{span6: isEditing, span12: !isEditing}" umbraco-bookshelf-marked-up="{{model.content}}"></div>
</div>
</umb-tab>
</umb-tab-view>
</umb-panel>
<umbraco-bookshelf-ctrl-s></umbraco-bookshelf-ctrl-s>
<umbraco-bookshelf-editor-height></umbraco-bookshelf-editor-height>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ <h1 class="ng-binding">{{model.dirPath}}</h1>
</div>
</umb-header>
<umb-tab-view>
<umb-tab id="tab1" rel="content">
<umb-tab id="tab1" rel="content" style="display: block;">
<div class="umb-pane">
<div class="bookshelf-markup" umbraco-bookshelf-marked-up="{{model.content}}"></div>
</div>
Expand Down
106 changes: 80 additions & 26 deletions src/App_Plugins/UmbracoBookshelf/js/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
return input.substring(0, qMarkIndex);
}

var linker = function(scope, element, attrs) {
var linker = function (scope, element, attrs) {
marked.setOptions({
highlight: function(code) {
hljs.initHighlightingOnLoad();
Expand All @@ -50,7 +50,6 @@
});

scope.$watch('model.content', function (newValue, oldValue) {

//not sure why, but the urls are double encoded
var url = decodeURIComponent($location.url());
var isViewingFile = (url.indexOf('/file/') != -1);
Expand All @@ -61,10 +60,20 @@
var pathOnFileSystemSections = pathOnFileSystem.split('/');

if (newValue) {
var markup = element.html(marked(newValue));

var $markupHtml = $('<div>' + marked(newValue) + '</div>');

//clean out script tags (though we may need to expand this to img, comments and the like)
$markupHtml.find('script').each(function() {
var $item = $(this);

$item.remove();
});

var markup = element.html($markupHtml);

/* handle links */
markup.find('a').each(function() {
markup.find('a').each(function () {
var $a = $(this);
var href = $a.attr('href');
var relativePath = "";
Expand All @@ -85,7 +94,7 @@
var extension = href.split('.').pop();

//test for media downloads
if (inArray(scope.config.fileExtensions, "." + extension)) {
if (extension != 'md' && inArray(scope.config.fileExtensions, "." + extension)) {
$a.attr('href', relativePath + href);
$a.attr('target', '_blank');
} else {
Expand All @@ -97,7 +106,7 @@
});

/* fixup image relative paths */
markup.find('img').each(function() {
markup.find('img').each(function () {
var $img = $(this);
var relativePath = "";

Expand All @@ -118,25 +127,75 @@
restrict: "A",
link: linker
}
}).directive('umbracoBookshelfCtrlS', function() {

var linker = function(scope, element, attrs) {
$(document).keydown(function(e) {
if ((e.which == '115' || e.which == '83') && (e.ctrlKey || e.metaKey)) {
e.preventDefault();
scope.save();
return false;
}).directive('autoGrow', function ($timeout) {
var linker = function (scope, element, attrs) {
scope.$watch('isEditing', function (newValue, oldValue) {
if (newValue) {
$timeout(function() {
element.autogrow();
}, 100);
}
return true;
});
}

return {
restrict: "E",
restrict: "A",
link: linker
}
}).directive('autoGrow', function ($timeout) {
}).directive('umbracoBookshelfNavigation', function ($http, $compile) {

function linker(scope, element, attrs) {
function getView(view) {
$http.get(view, { cache: false }).then(function (data) {

element.html(data.data).show();

$compile(element.contents())(scope);
});
}

scope.$on("$routeChangeSuccess", function(event, current, previous) {

/*
For anyone that actually read this...
This is a way to avoid re-initializing the default navigation view. Without this bit of code, the UI flashes.
If it seems convoluted, it is. Apologies.
*/

var isComingFromBookshelf = (previous && previous.pathParams.section && previous.pathParams.section.toLowerCase().indexOf("umbracobookshelf") != -1);
var isOnBookshelf = (current.pathParams && current.pathParams.section && current.pathParams.section.toLowerCase().indexOf("umbracobookshelf") != -1);

//if on bookshelf but not coming from bookshelf
if (isOnBookshelf) {
if (!isComingFromBookshelf) {
getView("/App_Plugins/UmbracoBookshelf/Views/navigation.html");
}
} else {
//if first time viewed
if (!previous) {
getView("views/directives/umb-navigation.html?intercepted=1");
} else {
//if coming from bookshelf
if (isComingFromBookshelf) {
getView("views/directives/umb-navigation.html?intercepted=1");
} else {
if (previous.loadedTemplateUrl && previous.loadedTemplateUrl.indexOf("login.html") != -1) {
getView("views/directives/umb-navigation.html?intercepted=1");
}
}
}
}
});
}

return {
restrict: "E",
link: linker,
replace: true
}
}).directive('insertMd', function() {
var insertAtCaret = function (element, text) {
text = text || '';
if (document.selection) {
Expand All @@ -158,17 +217,12 @@
}
};

var linker = function (scope, element, attrs) {
scope.$watch('isEditing', function (newValue, oldValue) {
if (newValue) {
$timeout(function() {
element.autogrow();
}, 100);
}
});

function linker(scope, element, attrs) {
scope.$on('insertMd', function (ev, args) {
insertAtCaret(element.get(0), "\n" + args.md + "\n");
scope.makeDirty();

scope.$emit('insertMdComplete');
});
}

Expand Down
15 changes: 15 additions & 0 deletions src/App_Plugins/UmbracoBookshelf/js/interceptors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
angular.module('umbraco').service('umbracoBookshelfInterceptor', function ($location, $templateCache) {
var service = this;

service.request = function (request) {
if (request.url == "views/directives/umb-navigation.html") {
request.url = "/App_Plugins/UmbracoBookshelf/Views/navigation.router.html";
}

return request;
};
});

angular.module('umbraco').config(function ($httpProvider) {
$httpProvider.interceptors.push('umbracoBookshelfInterceptor');
});
4 changes: 2 additions & 2 deletions src/App_Plugins/UmbracoBookshelf/js/library.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}

$scope.getUpdatedOn = function(item) {
if (item.details) {
if (item.details && item.details.pushed_at) {
return item.details.pushed_at.replace('T', ' ');
}

Expand All @@ -49,7 +49,7 @@
umbracoBookshelfResource.getBookFeed().then(function(data) {
$scope.model.feed = data;
}).then(function () {
angular.forEach($scope.model.feed.gitHub, function(feedItem) {
angular.forEach($scope.model.feed.gitHub, function (feedItem) {
umbracoBookshelfResource.getContributors(feedItem).then(function(contributors) {
feedItem.authors = contributors;
});
Expand Down
5 changes: 5 additions & 0 deletions src/App_Plugins/UmbracoBookshelf/js/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
return umbRequestHelper.resourcePromise(
$http.get("/umbraco/backoffice/umbracobookshelfapi/umbracobookshelf/getsiblingfiles/?filePath=" + filePath), 'Failed to get sibling files'
);
},
searchFiles: function (keywords) {
return umbRequestHelper.resourcePromise(
$http.get("/umbraco/backoffice/umbracobookshelfapi/umbracobookshelf/searchfiles/?keywords=" + keywords), 'Failed to search files'
);
}
}
});
26 changes: 26 additions & 0 deletions src/App_Plugins/UmbracoBookshelf/js/search.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
angular.module('umbraco').controller('umbracoBookshelfSearchController', function($scope, umbracoBookshelfResource) {

$scope.model = {};
$scope.model.keywords = "";

$scope.model.books = [];

$scope.isLoading = false;

$scope.search = function() {

if ($scope.model.keywords && $scope.model.keywords.length > 2) {

$scope.isLoading = true;

umbracoBookshelfResource.searchFiles($scope.model.keywords).then(function(data) {
$scope.model.books = data;
$scope.isLoading = false;
});
}
}

$scope.clear = function() {
$scope.model.keywords = "";
}
});
4 changes: 3 additions & 1 deletion src/App_Plugins/UmbracoBookshelf/package.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"~/App_Plugins/UmbracoBookshelf/js/marked.min.js",
"~/App_Plugins/UmbracoBookshelf/js/highlight.pack.js",
"~/App_Plugins/UmbracoBookshelf/js/autogrow.js",
"~/App_Plugins/UmbracoBookshelf/js/imageSelector.controller.js"
"~/App_Plugins/UmbracoBookshelf/js/imageSelector.controller.js",
"~/App_Plugins/UmbracoBookshelf/js/interceptors.js",
"~/App_Plugins/UmbracoBookshelf/js/search.controller.js"
],
"css": [
"~/App_Plugins/UmbracoBookshelf/css/application.css"
Expand Down
Loading

0 comments on commit 8d40c11

Please sign in to comment.