#430 display poem naskban images for a category
This commit is contained in:
parent
b03deae151
commit
a0b791649b
@ -3668,17 +3668,33 @@ namespace RMuseum.Controllers
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> DeletePoemRelatedNaskbanImagesByNaskbanUrlAsync(string naskbanUrl)
|
||||
{
|
||||
var res = await _ganjoorService.DeletePoemRelatedNaskbanImagesByNaskbanUrlAsync(naskbanUrl);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
if (res.Result == false)
|
||||
return NotFound();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get category poem related images
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("cat/{id}/images")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PoemRelatedImageEx[]))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetCatPoemImagesAsync(int id)
|
||||
{
|
||||
var res = await _ganjoorService.GetCatPoemImagesAsync(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// extracting quoted poems
|
||||
|
||||
@ -49,4 +49,22 @@
|
||||
/// </summary>
|
||||
public bool IsTextOriginalSource { get; set; }
|
||||
}
|
||||
|
||||
public class PoemRelatedImageEx : PoemRelatedImage
|
||||
{
|
||||
/// <summary>
|
||||
/// poem id
|
||||
/// </summary>
|
||||
public int PoemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poem url
|
||||
/// </summary>
|
||||
public string PoemFullUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poem full title
|
||||
/// </summary>
|
||||
public string PoemFullTitle { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2022,6 +2022,13 @@
|
||||
<param name="naskbanUrl"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetCatPoemImagesAsync(System.Int32)">
|
||||
<summary>
|
||||
get category poem related images
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.StartExtractingQuotedPoems">
|
||||
<summary>
|
||||
extracting quoted poems
|
||||
@ -12154,6 +12161,21 @@
|
||||
is text original source
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.PoemRelatedImageEx.PoemId">
|
||||
<summary>
|
||||
poem id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.PoemRelatedImageEx.PoemFullUrl">
|
||||
<summary>
|
||||
poem url
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.PoemRelatedImageEx.PoemFullTitle">
|
||||
<summary>
|
||||
poem full title
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.PoemVerseOrder">
|
||||
<summary>
|
||||
poem + verse order
|
||||
@ -15904,6 +15926,13 @@
|
||||
<param name="naskbanUrl"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetCatPoemImagesAsync(System.Int32)">
|
||||
<summary>
|
||||
get category poem related images
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.StartFillingSectionsPoemFormats">
|
||||
<summary>
|
||||
filling poem formats
|
||||
@ -18922,6 +18951,13 @@
|
||||
<param name="naskbanUrl"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCatPoemImagesAsync(System.Int32)">
|
||||
<summary>
|
||||
get category poem related images
|
||||
</summary>
|
||||
<param name="catId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="P:RMuseum.Services.Implementation.GanjoorService.AggressiveCacheEnabled">
|
||||
<summary>
|
||||
aggressive cache
|
||||
|
||||
@ -1220,6 +1220,13 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> DeletePoemRelatedNaskbanImagesByNaskbanUrlAsync(string naskbanUrl);
|
||||
|
||||
/// <summary>
|
||||
/// get category poem related images
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<PoemRelatedImageEx[]>> GetCatPoemImagesAsync(int catId);
|
||||
|
||||
/// <summary>
|
||||
/// filling poem formats
|
||||
/// </summary>
|
||||
|
||||
@ -180,8 +180,8 @@ namespace RMuseum.Services.Implementation
|
||||
return await GetCatById(cat.Id, poems, mainSections);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get list of books
|
||||
/// </summary>
|
||||
@ -226,19 +226,19 @@ namespace RMuseum.Services.Implementation
|
||||
{
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
||||
using(Font font = new Font(Configuration.GetSection("Ganjoor")["BooksCoverTitleFontName"], float.Parse(Configuration.GetSection("Ganjoor")["BooksCoverTitleFontSize"])))
|
||||
using (Font font = new Font(Configuration.GetSection("Ganjoor")["BooksCoverTitleFontName"], float.Parse(Configuration.GetSection("Ganjoor")["BooksCoverTitleFontSize"])))
|
||||
{
|
||||
SizeF sz = g.MeasureString(book.BookName, font);
|
||||
using (SolidBrush brsh = new SolidBrush(Color.FromArgb(51, 0, 0)))
|
||||
g.DrawString(book.BookName, font, brsh, new PointF(200.0f - sz.Width / 2, 230.0f - sz.Height / 2));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
MemoryStream coverData = new MemoryStream();
|
||||
coverImg.Save(coverData, System.Drawing.Imaging.ImageFormat.Jpeg);
|
||||
coverData.Seek(0, SeekOrigin.Begin);
|
||||
RServiceResult<RImage> imageRes = await _imageFileService.Add(null, coverData, $"Book-{book.Id}", "CategoryImages");
|
||||
if(!string.IsNullOrEmpty(imageRes.ExceptionString))
|
||||
if (!string.IsNullOrEmpty(imageRes.ExceptionString))
|
||||
{
|
||||
return new RServiceResult<bool>(false, imageRes.ExceptionString);
|
||||
}
|
||||
@ -248,10 +248,10 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<bool>(false, imageRes.ExceptionString);
|
||||
}
|
||||
var finalRes = await SetCategoryExtraInfo(book.Id, book.BookName, imageRes.Result.Id, book.SumUpSubsGeoLocations, book.MapName);
|
||||
if(!string.IsNullOrEmpty(finalRes.ExceptionString))
|
||||
if (!string.IsNullOrEmpty(finalRes.ExceptionString))
|
||||
{
|
||||
return new RServiceResult<bool>(false, finalRes.ExceptionString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new RServiceResult<bool>(true);
|
||||
@ -728,7 +728,7 @@ namespace RMuseum.Services.Implementation
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<PublicRecitationViewModel[]>> GetPoemRecitations(int id)
|
||||
{
|
||||
bool loadFromExternalServer = bool.Parse(Configuration.GetSection("ExternalFTPServer")["LoadFromExternalServer"]);
|
||||
bool loadFromExternalServer = bool.Parse(Configuration.GetSection("ExternalFTPServer")["LoadFromExternalServer"]);
|
||||
var source =
|
||||
from audio in _context.Recitations
|
||||
join poem in _context.GanjoorPoems
|
||||
@ -756,7 +756,7 @@ namespace RMuseum.Services.Implementation
|
||||
Mp3SizeInBytes = audio.Mp3SizeInBytes,
|
||||
PublishDate = audio.ReviewDate,
|
||||
FileLastUpdated = audio.FileLastUpdated,
|
||||
Mp3Url = loadFromExternalServer ? audio.Mp3Url : $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3",
|
||||
Mp3Url = loadFromExternalServer ? audio.Mp3Url : $"{WebServiceUrl.Url}/api/audio/file/{audio.Id}.mp3",
|
||||
XmlText = $"{WebServiceUrl.Url}/api/audio/xml/{audio.Id}",
|
||||
PlainText = "", //poem.PlainText
|
||||
HtmlText = "",//poem.HtmlText
|
||||
@ -2210,7 +2210,7 @@ namespace RMuseum.Services.Implementation
|
||||
dbCorrection.Reviewed == true
|
||||
&&
|
||||
(
|
||||
dbCorrection.Result == CorrectionReviewResult.Approved || dbCorrection.RhythmResult == CorrectionReviewResult.Approved
|
||||
dbCorrection.Result == CorrectionReviewResult.Approved || dbCorrection.RhythmResult == CorrectionReviewResult.Approved
|
||||
|| dbCorrection.Rhythm2Result == CorrectionReviewResult.Approved || dbCorrection.RhymeLettersReviewResult == CorrectionReviewResult.Approved
|
||||
|| dbCorrection.PoemFormatReviewResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
@ -3484,9 +3484,9 @@ namespace RMuseum.Services.Implementation
|
||||
e.Accept = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -3679,7 +3679,7 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// manually add a duplicate for a poems
|
||||
@ -3778,7 +3778,7 @@ namespace RMuseum.Services.Implementation
|
||||
&&
|
||||
await _context.PinterestLinks.Where(l => l.GanjoorPostId == unsynchronized.GanjoorPostId && l.IsTextOriginalSource).AnyAsync() == false
|
||||
;
|
||||
if (false == await _context.PinterestLinks.Where(p => p.NaskbanLinkId == unsynchronized.Id).AnyAsync() )
|
||||
if (false == await _context.PinterestLinks.Where(p => p.NaskbanLinkId == unsynchronized.Id).AnyAsync())
|
||||
{
|
||||
PinterestLink link = new PinterestLink()
|
||||
{
|
||||
@ -3839,6 +3839,71 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get category poem related images
|
||||
/// </summary>
|
||||
/// <param name="catId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<PoemRelatedImageEx[]>> GetCatPoemImagesAsync(int catId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var museumSrc =
|
||||
from link in _context.GanjoorLinks.Include(l => l.Artifact).Include(l => l.Item).ThenInclude(i => i.Images)
|
||||
join poem in _context.GanjoorPoems
|
||||
on link.GanjoorPostId equals poem.Id
|
||||
where
|
||||
link.DisplayOnPage == true
|
||||
&&
|
||||
link.ReviewResult == ReviewResult.Approved
|
||||
&&
|
||||
poem.CatId == catId
|
||||
orderby poem.Id
|
||||
select new PoemRelatedImageEx()
|
||||
{
|
||||
PoemRelatedImageType = PoemRelatedImageType.MuseumLink,
|
||||
ThumbnailImageUrl = link.Item.Images.First().ExternalNormalSizeImageUrl.Replace("/norm/", "/thumb/").Replace("/orig/", "/thumb/"),
|
||||
TargetPageUrl = link.LinkToOriginalSource ? link.OriginalSourceUrl : $"https://museum.ganjoor.net/items/{link.Artifact.FriendlyUrl}/{link.Item.FriendlyUrl}",
|
||||
AltText = $"{link.Artifact.Name} » {link.Item.Name}",
|
||||
IsTextOriginalSource = link.IsTextOriginalSource,
|
||||
PoemId = poem.Id,
|
||||
PoemFullUrl = poem.FullUrl,
|
||||
PoemFullTitle = poem.FullTitle,
|
||||
};
|
||||
List<PoemRelatedImageEx> museumImages = await museumSrc.ToListAsync();
|
||||
|
||||
var externalSrc =
|
||||
from link in _context.PinterestLinks
|
||||
join poem in _context.GanjoorPoems
|
||||
on link.GanjoorPostId equals poem.Id
|
||||
where
|
||||
link.ReviewResult == ReviewResult.Approved
|
||||
&&
|
||||
poem.Id == catId
|
||||
orderby poem.Id
|
||||
select new PoemRelatedImageEx()
|
||||
{
|
||||
PoemRelatedImageType = PoemRelatedImageType.ExternalLink,
|
||||
ThumbnailImageUrl = link.LinkType == LinkType.Naskban ? link.PinterestImageUrl : link.Item.Images.First().ExternalNormalSizeImageUrl.Replace("/norm/", "/thumb/").Replace("/orig/", "/thumb/"),
|
||||
TargetPageUrl = link.PinterestUrl,
|
||||
AltText = link.AltText,
|
||||
IsTextOriginalSource = link.IsTextOriginalSource,
|
||||
PoemId = poem.Id,
|
||||
PoemFullUrl = poem.FullUrl,
|
||||
PoemFullTitle = poem.FullTitle,
|
||||
};
|
||||
|
||||
museumImages.AddRange(await externalSrc.AsNoTracking().ToListAsync());
|
||||
|
||||
return new RServiceResult<PoemRelatedImageEx[]>(museumImages.ToArray());
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<PoemRelatedImageEx[]>(null, exp.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// aggressive cache
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user