docs: #275 adding a page template for photos project
This commit is contained in:
parent
c99de47391
commit
9a2cc74920
60
GanjooRazor/Pages/Photos.cshtml
Normal file
60
GanjooRazor/Pages/Photos.cshtml
Normal file
@ -0,0 +1,60 @@
|
||||
@page
|
||||
@model GanjooRazor.Pages.PhotosModel
|
||||
@{
|
||||
Layout = null;
|
||||
}
|
||||
<!DOCTYPE html>
|
||||
<html lang="fa-IR" dir="rtl">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<title>
|
||||
@Html.Raw(ViewData["Title"])
|
||||
</title>
|
||||
<link href="/css/p8.css?version=32" 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" />
|
||||
<script src="/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script>
|
||||
var playerScrollLock = false;
|
||||
</script>
|
||||
<script src="/js/bk.js?version=21"></script>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div id="hdr">
|
||||
<h1><a href="/photos" title="گنجور"><img src="/image/gmg.gif" alt="تصاویر شاعران" class="home-logo" /></a></h1>
|
||||
</div>
|
||||
<div id="fa">
|
||||
<h2>
|
||||
تصاویر شاعران
|
||||
</h2>
|
||||
<div id="main">
|
||||
<div id="guides">
|
||||
<div class="clear-both">
|
||||
<input type="text" id="findpoet" placeholder="جستجوی شاعر" size="35" value="" oninput="onFindPoet(this.value)" />
|
||||
<div class="spacer" id="found-poets"></div>
|
||||
</div>
|
||||
<div class="century">
|
||||
فهرست شاعران
|
||||
</div>
|
||||
@foreach (var poet in Model.Poets)
|
||||
{
|
||||
<div class="poet" data-value="@poet.Nickname">
|
||||
<a href="/photos?p=@poet.FullUrl.Substring(1)" title="@poet.Name"><img src="@poet.ImageUrl" alt="@poet.Name" /></a>
|
||||
<div class="caption">
|
||||
<a href="/photos?p=@poet.FullUrl.Substring(1)">@poet.Nickname</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
<div class="spacer"></div>
|
||||
</div>
|
||||
</div>
|
||||
<partial name="_FooterPartial" model="null" />
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>>
|
||||
54
GanjooRazor/Pages/Photos.cshtml.cs
Normal file
54
GanjooRazor/Pages/Photos.cshtml.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Pages
|
||||
{
|
||||
public class PhotosModel : PageModel
|
||||
{
|
||||
public string LastError { get; set; }
|
||||
|
||||
public List<GanjoorPoetViewModel> Poets { get; set; }
|
||||
|
||||
private async Task<List<GanjoorPoetViewModel>> _PreparePoets()
|
||||
{
|
||||
var response = await _httpClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poets");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return new List<GanjoorPoetViewModel>();
|
||||
}
|
||||
var poets = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoetViewModel>>();
|
||||
|
||||
|
||||
foreach (var poet in poets)
|
||||
{
|
||||
poet.ImageUrl = $"{APIRoot.InternetUrl}{poet.ImageUrl}";
|
||||
}
|
||||
|
||||
return poets;
|
||||
}
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
ViewData["Title"] = "تصاویر شاعران گنجور";
|
||||
Poets = await _PreparePoets();
|
||||
return Page();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HttpClient instance
|
||||
/// </summary>
|
||||
private readonly HttpClient _httpClient;
|
||||
|
||||
|
||||
public PhotosModel(HttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,8 +8,8 @@
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"GoogleAnalyticsCode": "",
|
||||
"APIRoot": "http://localhost:3439",
|
||||
"GlobalAPIRoot": "http://localhost:3439",
|
||||
"APIRoot": "https://api.ganjoor.net",
|
||||
"GlobalAPIRoot": "https://api.ganjoor.net",
|
||||
"SiteUrl": "http://localhost:33081",
|
||||
"AggressiveCacheEnabled": "False",
|
||||
"ReadOnlyMode": "False",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user