diff --git a/.gitignore b/.gitignore index 383d7073..432689ac 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,6 @@ nbproject # Generated from .drone.star .drone.yml +js/package-lock.json +js/public/app.min.js +js/public/app.min.js.map diff --git a/css/notes.css b/css/notes.css index 0ff92022..2beb46a3 100644 --- a/css/notes.css +++ b/css/notes.css @@ -141,6 +141,12 @@ z-index: -1; border-top: 1px solid rgba(120, 120, 120, 0.5); } +.mdedit .code-block { + background: rgba(120, 120, 120, 0.1); + padding: 0 0.5em; + margin: 0.5em 0; + display: block; +} /* hanging punctuation */ @@ -167,3 +173,9 @@ padding-left: 90px; } } + +#searchnotes { + width: 100%; + border-left: 0px; + padding-left: 12px; +} \ No newline at end of file diff --git a/img/manifest.json b/img/manifest.json new file mode 100644 index 00000000..65ddda65 --- /dev/null +++ b/img/manifest.json @@ -0,0 +1,19 @@ +{ + "name": "Notes", + "start_url": "../../../apps/notes/#/", + "icons": [ + { + "src": "./favicon-touch.png", + "type": "image/png", + "sizes": "128x128" + }, + { + "src": "./favicon-touch.svg", + "type": "image/svg+xml", + "sizes": "any" + } + ], + "display": "standalone", + "theme_color": "#041e42", + "background_color": "#ffffff" +} \ No newline at end of file diff --git a/js/app/controllers/notescontroller.js b/js/app/controllers/notescontroller.js index d180e04b..3291c7f5 100644 --- a/js/app/controllers/notescontroller.js +++ b/js/app/controllers/notescontroller.js @@ -43,4 +43,37 @@ app.controller('NotesController', function($routeParams, $scope, $location, }); }; -}); + var searchbox = $('#searchnotes'); + + initSearch(); + + function initSearch() { + $scope.queryString = searchbox.val().trim(); + + /** Conduct the search when there is a pause in typing in text */ + var checkQueryChange = _.debounce(function() { + if ($scope.queryString != searchbox.val().trim()) { + onEnterSearchString(); + } + }, 250); + searchbox.bind('propertychange change keyup input paste', checkQueryChange); + + /** Run search when enter pressed within the searchbox */ + searchbox.bind('keydown', function (event) { + if (event.which === 13) { + onEnterSearchString(); + } + }); + } + + function onEnterSearchString() { + setQueryString(searchbox.val().trim()); + } + + function setQueryString(query) { + $scope.$apply(() => { + $scope.queryString = query; + }); + } + +}); \ No newline at end of file diff --git a/js/app/filters/noteFilter.js b/js/app/filters/noteFilter.js new file mode 100644 index 00000000..54e5cd9f --- /dev/null +++ b/js/app/filters/noteFilter.js @@ -0,0 +1,10 @@ +app.filter('noteFilter', function() { + 'use strict'; + return function (items, searchString) { + if (!searchString || searchString.length == 0) + return items; + + var regex = new RegExp(searchString, 'i'); + return items.filter(x => x.title.match(regex) || x.content.match(regex)); + }; +}); \ No newline at end of file diff --git a/js/config/app.js b/js/config/app.js index 1164a709..778eab24 100644 --- a/js/config/app.js +++ b/js/config/app.js @@ -38,9 +38,16 @@ config(function($provide, $routeProvider, RestangularProvider, $httpProvider, Restangular.one('notes', noteId).get().then(function (note) { is.loading = false; deferred.resolve(note); - }, function () { + }, function (response) { is.loading = false; - deferred.reject(); + + // Token expired + if (response.status == 412) { + OC.reload(); + } + else { + deferred.reject(); + } }); return deferred.promise; diff --git a/templates/main.php b/templates/main.php index 2baf6daf..17135fb8 100644 --- a/templates/main.php +++ b/templates/main.php @@ -40,8 +40,12 @@ oc-click-focus="{ selector: '#app-content textarea' }"> + t('New note')); ?> + +
  • + +
  • -
  • {{ note.title | noteTitle }} diff --git a/templates/note.php b/templates/note.php index 901a3f2b..623b91a0 100644 --- a/templates/note.php +++ b/templates/note.php @@ -1,4 +1,2 @@ -
    {{note.content}}
    {{note.content | wordCount}}
    -