diff --git a/README.md b/README.md index dc9f87d0..47b77d76 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Full node install description: https://raspberrypi.stackexchange.com/questions/4 ```bash cd ~ -wget https://github.com/bpatrik/pigallery2/releases/download/1.0.0-beta.3/pigallery2.zip +wget https://github.com/bpatrik/pigallery2/releases/download/1.0.0-rc.1/pigallery2.zip unzip pigallery2 cd pigallery2 npm install @@ -59,6 +59,12 @@ npm start To configure it. Run `PiGallery2` first to create `config.json` file, then edit it and restart. Default user: `admin` pass: `admin` + +### Using nginx +https://stackoverflow.com/questions/5009324/node-js-nginx-what-now +### making https +https://certbot.eff.org/ + ## Feature list * **Rendering directories as it is** @@ -91,9 +97,10 @@ Default user: `admin` pass: `admin` * instant search, auto complete * sharing * setting link expiration time - * Nice design - `In progress` + * Nice design * responsive design (phone, tablet desktop support) - * Setup page - `In progress` + * Setup page + * video support - `future plan` * **Markdown based blogging support** - `future plan` * you can write some note in the blog.md for every directory * bug free :) - `In progress` diff --git a/common/config/public/ConfigClass.ts b/common/config/public/ConfigClass.ts index 9d68ceca..a37906da 100644 --- a/common/config/public/ConfigClass.ts +++ b/common/config/public/ConfigClass.ts @@ -4,6 +4,7 @@ export module ClientConfig { instantSearchEnabled: boolean autocompleteEnabled: boolean InstantSearchTimeout: number; + autocompleteCacheTimeout: number; } export interface SharingConfig { @@ -15,6 +16,7 @@ export module ClientConfig { enabled: boolean; googleApiKey: string; } + export interface ThumbnailConfig { iconSize: number; thumbnailSizes: Array; @@ -35,6 +37,7 @@ export module ClientConfig { } } + /** * These configuration will be available at frontend and backend too */ @@ -50,7 +53,8 @@ export class PublicConfigClass { enabled: true, instantSearchEnabled: true, autocompleteEnabled: true, - InstantSearchTimeout: 3000 + InstantSearchTimeout: 3000, + autocompleteCacheTimeout: 1000 * 60 * 60 }, Sharing: { enabled: true, diff --git a/frontend/app/gallery/cache.gallery.service.ts b/frontend/app/gallery/cache.gallery.service.ts index ff6c0108..54126280 100644 --- a/frontend/app/gallery/cache.gallery.service.ts +++ b/frontend/app/gallery/cache.gallery.service.ts @@ -3,16 +3,47 @@ import {PhotoDTO} from "../../../common/entities/PhotoDTO"; import {DirectoryDTO} from "../../../common/entities/DirectoryDTO"; import {Utils} from "../../../common/Utils"; import {Config} from "../../../common/config/public/Config"; +import {AutoCompleteItem} from "../../../common/entities/AutoCompleteItem"; + +interface AutoCompleteCacheItem { + timestamp: number; + items: Array; +} @Injectable() export class GalleryCacheService { + private static CONTENT_PREFIX = "content:"; + private static AUTO_COMPLETE_PREFIX = "content:"; + + + public getAutoComplete(text: string): Array { + const key = GalleryCacheService.AUTO_COMPLETE_PREFIX + text; + const tmp = localStorage.getItem(key); + if (tmp != null) { + const value: AutoCompleteCacheItem = JSON.parse(tmp); + if (value.timestamp < Date.now() - Config.Client.Search.autocompleteCacheTimeout) { + localStorage.removeItem(key); + return null; + } + return value.items; + } + return null; + } + + public setAutoComplete(text, items: Array): void { + const tmp: AutoCompleteCacheItem = { + timestamp: Date.now(), + items: items + }; + localStorage.setItem(GalleryCacheService.AUTO_COMPLETE_PREFIX + text, JSON.stringify(tmp)); + } public getDirectory(directoryName: string): DirectoryDTO { if (Config.Client.enableCache == false) { return null; } - let value = localStorage.getItem(Utils.concatUrls(directoryName)); + let value = localStorage.getItem(GalleryCacheService.CONTENT_PREFIX + Utils.concatUrls(directoryName)); if (value != null) { let directory: DirectoryDTO = JSON.parse(value); @@ -27,7 +58,7 @@ export class GalleryCacheService { return; } - const key = Utils.concatUrls(directory.path, directory.name); + const key = GalleryCacheService.CONTENT_PREFIX + Utils.concatUrls(directory.path, directory.name); if (directory.isPartial == true && localStorage.getItem(key)) { return; } diff --git a/frontend/app/gallery/search/autocomplete.service.ts b/frontend/app/gallery/search/autocomplete.service.ts index fa0198f9..be9837cf 100644 --- a/frontend/app/gallery/search/autocomplete.service.ts +++ b/frontend/app/gallery/search/autocomplete.service.ts @@ -1,16 +1,23 @@ import {Injectable} from "@angular/core"; import {NetworkService} from "../../model/network/network.service"; import {AutoCompleteItem} from "../../../../common/entities/AutoCompleteItem"; +import {GalleryCacheService} from "../cache.gallery.service"; @Injectable() export class AutoCompleteService { - constructor(private _networkService: NetworkService) { + constructor(private _networkService: NetworkService, + private galleryCacheService: GalleryCacheService) { } - public autoComplete(text: string): Promise> { - return this._networkService.getJson>("/autocomplete/" + text); + public async autoComplete(text: string): Promise> { + let items: Array = this.galleryCacheService.getAutoComplete(text); + if (items == null) { + items = await this._networkService.getJson>("/autocomplete/" + text); + this.galleryCacheService.setAutoComplete(text, items); + } + return items; } diff --git a/frontend/app/gallery/share/share.gallery.component.html b/frontend/app/gallery/share/share.gallery.component.html index b6176101..5be81f28 100644 --- a/frontend/app/gallery/share/share.gallery.component.html +++ b/frontend/app/gallery/share/share.gallery.component.html @@ -13,7 +13,7 @@