docs: #287 UI for user suggested songs added

This commit is contained in:
Hamid Reza Mohammadi 2022-02-24 18:33:36 +03:30
parent 77094b5730
commit f8c4c25a02
25 changed files with 285 additions and 25 deletions

View File

@ -0,0 +1,116 @@
@page
@model GanjooRazor.Areas.User.Pages.MySuggestedSongsModel
@using DNTPersianUtils.Core
@{
Layout = "_UserPanelLayout";
ViewData["Title"] = "آهنگ‌های پیشنهادی من";
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
string color = "gray";
}
<h1>@ViewData["Title"]</h1>
@if (Model.LastError != "")
{
<h2>@Model.LastError</h2>
}
else
{
<p style="text-align:center">
@foreach (var paginationLink in Model.PaginationLinks)
{
if (!string.IsNullOrEmpty(paginationLink.Url))
{
<a href="@paginationLink.Url">@paginationLink.Name</a>
}
else
{
@paginationLink.Name
}
}
</p>
@if (Model.SuggestedSongs.Count == 0)
{
<p>
شما هنوز هیچ آهنگ مرتبطی را پیشنهاد نداده‌اید. برای آشنایی با نحوهٔ پیشنهاد آهنگ‌های مرتبط <a href="http://blog.ganjoor.net/1395/06/28/bptags/" target="_blank">اینجا</a> را ببینید.
</p>
}
@foreach (var suggestedSong in Model.SuggestedSongs)
{
if (color == "gray")
color = "white";
else
color = "gray";
<div style="background-color:@color" id="bookmark-@suggestedSong.Id">
<p>
وضعیت: @(suggestedSong.Rejected ? "رد شده" : suggestedSong.Approved ? "تأیید شده" : "بررسی نشده" )
</p>
@if (suggestedSong.Rejected)
{
<p>
دلیل رد: @suggestedSong.RejectionCause
</p>
}
@if (suggestedSong.BrokenLink)
{
<p>لینک آهنگ کار نمی‌کند.</p>
}
<p>
<a href="@($"/?p={suggestedSong.PoemId}")" target="_blank">مشاهدهٔ شعر مرتبط</a>
</p>
@if (!string.IsNullOrEmpty(suggestedSong.ArtistName))
{
<p>
خواننده: <a href="@Html.Raw(suggestedSong.ArtistUrl)" target="_blank">@suggestedSong.ArtistName</a>
</p>
}
@if (!string.IsNullOrEmpty(suggestedSong.AlbumName))
{
<p>
آلبوم: <a href="@Html.Raw(suggestedSong.AlbumUrl)" target="_blank">@suggestedSong.AlbumName</a>
</p>
}
<p>
آهنگ: <a href="@Html.Raw(suggestedSong.TrackUrl)" target="_blank">@suggestedSong.TrackName</a>
</p>
@if (!string.IsNullOrEmpty(suggestedSong.Description))
{
<p>توضیح: @suggestedSong.Description</p>
}
</div>
<hr />
}
<p style="text-align:center">
@foreach (var paginationLink in Model.PaginationLinks)
{
if (!string.IsNullOrEmpty(paginationLink.Url))
{
<a href="@paginationLink.Url">@paginationLink.Name</a>
}
else
{
@paginationLink.Name
}
}
</p>
}

View File

@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using DNTPersianUtils.Core;
using GanjooRazor.Utils;
using GSpotifyProxy.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RMuseum.Models.Ganjoor.ViewModels;
using RSecurityBackend.Models.Generic;
namespace GanjooRazor.Areas.User.Pages
{
public class MySuggestedSongsModel : PageModel
{
/// <summary>
/// Last Error
/// </summary>
public string LastError { get; set; }
/// <summary>
/// pagination links
/// </summary>
public List<NameIdUrlImage> PaginationLinks { get; set; }
public List<PoemMusicTrackViewModel> SuggestedSongs { get; set; }
public async Task<IActionResult> OnGetAsync()
{
if (string.IsNullOrEmpty(Request.Cookies["Token"]))
return Redirect("/");
LastError = "";
using (HttpClient secureClient = new HttpClient())
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
{
{
int pageNumber = 1;
if (!string.IsNullOrEmpty(Request.Query["page"]))
{
pageNumber = int.Parse(Request.Query["page"]);
}
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/song/mysuggestions/?PageNumber={pageNumber}&PageSize=20");
if (!response.IsSuccessStatusCode)
{
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
return Page();
}
SuggestedSongs = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<PoemMusicTrackViewModel>>();
string paginnationMetadata = response.Headers.GetValues("paging-headers").FirstOrDefault();
if (!string.IsNullOrEmpty(paginnationMetadata))
{
PaginationMetadata paginationMetadata = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata);
PaginationLinks = new List<NameIdUrlImage>();
if (paginationMetadata.totalPages > 1)
{
if (paginationMetadata.currentPage > 3)
{
PaginationLinks.Add
(
new NameIdUrlImage()
{
Name = "صفحهٔ اول",
Url = "/User/MySuggestedSongs/?page=1"
}
);
}
for (int i = (paginationMetadata.currentPage - 2); i <= (paginationMetadata.currentPage + 2); i++)
{
if (i >= 1 && i <= paginationMetadata.totalPages)
{
if (i == paginationMetadata.currentPage)
{
PaginationLinks.Add
(
new NameIdUrlImage()
{
Name = i.ToPersianNumbers(),
}
);
}
else
{
PaginationLinks.Add
(
new NameIdUrlImage()
{
Name = i.ToPersianNumbers(),
Url = $"/User/MySuggestedSongs/?page={i}"
}
);
}
}
}
if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2))
{
PaginationLinks.Add
(
new NameIdUrlImage()
{
Name = "... ",
}
);
PaginationLinks.Add
(
new NameIdUrlImage()
{
Name = "صفحهٔ آخر",
Url = $"/User/MySuggestedSongs/?page={paginationMetadata.totalPages}"
}
);
}
}
}
}
}
else
{
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
}
return Page();
}
}
}

