#214 web share corrent poem

This commit is contained in:
Hamid Reza Mohammadi 2021-10-01 19:43:38 +03:30
parent 99e4e5e7a0
commit 7d4d38507d
3 changed files with 42 additions and 24 deletions

View File

@ -35,12 +35,13 @@
{
if (Model.IsPoemPage)
{
<script>
<script>
$(document).ready(function () {
checkWebShareSupport();
btshmr(@Model.GanjoorPage.Id);
checkIfBookmarked(@Model.GanjoorPage.Id);
});
</script>
</script>
}
<script type="application/ld+json">
{

View File

@ -111,7 +111,7 @@
}
}
<article>
<article id="garticle">
@{
if (!Model.IsPoemPage && Model.GanjoorPage.PoetOrCat == null)
@ -284,7 +284,7 @@
<a href="@Html.Raw(Model.GanjoorPage.PoetOrCat.Cat.FullUrl + "/" + Model.GanjoorPage.Poem.Next.UrlSlug)">@Html.Raw(Model.GanjoorPage.Poem.Next.Title): @Html.Raw(Model.GanjoorPage.Poem.Next.Excerpt)</a><span> &raquo;</span>
}
else
if (Model.GanjoorPage.Poem.Category.Cat.Next != null)
if (Model.GanjoorPage.Poem.Category.Cat.Next != null)
{
<a href="@Model.GanjoorPage.Poem.Category.Cat.Next.FullUrl">@Model.GanjoorPage.Poem.Category.Cat.Next.Title</a><span> &raquo;</span>
}
@ -295,7 +295,7 @@
<span>&laquo; </span><a href="@Html.Raw(Model.GanjoorPage.PoetOrCat.Cat.FullUrl + "/" +Model.GanjoorPage.Poem.Previous.UrlSlug)">@Html.Raw(Model.GanjoorPage.Poem.Previous.Title) :@Html.Raw(Model.GanjoorPage.Poem.Previous.Excerpt)</a>
}
else
if (Model.GanjoorPage.Poem.Category.Cat.Previous != null)
if (Model.GanjoorPage.Poem.Category.Cat.Previous != null)
{
<span>&laquo; </span><a href="@Model.GanjoorPage.Poem.Category.Cat.Previous.FullUrl">@Model.GanjoorPage.Poem.Category.Cat.Previous.Title</a>
}
@ -333,31 +333,30 @@
@if (Model.LoggedIn)
{
<text> | <a role="button" id="bookmark" style="cursor: pointer;" onclick="switchBookmark(@Model.GanjoorPage.Id, 0)" title="نشانه‌گذاری / حذف نشانه"><i class="pageicons" id="bookmark-icon">star_border</i></a></text>
}
@if (Model.GanjoorPage.Poem.GanjoorMetre != null)
{
<text> | <small>وزن: <a href="@Html.Raw($"/vazn/?v={Uri.EscapeUriString(Model.GanjoorPage.Poem.GanjoorMetre.Rhythm)}&amp;a={Model.GanjoorPage.PoetOrCat.Poet.Id}")">@Html.Raw(Model.GanjoorPage.Poem.GanjoorMetre.Rhythm)</a></small></text>
}
@if (Model.GanjoorPage.Poem.GanjoorMetre != null)
{
<text> | <small>وزن: <a href="@Html.Raw($"/vazn/?v={Uri.EscapeUriString(Model.GanjoorPage.Poem.GanjoorMetre.Rhythm)}&amp;a={Model.GanjoorPage.PoetOrCat.Poet.Id}")">@Html.Raw(Model.GanjoorPage.Poem.GanjoorMetre.Rhythm)</a></small></text>
@if (!string.IsNullOrEmpty(Model.GanjoorPage.Poem.RhymeLetters))
{
<text> | <small><i class="pageicons">search</i> <a href="@Html.Raw($"/simi/?v={Uri.EscapeUriString(Model.GanjoorPage.Poem.GanjoorMetre.Rhythm)}&amp;g={Uri.EscapeUriString(Model.GanjoorPage.Poem.RhymeLetters)}")">شعرهای مشابه (وزن و قافیه)</a></small></text>
}
}
@if (!string.IsNullOrEmpty(Model.GanjoorPage.Poem.OldTag))
{
<text> | <small><a href="@Html.Raw($"{Model.GanjoorPage.Poem.OldTagPageUrl}/")">@Html.Raw(Model.GanjoorPage.Poem.OldTag)</a></small></text>
}
@if (!string.IsNullOrEmpty(Model.GanjoorPage.Poem.SourceName))
{
<text> | <small>منبع اولیه: <a href="@Html.Raw($"/sources/{Model.GanjoorPage.Poem.SourceUrlSlug}/")">@Html.Raw(Model.GanjoorPage.Poem.SourceName)</a></small></text>
}
| <small><a href="@Html.Raw($"http://www.facebook.com/sharer.php?u=https://ganjoor.net{Model.GanjoorPage.FullUrl}&amp;t={Uri.EscapeUriString(Model.GanjoorPage.FullTitle)}/")">ارسال به فیس‌بوک</a></small>
@if (!string.IsNullOrEmpty(Model.GanjoorPage.Poem.OldTag))
{
<text> | <small><a href="@Html.Raw($"{Model.GanjoorPage.Poem.OldTagPageUrl}/")">@Html.Raw(Model.GanjoorPage.Poem.OldTag)</a></small></text>
}
@if (!string.IsNullOrEmpty(Model.GanjoorPage.Poem.SourceName))
{
<text> | <small>منبع اولیه: <a href="@Html.Raw($"/sources/{Model.GanjoorPage.Poem.SourceUrlSlug}/")">@Html.Raw(Model.GanjoorPage.Poem.SourceName)</a></small></text>
}
<span id="share_span">| <a role="button" id="share" style="cursor: pointer;" onclick="webSharePoem()" title="همرسانی"><i class="pageicons" id="share-icon">share</i></a></span>
@if (Model.LoggedIn)
{
<text>| <small><a href="@Html.Raw($"/trans?p={Model.GanjoorPage.Id}")" onclick="wpopen(this.href); return false" title="برگردان‌ها و نویسش‌ها" class="comments-link"><i class="pageicons">translate</i></a></small></text>
}
@if (Model.LoggedIn)
{
<text>| <small><a href="@Html.Raw($"/trans?p={Model.GanjoorPage.Id}")" onclick="wpopen(this.href); return false" class="comments-link"><i class="pageicons">translate</i></a></small></text>
}
</p>
</p>
<h3>این شعر را چه کسی در کدام آهنگ خوانده است؟</h3>
@if (Model.GanjoorPage.Poem.Songs.Length == 0)
{

View File

@ -509,6 +509,7 @@ function switchBookmark(poemId, coupletIndex) {
}
function checkIfBookmarked(poemId) {
if (document.getElementById('bookmark-icon') == null) return;
setTimeout(function () {
$.ajax({
type: "GET",
@ -526,4 +527,21 @@ function checkIfBookmarked(poemId) {
},
});
}, 1);
}
function checkWebShareSupport() {
if (navigator.share === undefined) {
document.getElementById('share_span').styl;e.display = 'none';
}
}
async function webSharePoem() {
var title = document.title;
var text = document.getElementById('garticle').text;
var url = window.location.href;
try {
await navigator.share({ title, text, url });
} catch (error) {
logError('Error sharing: ' + error);
}
}