Add option to use main link to open original page

This commit is contained in:
Radhi Fadlillah 2018-06-14 14:32:50 +07:00
parent 85101984e9
commit 707ea8215b
4 changed files with 44 additions and 14 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -113,7 +113,7 @@
</div>
<div class="bookmark" v-for="(book, idx) in visibleBookmarks" :class="{selected: isSelected(idx)}">
<a class="bookmark-selector" v-if="editMode" @click="toggleSelection(idx)"></a>
<a class="bookmark-link" :href="book.hasContent ? '/bookmark/'+book.id : null" :title="book.hasContent ? 'View cache' : null" target="_blank">
<a class="bookmark-link" :href="getBookLink(book, true)" :title="getBookLinkTitle(book, true)" target="_blank">
<img v-if="book.imageURL !== ''" :src="book.imageURL">
<p class="title">{{book.title}}</p>
<p class="excerpt" v-if="book.imageURL === ''">{{book.excerpt}}</p>
@ -124,7 +124,7 @@
</div>
<div class="spacer"></div>
<div class="bookmark-menu">
<a class="url" title="View original" :href="book.url" target="_blank">
<a class="url" :href="getBookLink(book, false)" :title="getBookLinkTitle(book, false)" target="_blank">
{{getHostname(book.url)}}
</a>
<a title="Edit bookmark" @click="showDialogEdit(idx)">
@ -188,6 +188,9 @@
<a @click="toggleBookmarkID">
<i class="fa-fw" :class="options.showBookmarkID ? 'fas fa-check-square' : 'far fa-square'"></i>Show bookmark's ID
</a>
<a @click="toggleBookmarkMainLink">
<i class="fa-fw" :class="options.mainOpenOriginal ? 'fas fa-check-square' : 'far fa-square'"></i>Bookmark's title open original webpage instead of the cache
</a>
</yla-dialog>
<yla-dialog v-bind="dialog"></yla-dialog>
</div>
@ -224,6 +227,7 @@
listView: false,
nightMode: false,
showBookmarkID: false,
mainOpenOriginal: false,
},
dialogAbout: {
visible: false,
@ -340,6 +344,10 @@
this.options.showBookmarkID = !this.options.showBookmarkID;
localStorage.setItem('shiori-show-id', this.options.showBookmarkID ? '1' : '0');
},
toggleBookmarkMainLink() {
this.options.mainOpenOriginal = !this.options.mainOpenOriginal;
localStorage.setItem('shiori-main-original', this.options.mainOpenOriginal ? '1' : '0');
},
toggleEditMode() {
this.editMode = !this.editMode;
this.selected = [];
@ -713,17 +721,31 @@
parser = document.createElement('a');
parser.href = url;
return parser.hostname.replace(/^www\./g, '');
},
getBookLink(book, isMainLink) {
if ((this.options.mainOpenOriginal && isMainLink) ||
(!this.options.mainOpenOriginal && !isMainLink)) return book.url;
if (book.hasContent) return '/bookmark/' + book.id;
return null;
},
getBookLinkTitle(book, isMainLink) {
if ((this.options.mainOpenOriginal && isMainLink) ||
(!this.options.mainOpenOriginal && !isMainLink)) return 'View original';
if (book.hasContent) return 'View cache';
return null;
}
},
mounted() {
// Read config from local storage
var listView = localStorage.getItem('shiori-list-view'),
nightMode = localStorage.getItem('shiori-night-mode'),
showBookmarkID = localStorage.getItem('shiori-show-id');
showBookmarkID = localStorage.getItem('shiori-show-id'),
mainOpenOriginal = localStorage.getItem('shiori-main-original');
this.options.listView = listView === '1';
this.options.nightMode = nightMode === '1';
this.options.showBookmarkID = showBookmarkID === '1';
this.options.mainOpenOriginal = mainOpenOriginal === '1';
// Create bookmarklet
var shioriURL = location.href.replace(/\/+$/g, ''),

View File

@ -475,6 +475,10 @@ body {
overflow: hidden;
text-overflow: ellipsis;
line-height: 21px;
&:not([href]) {
cursor: default;
color: var(--colorLink);
}
}
}
}
@ -772,8 +776,12 @@ body {
cursor: pointer;
color: var(--color);
font-size: 0.9em;
padding-left: 24px;
position: relative;
i {
margin-right: 8px;
left: 0;
top: 2px;
position: absolute;
color: var(--color);
}
&:hover,