docs: #307 Simi page is complete
This commit is contained in:
parent
36a7f52bde
commit
b315f2f3e8
@ -13,20 +13,7 @@
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
function doSearchInRhythmsCombo(selectSearchId, rhythmnewId){
|
||||
var value = document.getElementById(selectSearchId).value;
|
||||
var options = document.getElementById(rhythmnewId).options
|
||||
for(var i=0; i < options.length; i++){
|
||||
if(options[i].value.indexOf(value) != -1){
|
||||
document.getElementById(rhythmnewId).value = options[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetRhythm(rhythmnewId) {
|
||||
document.getElementById('rhythm-new').value = '';
|
||||
}
|
||||
|
||||
|
||||
function savePoemCorrections(id, verseCount) {
|
||||
var verseOrderText = [];
|
||||
|
||||
@ -149,7 +149,7 @@
|
||||
</p>
|
||||
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/js/bk.js?version=24"></script>
|
||||
<script src="~/js/bk.js?version=25"></script>
|
||||
<script src="~/js/jplayersupport.js"></script>
|
||||
<script src="~/js/vaabd.js"></script>
|
||||
<script src="~/dist/jplayer/jquery.jplayer.min.js"></script>
|
||||
|
||||
@ -104,7 +104,7 @@
|
||||
</div>
|
||||
|
||||
<script src="/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="/js/bk.js?version=24"></script>
|
||||
<script src="/js/bk.js?version=25"></script>
|
||||
<script src="/js/vaabd.js"></script>
|
||||
|
||||
@if (!string.IsNullOrEmpty(ViewData["GoogleAnalyticsCode"].ToString()))
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
<script>
|
||||
var playerScrollLock = false;
|
||||
</script>
|
||||
<script src="/js/bk.js?version=24"></script>
|
||||
<script src="/js/bk.js?version=25"></script>
|
||||
|
||||
@if(Model.GanjoorPage != null && Model.GanjoorPage.NoIndex)
|
||||
{
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<script>
|
||||
var playerScrollLock = false;
|
||||
</script>
|
||||
<script src="/js/bk.js?version=24"></script>
|
||||
<script src="/js/bk.js?version=25"></script>
|
||||
|
||||
@if (Model.Poet != null)
|
||||
{
|
||||
|
||||
@ -187,7 +187,7 @@
|
||||
</div>
|
||||
|
||||
<script src="/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="/js/bk.js?version=24"></script>
|
||||
<script src="/js/bk.js?version=25"></script>
|
||||
<script src="/js/vaabd.js"></script>
|
||||
|
||||
@if (!string.IsNullOrEmpty(ViewData["GoogleAnalyticsCode"].ToString()))
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.LastError))
|
||||
{
|
||||
@Model.LastError
|
||||
@Html.Raw(Model.LastError)
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -90,16 +90,77 @@
|
||||
|
||||
<div id="fa">
|
||||
|
||||
|
||||
|
||||
<div id="maincnt">
|
||||
|
||||
<div class="spacer"> </div>
|
||||
<div class="sitem actionbox">
|
||||
<div class="related-images-frame">
|
||||
<form method="get" id="simiform">
|
||||
|
||||
@if (Model.Poems == null)
|
||||
<select name="a" id="a" class="width-100per">
|
||||
@{
|
||||
if (Model.PoetId != 0)
|
||||
{
|
||||
<option value="0">در آثار همهٔ سخنوران</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="0" selected>در آثار همهٔ سخنوران</option>
|
||||
}
|
||||
|
||||
if (Model.Poets != null)
|
||||
{
|
||||
foreach (RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetViewModel poet in Model.Poets)
|
||||
{
|
||||
if (poet.Id == Model.PoetId)
|
||||
{
|
||||
<option value="@poet.Id" selected>@poet.Name</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@poet.Id">@poet.Name</option>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</select>
|
||||
|
||||
<label for="v" class="width-100per">وزن:</label>
|
||||
<input class="width-100per" type="text" id="select-search" placeholder="@Model.Metre" oninput="doSearchInRhythmsCombo('select-search', 'v')" list="inputRhythms" autocomplete="off" size="50" />
|
||||
<datalist id="inputRhythms">
|
||||
@if (Model.RhythmsByVerseCount != null)
|
||||
@foreach (var rhythm in Model.RhythmsByVerseCount)
|
||||
{
|
||||
<option value="@rhythm.Rhythm">@rhythm.Rhythm</option>
|
||||
}
|
||||
</datalist>
|
||||
<select id="v" name="v" class="width-100per">
|
||||
@foreach (var rhythm in Model.RhythmsAlphabetically)
|
||||
{
|
||||
if (Model.Metre == rhythm.Rhythm)
|
||||
{
|
||||
<option value="@rhythm.Rhythm" selected>@(rhythm.Rhythm == "" ? "هیچکدام" : rhythm.Rhythm)</option>
|
||||
}
|
||||
else
|
||||
{
|
||||
<option value="@rhythm.Rhythm">@(rhythm.Rhythm == "" ? "هیچکدام" : rhythm.Rhythm)</option>
|
||||
}
|
||||
|
||||
}
|
||||
</select>
|
||||
|
||||
<label for="g" class="width-100per">قافیه:</label>
|
||||
<input type="text" name="g" id="g" class="width-100per" value="@Model.Rhyme" placeholder="حروف قافیه" />
|
||||
|
||||
<input type="submit" class="width-100per" value="اعمال ورودیها" />
|
||||
|
||||
|
||||
</form>
|
||||
</div><!-- related-images-frame -->
|
||||
</div> <!-- comments-like-div -->
|
||||
@if (Model.Poems == null || Model.Poems.Count == 0)
|
||||
{
|
||||
<div class="poem">
|
||||
<h2>شعری با مشخصات مورد نظر شما پیدا نشد.</h2>
|
||||
<div class="sitem">
|
||||
<p>شعری با مشخصات مورد نظر شما پیدا نشد.</p>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
@ -140,7 +201,7 @@
|
||||
</div>
|
||||
|
||||
<script src="/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="/js/bk.js?version=24"></script>
|
||||
<script src="/js/bk.js?version=25"></script>
|
||||
<script src="/js/vaabd.js"></script>
|
||||
|
||||
@if (!string.IsNullOrEmpty(ViewData["GoogleAnalyticsCode"].ToString()))
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using DNTPersianUtils.Core;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -11,8 +9,8 @@ using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RMuseum.Services.Implementation;
|
||||
using RMuseum.Utils;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
|
||||
@ -117,6 +115,37 @@ namespace GanjooRazor.Pages
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// rhythms alphabetically
|
||||
/// </summary>
|
||||
public GanjoorMetre[] RhythmsAlphabetically { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// rhythms by frequency
|
||||
/// </summary>
|
||||
public GanjoorMetre[] RhythmsByVerseCount { get; set; }
|
||||
|
||||
public async Task<IActionResult> OnGetPoetInformationAsync(int id)
|
||||
{
|
||||
if (id == 0)
|
||||
return new OkObjectResult(null);
|
||||
var cacheKey = $"/api/ganjoor/poet/{id}";
|
||||
if (!_memoryCache.TryGetValue(cacheKey, out GanjoorPoetCompleteViewModel poet))
|
||||
{
|
||||
var poetResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poet/{id}");
|
||||
if (!poetResponse.IsSuccessStatusCode)
|
||||
{
|
||||
return BadRequest(JsonConvert.DeserializeObject<string>(await poetResponse.Content.ReadAsStringAsync()));
|
||||
}
|
||||
poet = JObject.Parse(await poetResponse.Content.ReadAsStringAsync()).ToObject<GanjoorPoetCompleteViewModel>();
|
||||
if (AggressiveCacheEnabled)
|
||||
{
|
||||
_memoryCache.Set(cacheKey, poet);
|
||||
}
|
||||
}
|
||||
return new OkObjectResult(poet);
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]);
|
||||
@ -144,6 +173,25 @@ namespace GanjooRazor.Pages
|
||||
return Page();
|
||||
}
|
||||
|
||||
var rhythmResponse = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/rhythms?sortOnVerseCount=true");
|
||||
if (!rhythmResponse.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await rhythmResponse.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
|
||||
RhythmsByVerseCount = JsonConvert.DeserializeObject<GanjoorMetre[]>(await rhythmResponse.Content.ReadAsStringAsync());
|
||||
|
||||
List<GanjoorMetre> rhythmsByVerseCount = new List<GanjoorMetre>(RhythmsByVerseCount);
|
||||
rhythmsByVerseCount.Sort((a, b) => a.Rhythm.CompareTo(b.Rhythm));
|
||||
rhythmsByVerseCount.Insert(0, new GanjoorMetre()
|
||||
{
|
||||
Rhythm = ""
|
||||
}
|
||||
);
|
||||
|
||||
RhythmsAlphabetically = rhythmsByVerseCount.ToArray();
|
||||
|
||||
int pageNumber = 1;
|
||||
if (!string.IsNullOrEmpty(Request.Query["page"]))
|
||||
{
|
||||
@ -153,6 +201,11 @@ namespace GanjooRazor.Pages
|
||||
Metre = Request.Query["v"];
|
||||
Rhyme = Request.Query["g"];
|
||||
|
||||
if(!string.IsNullOrEmpty(Rhyme))
|
||||
{
|
||||
Rhyme = Rhyme.Replace(" ", "");
|
||||
}
|
||||
|
||||
string title = "شعرها یا ابیات ";
|
||||
|
||||
if (PoetId != 0)
|
||||
|
||||
@ -936,4 +936,19 @@ function CheckIfHasNotificationsForHomePage() {
|
||||
},
|
||||
});
|
||||
}, 1);
|
||||
}
|
||||
|
||||
function doSearchInRhythmsCombo(selectSearchId, rhythmnewId) {
|
||||
var value = document.getElementById(selectSearchId).value;
|
||||
var options = document.getElementById(rhythmnewId).options
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
if (options[i].value.indexOf(value) != -1) {
|
||||
document.getElementById(rhythmnewId).value = options[i].value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetRhythm(rhythmnewId) {
|
||||
document.getElementById(rhythmnewId).value = '';
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user