View File

@ -15,7 +15,7 @@
گنجور » نمایش خوانش
</title>
<link href="~/dist/skin/pink.flag/css/jplayer.pink.flag.min.css" rel="stylesheet" type="text/css" />
<link href="~/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="~/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />
<script>

View File

@ -11,7 +11,7 @@
<title>انتخاب قطعهٔ موسیقی مرتبط با شعر از بیپتونز</title>
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/spotify.css" rel="stylesheet" type="text/css" />
<script src="/lib/jquery/dist/jquery.min.js"></script>

View File

@ -14,7 +14,7 @@
@ViewData["Title"]
</title>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />

View File

@ -10,7 +10,7 @@
<title>انتخاب قطعه‌ای از برنامهٔ گلها مرتبط با این شعر</title>
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/spotify.css" rel="stylesheet" type="text/css" />
<script src="/lib/jquery/dist/jquery.min.js"></script>
<script src="~/js/golha.js"></script>

View File

@ -12,7 +12,7 @@
<title>
@Html.Raw(ViewData["Title"])
</title>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/fab.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />

View File

@ -13,7 +13,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="hdr">

View File

@ -12,7 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="شاعران و نویسندگان گنجور روی نقشهٔ جغرافیایی" />
<meta charset="utf-8" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/css/leaflet.css" />
<style>
.leaflet-container {

View File

@ -11,7 +11,7 @@
<title>
@Html.Raw(ViewData["Title"])
</title>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/fab.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />

View File

@ -11,7 +11,7 @@
<title>پیشنهاد شعر مرتبط با تصویر</title>
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/spotify.css" rel="stylesheet" type="text/css" />
<script src="/lib/jquery/dist//jquery.min.js"></script>

View File

@ -12,7 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex, nofollow" />
<title>اطلاعات رتبه‌بندی خوانش‌های شعر</title>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
</head>
<body>

View File

@ -11,7 +11,7 @@
<meta name="robots" content="noindex, nofollow" />
<title>درخواست حذف حاشیه</title>
<script src="/lib/jquery/dist/jquery.min.js"></script>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<style>
label {
width: 100px;

View File

@ -13,7 +13,7 @@
<meta name="robots" content="noindex, nofollow" />
<title>گزارش خطا در خوانش</title>
<script src="/lib/jquery/dist/jquery.min.js"></script>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<style>
label {
width: 100px;

View File

@ -12,7 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="hdr">

View File

@ -15,7 +15,7 @@
@ViewData["Title"]
</title>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/fab.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />

View File

@ -10,7 +10,7 @@
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link href="/dist/skin/blue.monday/css/jplayer.blue.monday.min.css" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/fab.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />

View File

@ -9,7 +9,7 @@
</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/fab.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />
@ -279,14 +279,18 @@
<a class="nav-link text-dark" asp-area="User" asp-page="/Edits">ویرایش‌‌های من</a>
</li>
<li class="nav-item">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="User" asp-page="/UpVotedRecitations">خوانش‌های نشان شده</a>
</li>
<li class="nav-item">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="User" asp-page="/History">ادامهٔ مطالعه</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="User" asp-page="/MySuggestedSongs">آهنگ‌های پیشنهادی من</a>
</li>
@if (ViewData.ContainsKey("ganjoor-songrevu"))
{
<li class="nav-item">

View File

@ -12,7 +12,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="hdr">

View File

@ -11,7 +11,7 @@
<title>انتخاب قطعهٔ موسیقی مرتبط با شعر از اسپاتیفای</title>
<meta name="robots" content="noindex, nofollow" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link href="/css/spotify.css" rel="stylesheet" type="text/css" />
<script src="/lib/jquery/dist/jquery.min.js"></script>

View File

@ -14,7 +14,7 @@
گنجور » برگردان‌ها و نویس‌های شعر
</title>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<link href="~/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="~/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />
</head>

View File

@ -14,7 +14,7 @@
@ViewData["Title"]
</title>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />

View File

@ -15,7 +15,7 @@
@ViewData["Title"]
</title>
<link href="/css/p8.css?version=35" rel="stylesheet" type="text/css" />
<link href="/css/p8.css?version=36" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="search" type="application/opensearchdescription+xml" title="گنجور" href="https://ganjoor.net/search.xml" />

View File

@ -115,7 +115,6 @@ h1 a img {
a {
text-decoration: none;
color: #c44
}
#fa {
@ -126,6 +125,10 @@ a {
background: transparent url(/image/bk.gif) top center repeat scroll;
}
#fa a {
color: #c44;
}
h2 {
font-family: Vazir;

View File

@ -1327,7 +1327,7 @@ namespace RMuseum.Controllers
[HttpGet]
[Route("song/mysuggestions")]
[Authorize]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorPoemCorrectionViewModel>))]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<PoemMusicTrackViewModel>))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
public async Task<IActionResult> GetUserSuggestedSongs([FromQuery] PagingParameterModel paging)
{