Ajoutez des fichiers projet.

This commit is contained in:
taywon18
2024-09-19 22:06:37 +02:00
parent 7420a47dc6
commit 70fe271ba4
39 changed files with 1605 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
@page "/counter"
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
}
}

42
Tagger/Pages/Error.cshtml Normal file
View File

@@ -0,0 +1,42 @@
@page
@model Tagger.Pages.ErrorModel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
</head>
<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;
namespace Tagger.Pages
{
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}

13
Tagger/Pages/Index.razor Normal file
View File

@@ -0,0 +1,13 @@
@page "/"
<PageTitle>Index</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new appss.
<SurveyPrompt Title="How is Blazor working for you?" />
@code{
}

78
Tagger/Pages/Page.razor Normal file
View File

@@ -0,0 +1,78 @@
@page "/page/{*Route}"
@inject PageProvider Pages;
@inject NavigationManager NavManager;
@if (CurrentPage is null)
{
<p>Page introuvable</p>
}
else
{
@((MarkupString)markdownHtml)
<hr />
<div hidden=@(!Editing)>
<MarkdownEditor @bind-Value="@markdownValue" ValueHTMLChanged="@OnMarkdownValueHTMLChanged" />
<button @onclick="Save">Sauvegarder</button>
<button @onclick="Delete">Supprimer</button>
</div>
<div hidden=@Editing>
<button @onclick="() => {Editing = true;}">Editer</button>
<button>Renommer</button>
</div>
}
@code {
[Parameter]
public string? Route { get; set; }
string markdownValue = "";
string markdownHtml ="";
bool Editing = false;
ElementReference Editor;
public MarkdownPage? CurrentPage { get; set; }
protected async override Task OnInitializedAsync()
{
await base.OnInitializedAsync();
if (Route is null)
return;
CurrentPage = Pages.Get(Route);
if (CurrentPage is null)
return;
markdownValue = CurrentPage.Content;
StateHasChanged();
}
Task OnMarkdownValueHTMLChanged(string value)
{
markdownHtml = value;
return Task.CompletedTask;
}
void Save()
{
if (CurrentPage is null)
return;
CurrentPage.Content = markdownValue;
Pages.Save(CurrentPage);
}
void Delete()
{
if (CurrentPage is null)
return;
Pages.Delete(CurrentPage.Title);
NavManager.NavigateTo("/page");
}
}

View File

@@ -0,0 +1,31 @@
@page "/page"
@inject PageProvider Pages;
@if (Paths is null)
{
<p>Chargement...</p>
}
else
{
@foreach(var p in Paths)
{
<a href="/page/@p">@p</a>
}
<button>Ajouter une page</button>
}
@code {
public string[]? Paths { get; set; } = null;
protected override void OnInitialized()
{
Paths = Pages.List().ToArray();
base.OnInitialized();
}
}

41
Tagger/Pages/_Host.cshtml Normal file
View File

@@ -0,0 +1,41 @@
@page "/"
@using Microsoft.AspNetCore.Components.Web
@namespace Tagger.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
<link href="css/site.css" rel="stylesheet" />
<link href="Tagger.styles.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png"/>
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
<link href="/_content/PSC.Blazor.Components.MarkdownEditor/css/markdowneditor.css" rel="stylesheet" />
<link href="/_content/PSC.Blazor.Components.MarkdownEditor/css/easymde.min.css" rel="stylesheet" />
</head>
<body>
<component type="typeof(App)" render-mode="ServerPrerendered" />
<div id="blazor-error-ui">
<environment include="Staging,Production">
An error has occurred. This application may no longer respond until reloaded.
</environment>
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.server.js"></script>
<script src="/_content/PSC.Blazor.Components.MarkdownEditor/js/easymde.min.js"></script>
<script src="/_content/PSC.Blazor.Components.MarkdownEditor/js/markdownEditor.js"></script>
</body>
</html>