Initial TafsirQuran app with Gitea CI/CD deploy to k3s.
build-and-deploy / deploy (push) Successful in 10m50s

Blazor UI + ASP.NET API + Postgres; push to main builds images and rolls out namespace tafsirquran.
This commit is contained in:
2026-10-09 21:50:37 +03:30
commit 7f06856f45
124 changed files with 4729 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
namespace TafsirQuran.Api.Auth;
public class JwtOptions
{
public const string SectionName = "Jwt";
public string Key { get; set; } = "TafsirQuran-Dev-Secret-Key-Change-In-Production-32+";
public string Issuer { get; set; } = "TafsirQuran";
public string Audience { get; set; } = "TafsirQuran";
public int ExpireMinutes { get; set; } = 60 * 24 * 30;
}
@@ -0,0 +1,41 @@
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using TafsirQuran.Domain.Entities;
namespace TafsirQuran.Api.Auth;
public class JwtTokenService(IOptions<JwtOptions> options)
{
private readonly JwtOptions _options = options.Value;
public string CreateToken(AppUser user)
{
var claims = new List<Claim>
{
new(JwtRegisteredClaimNames.Sub, user.Id.ToString()),
new(JwtRegisteredClaimNames.Email, user.Email),
new("display_name", user.DisplayName)
};
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_options.Key));
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
var token = new JwtSecurityToken(
issuer: _options.Issuer,
audience: _options.Audience,
claims: claims,
expires: DateTime.UtcNow.AddMinutes(_options.ExpireMinutes),
signingCredentials: creds);
return new JwtSecurityTokenHandler().WriteToken(token);
}
public static Guid? GetUserId(ClaimsPrincipal user)
{
var sub = user.FindFirstValue(JwtRegisteredClaimNames.Sub)
?? user.FindFirstValue(ClaimTypes.NameIdentifier);
return Guid.TryParse(sub, out var id) ? id : null;
}
}
@@ -0,0 +1,80 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using TafsirQuran.Api.Auth;
using TafsirQuran.Domain.Entities;
using TafsirQuran.Infrastructure.Persistence;
using TafsirQuran.Shared.Dtos;
namespace TafsirQuran.Api.Endpoints;
public static class AuthEndpoints
{
public static RouteGroupBuilder MapAuthEndpoints(this WebApplication app)
{
var group = app.MapGroup("/api/auth");
group.MapPost("/register", async (AuthRequest request, AppDbContext db, JwtTokenService jwt, CancellationToken ct) =>
{
if (string.IsNullOrWhiteSpace(request.Email) || string.IsNullOrWhiteSpace(request.Password))
return Results.BadRequest("ایمیل و رمز عبور لازم است");
var email = request.Email.Trim().ToLowerInvariant();
if (await db.Users.AnyAsync(u => u.Email == email, ct))
return Results.Conflict("این ایمیل قبلاً ثبت شده است");
var user = new AppUser
{
Email = email,
DisplayName = string.IsNullOrWhiteSpace(request.DisplayName) ? email.Split('@')[0] : request.DisplayName!.Trim(),
PasswordHash = BCrypt.Net.BCrypt.HashPassword(request.Password)
};
db.Users.Add(user);
await db.SaveChangesAsync(ct);
var token = jwt.CreateToken(user);
return Results.Ok(new AuthResponse(user.Id, user.Email, user.DisplayName, token));
});
group.MapPost("/login", async (AuthRequest request, AppDbContext db, JwtTokenService jwt, CancellationToken ct) =>
{
var email = request.Email.Trim().ToLowerInvariant();
var user = await db.Users.FirstOrDefaultAsync(u => u.Email == email, ct);
if (user is null || !BCrypt.Net.BCrypt.Verify(request.Password, user.PasswordHash))
return Results.Unauthorized();
var token = jwt.CreateToken(user);
return Results.Ok(new AuthResponse(user.Id, user.Email, user.DisplayName, token));
});
group.MapPost("/logout", () => Results.NoContent());
group.MapGet("/me", async (ClaimsPrincipal principal, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(principal);
if (userId is null)
return Results.Ok(new UserStatusDto(false, null, null, null));
var user = await db.Users.AsNoTracking().FirstOrDefaultAsync(u => u.Id == userId, ct);
if (user is null)
return Results.Ok(new UserStatusDto(false, null, null, null));
return Results.Ok(new UserStatusDto(true, user.Id, user.Email, user.DisplayName));
}).RequireAuthorization();
// Allow anonymous me check without 401
group.MapGet("/status", async (ClaimsPrincipal principal, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(principal);
if (userId is null)
return Results.Ok(new UserStatusDto(false, null, null, null));
var user = await db.Users.AsNoTracking().FirstOrDefaultAsync(u => u.Id == userId, ct);
if (user is null)
return Results.Ok(new UserStatusDto(false, null, null, null));
return Results.Ok(new UserStatusDto(true, user.Id, user.Email, user.DisplayName));
});
return group;
}
}
@@ -0,0 +1,63 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using TafsirQuran.Api.Auth;
using TafsirQuran.Api.Mapping;
using TafsirQuran.Domain.Entities;
using TafsirQuran.Infrastructure.Persistence;
using TafsirQuran.Shared.Dtos;
namespace TafsirQuran.Api.Endpoints;
public static class BookmarkEndpoints
{
public static RouteGroupBuilder MapBookmarkEndpoints(this WebApplication app)
{
var group = app.MapGroup("/api/bookmarks");
group.MapGet("/", async (string deviceId, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(user);
var items = await db.Bookmarks.AsNoTracking()
.Include(b => b.Episode).ThenInclude(e => e.Surah)
.Where(b => b.DeviceId == deviceId || (userId.HasValue && b.UserId == userId))
.OrderByDescending(b => b.CreatedAt)
.ToListAsync(ct);
return Results.Ok(items.Select(b => new BookmarkDto(
b.Id, b.EpisodeId, b.Note, b.CreatedAt, EpisodeMapper.ToListItem(b.Episode))).ToList());
});
group.MapPost("/", async (ToggleEpisodeRequest request, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(user);
var exists = await db.Bookmarks.AnyAsync(b =>
b.EpisodeId == request.EpisodeId &&
(b.DeviceId == request.DeviceId || (userId.HasValue && b.UserId == userId)), ct);
if (exists) return Results.NoContent();
db.Bookmarks.Add(new Bookmark
{
DeviceId = request.DeviceId,
UserId = userId,
EpisodeId = request.EpisodeId,
Note = request.Note
});
await db.SaveChangesAsync(ct);
return Results.Created($"/api/bookmarks/{request.EpisodeId}", null);
});
group.MapDelete("/{episodeId:guid}", async (Guid episodeId, string deviceId, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(user);
var items = await db.Bookmarks
.Where(b => b.EpisodeId == episodeId &&
(b.DeviceId == deviceId || (userId.HasValue && b.UserId == userId)))
.ToListAsync(ct);
db.Bookmarks.RemoveRange(items);
await db.SaveChangesAsync(ct);
return Results.NoContent();
});
return group;
}
}
@@ -0,0 +1,62 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using TafsirQuran.Api.Auth;
using TafsirQuran.Api.Mapping;
using TafsirQuran.Domain.Entities;
using TafsirQuran.Infrastructure.Persistence;
using TafsirQuran.Shared.Dtos;
namespace TafsirQuran.Api.Endpoints;
public static class FavoriteEndpoints
{
public static RouteGroupBuilder MapFavoriteEndpoints(this WebApplication app)
{
var group = app.MapGroup("/api/favorites");
group.MapGet("/", async (string deviceId, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(user);
var items = await db.Favorites.AsNoTracking()
.Include(f => f.Episode).ThenInclude(e => e.Surah)
.Where(f => f.DeviceId == deviceId || (userId.HasValue && f.UserId == userId))
.OrderByDescending(f => f.CreatedAt)
.ToListAsync(ct);
return Results.Ok(items.Select(f => new FavoriteDto(
f.Id, f.EpisodeId, f.CreatedAt, EpisodeMapper.ToListItem(f.Episode))).ToList());
});
group.MapPost("/", async (ToggleEpisodeRequest request, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(user);
var exists = await db.Favorites.AnyAsync(f =>
f.EpisodeId == request.EpisodeId &&
(f.DeviceId == request.DeviceId || (userId.HasValue && f.UserId == userId)), ct);
if (exists) return Results.NoContent();
db.Favorites.Add(new Favorite
{
DeviceId = request.DeviceId,
UserId = userId,
EpisodeId = request.EpisodeId
});
await db.SaveChangesAsync(ct);
return Results.Created($"/api/favorites/{request.EpisodeId}", null);
});
group.MapDelete("/{episodeId:guid}", async (Guid episodeId, string deviceId, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(user);
var items = await db.Favorites
.Where(f => f.EpisodeId == episodeId &&
(f.DeviceId == deviceId || (userId.HasValue && f.UserId == userId)))
.ToListAsync(ct);
db.Favorites.RemoveRange(items);
await db.SaveChangesAsync(ct);
return Results.NoContent();
});
return group;
}
}
@@ -0,0 +1,76 @@
using System.Security.Claims;
using Microsoft.EntityFrameworkCore;
using TafsirQuran.Api.Auth;
using TafsirQuran.Api.Mapping;
using TafsirQuran.Domain.Entities;
using TafsirQuran.Infrastructure.Persistence;
using TafsirQuran.Shared.Dtos;
namespace TafsirQuran.Api.Endpoints;
public static class ProgressEndpoints
{
public static RouteGroupBuilder MapProgressEndpoints(this WebApplication app)
{
var group = app.MapGroup("/api/progress");
group.MapGet("/", async (string deviceId, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
var userId = JwtTokenService.GetUserId(user);
var query = db.ListeningProgresses.AsNoTracking().Include(p => p.Episode).ThenInclude(e => e.Surah).AsQueryable();
ListeningProgress? progress = null;
if (userId.HasValue)
{
progress = await query.Where(p => p.UserId == userId).OrderByDescending(p => p.UpdatedAt).FirstOrDefaultAsync(ct);
}
progress ??= await query.Where(p => p.DeviceId == deviceId).OrderByDescending(p => p.UpdatedAt).FirstOrDefaultAsync(ct);
if (progress is null) return Results.NoContent();
return Results.Ok(new ProgressDto(
progress.EpisodeId,
progress.PositionSeconds,
progress.UpdatedAt,
EpisodeMapper.ToListItem(progress.Episode)));
});
group.MapPut("/", async (UpsertProgressRequest request, ClaimsPrincipal user, AppDbContext db, CancellationToken ct) =>
{
if (string.IsNullOrWhiteSpace(request.DeviceId))
return Results.BadRequest("deviceId required");
var userId = JwtTokenService.GetUserId(user);
var existing = await db.ListeningProgresses
.Where(p => p.DeviceId == request.DeviceId || (userId.HasValue && p.UserId == userId))
.OrderByDescending(p => p.UpdatedAt)
.FirstOrDefaultAsync(ct);
if (existing is null)
{
existing = new ListeningProgress
{
DeviceId = request.DeviceId,
UserId = userId,
EpisodeId = request.EpisodeId,
PositionSeconds = request.PositionSeconds
};
db.ListeningProgresses.Add(existing);
}
else
{
existing.EpisodeId = request.EpisodeId;
existing.PositionSeconds = request.PositionSeconds;
existing.UpdatedAt = DateTimeOffset.UtcNow;
existing.UserId ??= userId;
if (string.IsNullOrWhiteSpace(existing.DeviceId))
existing.DeviceId = request.DeviceId;
}
await db.SaveChangesAsync(ct);
return Results.NoContent();
});
return group;
}
}
@@ -0,0 +1,80 @@
using Microsoft.EntityFrameworkCore;
using TafsirQuran.Api.Mapping;
using TafsirQuran.Infrastructure.Persistence;
using TafsirQuran.Shared.Dtos;
namespace TafsirQuran.Api.Endpoints;
public static class TafsirEndpoints
{
public static RouteGroupBuilder MapTafsirEndpoints(this WebApplication app)
{
var group = app.MapGroup("/api");
group.MapGet("/tafsirs", async (AppDbContext db, CancellationToken ct) =>
{
var items = await db.Tafsirs
.AsNoTracking()
.Where(t => t.IsPublished)
.OrderBy(t => t.Title)
.Select(t => new TafsirDto(t.Id, t.Title, t.Author, t.Slug, t.CoverUrl))
.ToListAsync(ct);
return Results.Ok(items);
});
group.MapGet("/tafsirs/{slug}/episodes", async (string slug, AppDbContext db, CancellationToken ct) =>
{
var tafsir = await db.Tafsirs.AsNoTracking().FirstOrDefaultAsync(t => t.Slug == slug && t.IsPublished, ct);
if (tafsir is null) return Results.NotFound();
var episodes = await db.Episodes
.AsNoTracking()
.Include(e => e.Surah)
.Where(e => e.TafsirId == tafsir.Id)
.OrderBy(e => e.SortOrder)
.ToListAsync(ct);
return Results.Ok(episodes.Select(e => EpisodeMapper.ToListItem(e)).ToList());
});
group.MapGet("/episodes/{id:guid}", async (Guid id, AppDbContext db, CancellationToken ct) =>
{
var episode = await db.Episodes
.AsNoTracking()
.Include(e => e.Surah)
.Include(e => e.Tafsir)
.FirstOrDefaultAsync(e => e.Id == id, ct);
if (episode is null) return Results.NotFound();
var ayah = await db.Ayahs.AsNoTracking()
.FirstOrDefaultAsync(a => a.SurahId == episode.SurahId && a.Number == episode.AyahNumber, ct);
var detail = EpisodeMapper.ToDetail(episode, ayah) with
{
AudioUrl = $"/api/audio/{episode.Id}"
};
return Results.Ok(detail);
});
group.MapGet("/audio/{episodeId:guid}", async (Guid episodeId, AppDbContext db, IWebHostEnvironment env, CancellationToken ct) =>
{
var episode = await db.Episodes.AsNoTracking().FirstOrDefaultAsync(e => e.Id == episodeId, ct);
if (episode is null) return Results.NotFound();
var relative = episode.AudioUrl.TrimStart('/');
var path = Path.Combine(env.ContentRootPath, "wwwroot", relative);
if (!File.Exists(path))
{
// Fallback placeholder: return empty audio-friendly response path for demo
var placeholder = Path.Combine(env.ContentRootPath, "wwwroot", "audio", "silence.mp3");
if (File.Exists(placeholder))
return Results.File(placeholder, "audio/mpeg", enableRangeProcessing: true);
return Results.NotFound();
}
return Results.File(path, "audio/mpeg", enableRangeProcessing: true);
});
return group;
}
}
@@ -0,0 +1,32 @@
using TafsirQuran.Domain.Entities;
using TafsirQuran.Shared.Dtos;
namespace TafsirQuran.Api.Mapping;
public static class EpisodeMapper
{
public static EpisodeListItemDto ToListItem(TafsirEpisode e, Ayah? ayah = null) =>
new(
e.Id,
e.Title,
e.Surah.Number,
e.Surah.NameFa,
e.AyahNumber,
e.DurationSeconds,
e.SortOrder);
public static EpisodeDetailDto ToDetail(TafsirEpisode e, Ayah? ayah) =>
new(
e.Id,
e.TafsirId,
e.Tafsir.Slug,
e.Title,
e.Surah.Number,
e.Surah.NameFa,
e.AyahNumber,
ayah?.TextAr ?? string.Empty,
ayah?.TextFa,
e.AudioUrl,
e.DurationSeconds,
e.Summary);
}
+80
View File
@@ -0,0 +1,80 @@
using System.Text;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using TafsirQuran.Api.Auth;
using TafsirQuran.Api.Endpoints;
using TafsirQuran.Infrastructure;
using TafsirQuran.Infrastructure.Persistence;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddInfrastructure(builder.Configuration);
builder.Services.Configure<JwtOptions>(builder.Configuration.GetSection(JwtOptions.SectionName));
builder.Services.AddSingleton<JwtTokenService>();
var jwt = builder.Configuration.GetSection(JwtOptions.SectionName).Get<JwtOptions>() ?? new JwtOptions();
builder.Services
.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuer = true,
ValidateAudience = true,
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
ValidIssuer = jwt.Issuer,
ValidAudience = jwt.Audience,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwt.Key))
};
});
builder.Services.AddAuthorization();
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin());
});
builder.Services.AddOpenApi();
var app = builder.Build();
using (var scope = app.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
for (var attempt = 1; ; attempt++)
{
try
{
await DbSeeder.SeedAsync(db);
break;
}
catch (Exception ex) when (attempt < 30)
{
app.Logger.LogWarning(ex, "DB not ready (attempt {Attempt}); retry in 2s", attempt);
await Task.Delay(TimeSpan.FromSeconds(2));
}
}
}
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
}
app.UseCors();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseAuthentication();
app.UseAuthorization();
app.MapTafsirEndpoints();
app.MapProgressEndpoints();
app.MapFavoriteEndpoints();
app.MapBookmarkEndpoints();
app.MapAuthEndpoints();
app.MapGet("/", () => Results.Ok(new { name = "TafsirQuran API", status = "ok" }));
app.Run();
@@ -0,0 +1,14 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5080",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.10" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TafsirQuran.Infrastructure\TafsirQuran.Infrastructure.csproj" />
<ProjectReference Include="..\TafsirQuran.Shared\TafsirQuran.Shared.csproj" />
</ItemGroup>
</Project>
+6
View File
@@ -0,0 +1,6 @@
@TafsirQuran.Api_HostAddress = http://localhost:5025
GET {{TafsirQuran.Api_HostAddress}}/weatherforecast/
Accept: application/json
###
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Information"
}
}
}
+18
View File
@@ -0,0 +1,18 @@
{
"ConnectionStrings": {
"Default": "Host=localhost;Port=5434;Database=tafsirquran;Username=tafsir;Password=tafsir_dev"
},
"Jwt": {
"Key": "TafsirQuran-Dev-Secret-Key-Change-In-Production-32+",
"Issuer": "TafsirQuran",
"Audience": "TafsirQuran",
"ExpireMinutes": 43200
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,14 @@
namespace TafsirQuran.Domain.Entities;
public class AppUser
{
public Guid Id { get; set; } = Guid.NewGuid();
public string Email { get; set; } = string.Empty;
public string PasswordHash { get; set; } = string.Empty;
public string DisplayName { get; set; } = string.Empty;
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
public ICollection<ListeningProgress> ListeningProgresses { get; set; } = new List<ListeningProgress>();
public ICollection<Favorite> Favorites { get; set; } = new List<Favorite>();
public ICollection<Bookmark> Bookmarks { get; set; } = new List<Bookmark>();
}
+12
View File
@@ -0,0 +1,12 @@
namespace TafsirQuran.Domain.Entities;
public class Ayah
{
public Guid Id { get; set; } = Guid.NewGuid();
public int SurahId { get; set; }
public int Number { get; set; }
public string TextAr { get; set; } = string.Empty;
public string? TextFa { get; set; }
public Surah Surah { get; set; } = null!;
}
@@ -0,0 +1,14 @@
namespace TafsirQuran.Domain.Entities;
public class Bookmark
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid? UserId { get; set; }
public string DeviceId { get; set; } = string.Empty;
public Guid EpisodeId { get; set; }
public string? Note { get; set; }
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
public AppUser? User { get; set; }
public TafsirEpisode Episode { get; set; } = null!;
}
@@ -0,0 +1,13 @@
namespace TafsirQuran.Domain.Entities;
public class Favorite
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid? UserId { get; set; }
public string DeviceId { get; set; } = string.Empty;
public Guid EpisodeId { get; set; }
public DateTimeOffset CreatedAt { get; set; } = DateTimeOffset.UtcNow;
public AppUser? User { get; set; }
public TafsirEpisode Episode { get; set; } = null!;
}
@@ -0,0 +1,14 @@
namespace TafsirQuran.Domain.Entities;
public class ListeningProgress
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid? UserId { get; set; }
public string DeviceId { get; set; } = string.Empty;
public Guid EpisodeId { get; set; }
public double PositionSeconds { get; set; }
public DateTimeOffset UpdatedAt { get; set; } = DateTimeOffset.UtcNow;
public AppUser? User { get; set; }
public TafsirEpisode Episode { get; set; } = null!;
}
+12
View File
@@ -0,0 +1,12 @@
namespace TafsirQuran.Domain.Entities;
public class Surah
{
public int Id { get; set; }
public int Number { get; set; }
public string NameAr { get; set; } = string.Empty;
public string NameFa { get; set; } = string.Empty;
public ICollection<Ayah> Ayahs { get; set; } = new List<Ayah>();
public ICollection<TafsirEpisode> Episodes { get; set; } = new List<TafsirEpisode>();
}
+13
View File
@@ -0,0 +1,13 @@
namespace TafsirQuran.Domain.Entities;
public class Tafsir
{
public Guid Id { get; set; } = Guid.NewGuid();
public string Title { get; set; } = string.Empty;
public string Author { get; set; } = string.Empty;
public string Slug { get; set; } = string.Empty;
public string? CoverUrl { get; set; }
public bool IsPublished { get; set; } = true;
public ICollection<TafsirEpisode> Episodes { get; set; } = new List<TafsirEpisode>();
}
@@ -0,0 +1,17 @@
namespace TafsirQuran.Domain.Entities;
public class TafsirEpisode
{
public Guid Id { get; set; } = Guid.NewGuid();
public Guid TafsirId { get; set; }
public int SurahId { get; set; }
public int AyahNumber { get; set; }
public string Title { get; set; } = string.Empty;
public string AudioUrl { get; set; } = string.Empty;
public int DurationSeconds { get; set; }
public int SortOrder { get; set; }
public string? Summary { get; set; }
public Tafsir Tafsir { get; set; } = null!;
public Surah Surah { get; set; } = null!;
}
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using TafsirQuran.Infrastructure.Persistence;
namespace TafsirQuran.Infrastructure;
public static class DependencyInjection
{
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
{
var connectionString = configuration.GetConnectionString("Default")
?? "Host=localhost;Port=5434;Database=tafsirquran;Username=tafsir;Password=tafsir_dev";
services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(connectionString));
return services;
}
}
@@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore;
using TafsirQuran.Domain.Entities;
namespace TafsirQuran.Infrastructure.Persistence;
public class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
public DbSet<AppUser> Users => Set<AppUser>();
public DbSet<Tafsir> Tafsirs => Set<Tafsir>();
public DbSet<Surah> Surahs => Set<Surah>();
public DbSet<Ayah> Ayahs => Set<Ayah>();
public DbSet<TafsirEpisode> Episodes => Set<TafsirEpisode>();
public DbSet<ListeningProgress> ListeningProgresses => Set<ListeningProgress>();
public DbSet<Favorite> Favorites => Set<Favorite>();
public DbSet<Bookmark> Bookmarks => Set<Bookmark>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<AppUser>(e =>
{
e.HasIndex(x => x.Email).IsUnique();
e.Property(x => x.Email).HasMaxLength(256);
e.Property(x => x.DisplayName).HasMaxLength(128);
});
modelBuilder.Entity<Tafsir>(e =>
{
e.HasIndex(x => x.Slug).IsUnique();
e.Property(x => x.Title).HasMaxLength(200);
e.Property(x => x.Author).HasMaxLength(120);
e.Property(x => x.Slug).HasMaxLength(120);
});
modelBuilder.Entity<Surah>(e =>
{
e.HasIndex(x => x.Number).IsUnique();
e.Property(x => x.NameAr).HasMaxLength(80);
e.Property(x => x.NameFa).HasMaxLength(80);
});
modelBuilder.Entity<Ayah>(e =>
{
e.HasIndex(x => new { x.SurahId, x.Number }).IsUnique();
e.HasOne(x => x.Surah).WithMany(x => x.Ayahs).HasForeignKey(x => x.SurahId);
});
modelBuilder.Entity<TafsirEpisode>(e =>
{
e.HasIndex(x => new { x.TafsirId, x.SortOrder });
e.Property(x => x.Title).HasMaxLength(300);
e.HasOne(x => x.Tafsir).WithMany(x => x.Episodes).HasForeignKey(x => x.TafsirId);
e.HasOne(x => x.Surah).WithMany(x => x.Episodes).HasForeignKey(x => x.SurahId);
});
modelBuilder.Entity<ListeningProgress>(e =>
{
e.HasIndex(x => new { x.DeviceId, x.UserId });
e.Property(x => x.DeviceId).HasMaxLength(64);
e.HasOne(x => x.User).WithMany(x => x.ListeningProgresses).HasForeignKey(x => x.UserId);
e.HasOne(x => x.Episode).WithMany().HasForeignKey(x => x.EpisodeId);
});
modelBuilder.Entity<Favorite>(e =>
{
e.HasIndex(x => new { x.DeviceId, x.UserId, x.EpisodeId }).IsUnique();
e.Property(x => x.DeviceId).HasMaxLength(64);
e.HasOne(x => x.User).WithMany(x => x.Favorites).HasForeignKey(x => x.UserId);
e.HasOne(x => x.Episode).WithMany().HasForeignKey(x => x.EpisodeId);
});
modelBuilder.Entity<Bookmark>(e =>
{
e.HasIndex(x => new { x.DeviceId, x.UserId, x.EpisodeId }).IsUnique();
e.Property(x => x.DeviceId).HasMaxLength(64);
e.Property(x => x.Note).HasMaxLength(500);
e.HasOne(x => x.User).WithMany(x => x.Bookmarks).HasForeignKey(x => x.UserId);
e.HasOne(x => x.Episode).WithMany().HasForeignKey(x => x.EpisodeId);
});
}
}
@@ -0,0 +1,120 @@
using Microsoft.EntityFrameworkCore;
using TafsirQuran.Domain.Entities;
namespace TafsirQuran.Infrastructure.Persistence;
public static class DbSeeder
{
public static readonly Guid GhatrehChekaniId = Guid.Parse("11111111-1111-1111-1111-111111111111");
public static async Task SeedAsync(AppDbContext db, CancellationToken ct = default)
{
await db.Database.MigrateAsync(ct);
if (!await db.Surahs.AnyAsync(ct))
{
db.Surahs.AddRange(
new Surah { Id = 1, Number = 1, NameAr = "الفاتحة", NameFa = "فاتحه" },
new Surah { Id = 2, Number = 2, NameAr = "البقرة", NameFa = "بقره" },
new Surah { Id = 112, Number = 112, NameAr = "الإخلاص", NameFa = "اخلاص" }
);
db.Ayahs.AddRange(
new Ayah
{
SurahId = 1,
Number = 1,
TextAr = "بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ",
TextFa = "به نام خداوند بخشنده مهربان"
},
new Ayah
{
SurahId = 1,
Number = 2,
TextAr = "الْحَمْدُ لِلَّهِ رَبِّ الْعَالَمِينَ",
TextFa = "ستایش مخصوص خداوندی است که پروردگار جهانیان است"
},
new Ayah
{
SurahId = 1,
Number = 3,
TextAr = "الرَّحْمَٰنِ الرَّحِيمِ",
TextFa = "بخشنده مهربان"
},
new Ayah
{
SurahId = 112,
Number = 1,
TextAr = "قُلْ هُوَ اللَّهُ أَحَدٌ",
TextFa = "بگو اوست خدای یگانه"
}
);
}
if (!await db.Tafsirs.AnyAsync(ct))
{
var tafsir = new Tafsir
{
Id = GhatrehChekaniId,
Title = "تفسیر قطره چکانی",
Author = "قرائتی",
Slug = "ghatreh-chekani",
IsPublished = true
};
db.Tafsirs.Add(tafsir);
db.Episodes.AddRange(
new TafsirEpisode
{
Id = Guid.Parse("22222222-2222-2222-2222-222222222201"),
TafsirId = GhatrehChekaniId,
SurahId = 1,
AyahNumber = 1,
Title = "فاتحه آیه ۱",
AudioUrl = "/audio/sample-1.mp3",
DurationSeconds = 180,
SortOrder = 1,
Summary = "تفسیر قطره‌چکانی سوره فاتحه آیه اول"
},
new TafsirEpisode
{
Id = Guid.Parse("22222222-2222-2222-2222-222222222202"),
TafsirId = GhatrehChekaniId,
SurahId = 1,
AyahNumber = 2,
Title = "فاتحه آیه ۲",
AudioUrl = "/audio/sample-2.mp3",
DurationSeconds = 210,
SortOrder = 2,
Summary = "تفسیر قطره‌چکانی سوره فاتحه آیه دوم"
},
new TafsirEpisode
{
Id = Guid.Parse("22222222-2222-2222-2222-222222222203"),
TafsirId = GhatrehChekaniId,
SurahId = 1,
AyahNumber = 3,
Title = "فاتحه آیه ۳",
AudioUrl = "/audio/sample-3.mp3",
DurationSeconds = 195,
SortOrder = 3,
Summary = "تفسیر قطره‌چکانی سوره فاتحه آیه سوم"
},
new TafsirEpisode
{
Id = Guid.Parse("22222222-2222-2222-2222-222222222204"),
TafsirId = GhatrehChekaniId,
SurahId = 112,
AyahNumber = 1,
Title = "اخلاص آیه ۱",
AudioUrl = "/audio/sample-4.mp3",
DurationSeconds = 160,
SortOrder = 4,
Summary = "تفسیر قطره‌چکانی سوره اخلاص آیه اول"
}
);
}
await db.SaveChangesAsync(ct);
}
}
@@ -0,0 +1,398 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TafsirQuran.Infrastructure.Persistence;
#nullable disable
namespace TafsirQuran.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20261009174748_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TafsirQuran.Domain.Entities.AppUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Ayah", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Number")
.HasColumnType("integer");
b.Property<int>("SurahId")
.HasColumnType("integer");
b.Property<string>("TextAr")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TextFa")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SurahId", "Number")
.IsUnique();
b.ToTable("Ayahs");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Bookmark", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceId")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("EpisodeId")
.HasColumnType("uuid");
b.Property<string>("Note")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("EpisodeId");
b.HasIndex("UserId");
b.HasIndex("DeviceId", "UserId", "EpisodeId")
.IsUnique();
b.ToTable("Bookmarks");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Favorite", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceId")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("EpisodeId")
.HasColumnType("uuid");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("EpisodeId");
b.HasIndex("UserId");
b.HasIndex("DeviceId", "UserId", "EpisodeId")
.IsUnique();
b.ToTable("Favorites");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.ListeningProgress", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("DeviceId")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("EpisodeId")
.HasColumnType("uuid");
b.Property<double>("PositionSeconds")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("EpisodeId");
b.HasIndex("UserId");
b.HasIndex("DeviceId", "UserId");
b.ToTable("ListeningProgresses");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Surah", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("NameAr")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("character varying(80)");
b.Property<string>("NameFa")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("character varying(80)");
b.Property<int>("Number")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Number")
.IsUnique();
b.ToTable("Surahs");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Tafsir", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("character varying(120)");
b.Property<string>("CoverUrl")
.HasColumnType("text");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("character varying(120)");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.HasKey("Id");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("Tafsirs");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.TafsirEpisode", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AudioUrl")
.IsRequired()
.HasColumnType("text");
b.Property<int>("AyahNumber")
.HasColumnType("integer");
b.Property<int>("DurationSeconds")
.HasColumnType("integer");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.Property<string>("Summary")
.HasColumnType("text");
b.Property<int>("SurahId")
.HasColumnType("integer");
b.Property<Guid>("TafsirId")
.HasColumnType("uuid");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(300)
.HasColumnType("character varying(300)");
b.HasKey("Id");
b.HasIndex("SurahId");
b.HasIndex("TafsirId", "SortOrder");
b.ToTable("Episodes");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Ayah", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.Surah", "Surah")
.WithMany("Ayahs")
.HasForeignKey("SurahId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Surah");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Bookmark", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.TafsirEpisode", "Episode")
.WithMany()
.HasForeignKey("EpisodeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.AppUser", "User")
.WithMany("Bookmarks")
.HasForeignKey("UserId");
b.Navigation("Episode");
b.Navigation("User");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Favorite", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.TafsirEpisode", "Episode")
.WithMany()
.HasForeignKey("EpisodeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.AppUser", "User")
.WithMany("Favorites")
.HasForeignKey("UserId");
b.Navigation("Episode");
b.Navigation("User");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.ListeningProgress", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.TafsirEpisode", "Episode")
.WithMany()
.HasForeignKey("EpisodeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.AppUser", "User")
.WithMany("ListeningProgresses")
.HasForeignKey("UserId");
b.Navigation("Episode");
b.Navigation("User");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.TafsirEpisode", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.Surah", "Surah")
.WithMany("Episodes")
.HasForeignKey("SurahId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.Tafsir", "Tafsir")
.WithMany("Episodes")
.HasForeignKey("TafsirId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Surah");
b.Navigation("Tafsir");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.AppUser", b =>
{
b.Navigation("Bookmarks");
b.Navigation("Favorites");
b.Navigation("ListeningProgresses");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Surah", b =>
{
b.Navigation("Ayahs");
b.Navigation("Episodes");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Tafsir", b =>
{
b.Navigation("Episodes");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,303 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TafsirQuran.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Surahs",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Number = table.Column<int>(type: "integer", nullable: false),
NameAr = table.Column<string>(type: "character varying(80)", maxLength: 80, nullable: false),
NameFa = table.Column<string>(type: "character varying(80)", maxLength: 80, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Surahs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Tafsirs",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Title = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Author = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
Slug = table.Column<string>(type: "character varying(120)", maxLength: 120, nullable: false),
CoverUrl = table.Column<string>(type: "text", nullable: true),
IsPublished = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tafsirs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
PasswordHash = table.Column<string>(type: "text", nullable: false),
DisplayName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Ayahs",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
SurahId = table.Column<int>(type: "integer", nullable: false),
Number = table.Column<int>(type: "integer", nullable: false),
TextAr = table.Column<string>(type: "text", nullable: false),
TextFa = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Ayahs", x => x.Id);
table.ForeignKey(
name: "FK_Ayahs_Surahs_SurahId",
column: x => x.SurahId,
principalTable: "Surahs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Episodes",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TafsirId = table.Column<Guid>(type: "uuid", nullable: false),
SurahId = table.Column<int>(type: "integer", nullable: false),
AyahNumber = table.Column<int>(type: "integer", nullable: false),
Title = table.Column<string>(type: "character varying(300)", maxLength: 300, nullable: false),
AudioUrl = table.Column<string>(type: "text", nullable: false),
DurationSeconds = table.Column<int>(type: "integer", nullable: false),
SortOrder = table.Column<int>(type: "integer", nullable: false),
Summary = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Episodes", x => x.Id);
table.ForeignKey(
name: "FK_Episodes_Surahs_SurahId",
column: x => x.SurahId,
principalTable: "Surahs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Episodes_Tafsirs_TafsirId",
column: x => x.TafsirId,
principalTable: "Tafsirs",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Bookmarks",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: true),
DeviceId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
EpisodeId = table.Column<Guid>(type: "uuid", nullable: false),
Note = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bookmarks", x => x.Id);
table.ForeignKey(
name: "FK_Bookmarks_Episodes_EpisodeId",
column: x => x.EpisodeId,
principalTable: "Episodes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Bookmarks_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Favorites",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: true),
DeviceId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
EpisodeId = table.Column<Guid>(type: "uuid", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Favorites", x => x.Id);
table.ForeignKey(
name: "FK_Favorites_Episodes_EpisodeId",
column: x => x.EpisodeId,
principalTable: "Episodes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Favorites_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "ListeningProgresses",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: true),
DeviceId = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
EpisodeId = table.Column<Guid>(type: "uuid", nullable: false),
PositionSeconds = table.Column<double>(type: "double precision", nullable: false),
UpdatedAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ListeningProgresses", x => x.Id);
table.ForeignKey(
name: "FK_ListeningProgresses_Episodes_EpisodeId",
column: x => x.EpisodeId,
principalTable: "Episodes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ListeningProgresses_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Ayahs_SurahId_Number",
table: "Ayahs",
columns: new[] { "SurahId", "Number" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Bookmarks_DeviceId_UserId_EpisodeId",
table: "Bookmarks",
columns: new[] { "DeviceId", "UserId", "EpisodeId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Bookmarks_EpisodeId",
table: "Bookmarks",
column: "EpisodeId");
migrationBuilder.CreateIndex(
name: "IX_Bookmarks_UserId",
table: "Bookmarks",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Episodes_SurahId",
table: "Episodes",
column: "SurahId");
migrationBuilder.CreateIndex(
name: "IX_Episodes_TafsirId_SortOrder",
table: "Episodes",
columns: new[] { "TafsirId", "SortOrder" });
migrationBuilder.CreateIndex(
name: "IX_Favorites_DeviceId_UserId_EpisodeId",
table: "Favorites",
columns: new[] { "DeviceId", "UserId", "EpisodeId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Favorites_EpisodeId",
table: "Favorites",
column: "EpisodeId");
migrationBuilder.CreateIndex(
name: "IX_Favorites_UserId",
table: "Favorites",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_ListeningProgresses_DeviceId_UserId",
table: "ListeningProgresses",
columns: new[] { "DeviceId", "UserId" });
migrationBuilder.CreateIndex(
name: "IX_ListeningProgresses_EpisodeId",
table: "ListeningProgresses",
column: "EpisodeId");
migrationBuilder.CreateIndex(
name: "IX_ListeningProgresses_UserId",
table: "ListeningProgresses",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Surahs_Number",
table: "Surahs",
column: "Number",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Tafsirs_Slug",
table: "Tafsirs",
column: "Slug",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Users_Email",
table: "Users",
column: "Email",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Ayahs");
migrationBuilder.DropTable(
name: "Bookmarks");
migrationBuilder.DropTable(
name: "Favorites");
migrationBuilder.DropTable(
name: "ListeningProgresses");
migrationBuilder.DropTable(
name: "Episodes");
migrationBuilder.DropTable(
name: "Users");
migrationBuilder.DropTable(
name: "Surahs");
migrationBuilder.DropTable(
name: "Tafsirs");
}
}
}
@@ -0,0 +1,395 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TafsirQuran.Infrastructure.Persistence;
#nullable disable
namespace TafsirQuran.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
partial class AppDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.10")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TafsirQuran.Domain.Entities.AppUser", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property<string>("Email")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property<string>("PasswordHash")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Ayah", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<int>("Number")
.HasColumnType("integer");
b.Property<int>("SurahId")
.HasColumnType("integer");
b.Property<string>("TextAr")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TextFa")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("SurahId", "Number")
.IsUnique();
b.ToTable("Ayahs");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Bookmark", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceId")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("EpisodeId")
.HasColumnType("uuid");
b.Property<string>("Note")
.HasMaxLength(500)
.HasColumnType("character varying(500)");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("EpisodeId");
b.HasIndex("UserId");
b.HasIndex("DeviceId", "UserId", "EpisodeId")
.IsUnique();
b.ToTable("Bookmarks");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Favorite", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DeviceId")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("EpisodeId")
.HasColumnType("uuid");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("EpisodeId");
b.HasIndex("UserId");
b.HasIndex("DeviceId", "UserId", "EpisodeId")
.IsUnique();
b.ToTable("Favorites");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.ListeningProgress", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("DeviceId")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("character varying(64)");
b.Property<Guid>("EpisodeId")
.HasColumnType("uuid");
b.Property<double>("PositionSeconds")
.HasColumnType("double precision");
b.Property<DateTimeOffset>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<Guid?>("UserId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("EpisodeId");
b.HasIndex("UserId");
b.HasIndex("DeviceId", "UserId");
b.ToTable("ListeningProgresses");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Surah", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("NameAr")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("character varying(80)");
b.Property<string>("NameFa")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("character varying(80)");
b.Property<int>("Number")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("Number")
.IsUnique();
b.ToTable("Surahs");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Tafsir", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("Author")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("character varying(120)");
b.Property<string>("CoverUrl")
.HasColumnType("text");
b.Property<bool>("IsPublished")
.HasColumnType("boolean");
b.Property<string>("Slug")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("character varying(120)");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.HasKey("Id");
b.HasIndex("Slug")
.IsUnique();
b.ToTable("Tafsirs");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.TafsirEpisode", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<string>("AudioUrl")
.IsRequired()
.HasColumnType("text");
b.Property<int>("AyahNumber")
.HasColumnType("integer");
b.Property<int>("DurationSeconds")
.HasColumnType("integer");
b.Property<int>("SortOrder")
.HasColumnType("integer");
b.Property<string>("Summary")
.HasColumnType("text");
b.Property<int>("SurahId")
.HasColumnType("integer");
b.Property<Guid>("TafsirId")
.HasColumnType("uuid");
b.Property<string>("Title")
.IsRequired()
.HasMaxLength(300)
.HasColumnType("character varying(300)");
b.HasKey("Id");
b.HasIndex("SurahId");
b.HasIndex("TafsirId", "SortOrder");
b.ToTable("Episodes");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Ayah", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.Surah", "Surah")
.WithMany("Ayahs")
.HasForeignKey("SurahId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Surah");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Bookmark", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.TafsirEpisode", "Episode")
.WithMany()
.HasForeignKey("EpisodeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.AppUser", "User")
.WithMany("Bookmarks")
.HasForeignKey("UserId");
b.Navigation("Episode");
b.Navigation("User");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Favorite", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.TafsirEpisode", "Episode")
.WithMany()
.HasForeignKey("EpisodeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.AppUser", "User")
.WithMany("Favorites")
.HasForeignKey("UserId");
b.Navigation("Episode");
b.Navigation("User");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.ListeningProgress", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.TafsirEpisode", "Episode")
.WithMany()
.HasForeignKey("EpisodeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.AppUser", "User")
.WithMany("ListeningProgresses")
.HasForeignKey("UserId");
b.Navigation("Episode");
b.Navigation("User");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.TafsirEpisode", b =>
{
b.HasOne("TafsirQuran.Domain.Entities.Surah", "Surah")
.WithMany("Episodes")
.HasForeignKey("SurahId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TafsirQuran.Domain.Entities.Tafsir", "Tafsir")
.WithMany("Episodes")
.HasForeignKey("TafsirId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Surah");
b.Navigation("Tafsir");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.AppUser", b =>
{
b.Navigation("Bookmarks");
b.Navigation("Favorites");
b.Navigation("ListeningProgresses");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Surah", b =>
{
b.Navigation("Ayahs");
b.Navigation("Episodes");
});
modelBuilder.Entity("TafsirQuran.Domain.Entities.Tafsir", b =>
{
b.Navigation("Episodes");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.10" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TafsirQuran.Domain\TafsirQuran.Domain.csproj" />
</ItemGroup>
</Project>
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:TafsirQuran.Maui"
x:Class="TafsirQuran.Maui.App">
<Application.Resources>
<ResourceDictionary>
<!--
For information about styling .NET MAUI pages
please refer to the documentation:
https://go.microsoft.com/fwlink/?linkid=2282329
-->
</ResourceDictionary>
</Application.Resources>
</Application>
+14
View File
@@ -0,0 +1,14 @@
namespace TafsirQuran.Maui;
public partial class App : Application
{
public App()
{
InitializeComponent();
}
protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new MainPage()) { Title = "TafsirQuran.Maui" };
}
}
@@ -0,0 +1,10 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using TafsirQuran.UI
@using TafsirQuran.UI.Layout
@using TafsirQuran.Maui
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:ui="clr-namespace:TafsirQuran.UI;assembly=TafsirQuran.UI"
x:Class="TafsirQuran.Maui.MainPage">
<BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
<BlazorWebView.RootComponents>
<RootComponent Selector="#app" ComponentType="{x:Type ui:Routes}" />
</BlazorWebView.RootComponents>
</BlazorWebView>
</ContentPage>
+9
View File
@@ -0,0 +1,9 @@
namespace TafsirQuran.Maui;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
}
+34
View File
@@ -0,0 +1,34 @@
using Microsoft.Extensions.Logging;
using TafsirQuran.UI.Services;
namespace TafsirQuran.Maui;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
});
builder.Services.AddMauiBlazorWebView();
// Emulator/device should reach host machine API; 10.0.2.2 is Android emulator loopback to host.
var apiBase = DeviceInfo.Platform == DevicePlatform.Android
? "http://10.0.2.2:5080/"
: "http://localhost:5080/";
builder.Services.AddTafsirUi(apiBase);
#if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools();
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true"
android:icon="@mipmap/appicon"
android:roundIcon="@mipmap/appicon_round"
android:supportsRtl="true"
android:usesCleartextTraffic="true" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
@@ -0,0 +1,10 @@
using Android.App;
using Android.Content.PM;
using Android.OS;
namespace TafsirQuran.Maui;
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
@@ -0,0 +1,15 @@
using Android.App;
using Android.Runtime;
namespace TafsirQuran.Maui;
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#512BD4</color>
<color name="colorPrimaryDark">#2B0B98</color>
<color name="colorAccent">#2B0B98</color>
</resources>
@@ -0,0 +1,9 @@
using Foundation;
namespace TafsirQuran.Maui;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!-- See https://aka.ms/maui-publish-app-store#add-entitlements for more information about adding entitlements.-->
<dict>
<!-- App Sandbox must be enabled to distribute a MacCatalyst app through the Mac App Store. -->
<key>com.apple.security.app-sandbox</key>
<true/>
<!-- When App Sandbox is enabled, this value is required to open outgoing network connections. -->
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- The Mac App Store requires you specify if the app uses encryption. -->
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/itsappusesnonexemptencryption -->
<!-- <key>ITSAppUsesNonExemptEncryption</key> -->
<!-- Please indicate <true/> or <false/> here. -->
<!-- Specify the category for your app here. -->
<!-- Please consult https://developer.apple.com/documentation/bundleresources/information_property_list/lsapplicationcategorytype -->
<!-- <key>LSApplicationCategoryType</key> -->
<!-- <string>public.app-category.YOUR-CATEGORY-HERE</string> -->
<key>UIDeviceFamily</key>
<array>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>
@@ -0,0 +1,15 @@
using ObjCRuntime;
using UIKit;
namespace TafsirQuran.Maui;
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
@@ -0,0 +1,16 @@
using System;
using Microsoft.Maui;
using Microsoft.Maui.Hosting;
namespace TafsirQuran.Maui;
class Program : MauiApplication
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
static void Main(string[] args)
{
var app = new Program();
app.Run(args);
}
}
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="maui-application-id-placeholder" version="0.0.0" api-version="9" xmlns="http://tizen.org/ns/packages">
<profile name="common" />
<ui-application appid="maui-application-id-placeholder" exec="TafsirQuran.Maui.dll" multiple="false" nodisplay="false" taskmanage="true" type="dotnet" launch_mode="single">
<label>maui-application-title-placeholder</label>
<icon>maui-appicon-placeholder</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
<shortcut-list />
<privileges>
<privilege>http://tizen.org/privilege/internet</privilege>
</privileges>
<dependencies />
<provides-appdefined-privileges />
</manifest>
@@ -0,0 +1,8 @@
<maui:MauiWinUIApplication
x:Class="TafsirQuran.Maui.WinUI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:maui="using:Microsoft.Maui"
xmlns:local="using:TafsirQuran.Maui.WinUI">
</maui:MauiWinUIApplication>
@@ -0,0 +1,24 @@
using Microsoft.UI.Xaml;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace TafsirQuran.Maui.WinUI;
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : MauiWinUIApplication
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity Name="maui-package-name-placeholder" Publisher="CN=User Name" Version="0.0.0.0" />
<mp:PhoneIdentity PhoneProductId="C77EEA2B-C81F-4233-BBB1-F27015400E93" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
<Properties>
<DisplayName>$placeholder$</DisplayName>
<PublisherDisplayName>User Name</PublisherDisplayName>
<Logo>$placeholder$.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="$placeholder$"
Description="$placeholder$"
Square150x150Logo="$placeholder$.png"
Square44x44Logo="$placeholder$.png"
BackgroundColor="transparent">
<uap:DefaultTile Square71x71Logo="$placeholder$.png" Wide310x150Logo="$placeholder$.png" Square310x310Logo="$placeholder$.png" />
<uap:SplashScreen Image="$placeholder$.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="TafsirQuran.Maui.WinUI.app"/>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<!-- The combination of below two tags have the following effect:
1) Per-Monitor for >= Windows 10 Anniversary Update
2) System < Windows 10 Anniversary Update
-->
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</windowsSettings>
</application>
</assembly>
@@ -0,0 +1,9 @@
using Foundation;
namespace TafsirQuran.Maui;
[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
</dict>
</plist>
@@ -0,0 +1,15 @@
using ObjCRuntime;
using UIKit;
namespace TafsirQuran.Maui;
public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
This is the minimum required version of the Apple Privacy Manifest for .NET MAUI apps.
The contents below are needed because of APIs that are used in the .NET framework and .NET MAUI SDK.
You are responsible for adding extra entries as needed for your application.
More information: https://aka.ms/maui-privacy-manifest
-->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>E174.1</string>
</array>
</dict>
<!--
The entry below is only needed when you're using the Preferences API in your app.
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict> -->
</array>
</dict>
</plist>
@@ -0,0 +1,8 @@
{
"profiles": {
"Windows Machine": {
"commandName": "Project",
"nativeDebugging": false
}
}
}
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="456" height="456" fill="#512BD4" />
</svg>

After

Width:  |  Height:  |  Size: 228 B

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="m 105.50037,281.60863 c -2.70293,0 -5.00091,-0.90042 -6.893127,-2.70209 -1.892214,-1.84778 -2.837901,-4.04181 -2.837901,-6.58209 0,-2.58722 0.945687,-4.80389 2.837901,-6.65167 1.892217,-1.84778 4.190197,-2.77167 6.893127,-2.77167 2.74819,0 5.06798,0.92389 6.96019,2.77167 1.93749,1.84778 2.90581,4.06445 2.90581,6.65167 0,2.54028 -0.96832,4.73431 -2.90581,6.58209 -1.89221,1.80167 -4.212,2.70209 -6.96019,2.70209 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 213.56111,280.08446 H 195.99044 L 149.69953,207.0544 c -1.17121,-1.84778 -2.14037,-3.76515 -2.90581,-5.75126 h -0.40578 c 0.36051,2.12528 0.54076,6.67515 0.54076,13.6496 v 65.13172 h -15.54349 v -99.36009 h 18.71925 l 44.7374,71.29798 c 1.89222,2.95695 3.1087,4.98917 3.64945,6.09751 h 0.26996 c -0.45021,-2.6325 -0.67573,-7.09015 -0.67573,-13.37293 v -64.02256 h 15.47557 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="m 289.25134,280.08446 h -54.40052 v -99.36009 h 52.23835 v 13.99669 h -36.15411 v 28.13085 h 33.31621 v 13.9271 h -33.31621 v 29.37835 h 38.31628 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 366.56466,194.72106 H 338.7222 v 85.3634 h -16.08423 v -85.3634 h -27.77455 v -13.99669 h 71.70124 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,93 @@
<svg width="419" height="519" viewBox="0 0 419 519" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M284.432 247.568L284.004 221.881C316.359 221.335 340.356 211.735 355.308 193.336C382.408 159.996 372.893 108.183 372.786 107.659L398.013 102.831C398.505 105.432 409.797 167.017 375.237 209.53C355.276 234.093 324.719 246.894 284.432 247.568Z" fill="#8A6FE8"/>
<path d="M331.954 109.36L361.826 134.245C367.145 138.676 375.055 137.959 379.497 132.639C383.928 127.32 383.211 119.41 377.891 114.969L348.019 90.0842C342.7 85.6531 334.79 86.3702 330.348 91.6896C325.917 97.0197 326.634 104.929 331.954 109.36Z" fill="#8A6FE8"/>
<path d="M407.175 118.062L417.92 94.2263C420.735 87.858 417.856 80.4087 411.488 77.5831C405.12 74.7682 397.67 77.6473 394.845 84.0156L383.831 108.461L407.175 118.062Z" fill="#8A6FE8"/>
<path d="M401.363 105.175L401.234 69.117C401.181 62.1493 395.498 56.541 388.53 56.5945C381.562 56.648 375.954 62.3313 376.007 69.2989L376.018 96.11L401.363 105.175Z" fill="#8A6FE8"/>
<path d="M386.453 109.071L378.137 73.9548C376.543 67.169 369.757 62.9628 362.971 64.5575C356.185 66.1523 351.979 72.938 353.574 79.7237L362.04 115.482L386.453 109.071Z" fill="#8A6FE8"/>
<path d="M381.776 142.261C396.359 142.261 408.181 130.44 408.181 115.857C408.181 101.274 396.359 89.4527 381.776 89.4527C367.194 89.4527 355.372 101.274 355.372 115.857C355.372 130.44 367.194 142.261 381.776 142.261Z" fill="url(#paint0_radial)"/>
<path d="M248.267 406.979C248.513 384.727 245.345 339.561 222.376 301.736L199.922 315.372C220.76 349.675 222.323 389.715 221.841 407.182C221.798 408.627 235.263 409.933 248.267 406.979Z" fill="url(#paint1_linear)"/>
<path d="M221.841 406.936L242.637 406.84L262.052 518.065L220.311 518.258C217.132 518.269 214.724 515.711 214.938 512.532L221.841 406.936Z" fill="#522CD5"/>
<path d="M306.566 488.814C310.173 491.661 310.109 495.782 309.831 500.127L308.964 513.452C308.803 515.839 306.727 517.798 304.34 517.809L260.832 518.012C258.125 518.023 256.08 515.839 256.262 513.142L256.551 499.335C256.883 494.315 255.192 492.474 251.307 487.744C244.649 479.663 224.967 435.62 226.84 406.925L248.256 406.829C249.691 423.858 272.167 461.682 306.566 488.814Z" fill="url(#paint2_linear)"/>
<path d="M309.82 500.127C310.023 497.088 310.077 494.176 308.889 491.715L254.635 491.961C256.134 494.166 256.765 496.092 256.562 499.314L256.273 513.121C256.091 515.828 258.146 518.012 260.843 517.99L304.34 517.798C306.727 517.787 308.803 515.828 308.964 513.442L309.82 500.127Z" fill="url(#paint3_radial)"/>
<path d="M133.552 407.471C133.103 385.22 135.864 340.021 158.49 301.993L181.073 315.425C160.545 349.921 159.346 389.972 159.989 407.428C160.042 408.884 146.578 410.318 133.552 407.471Z" fill="url(#paint4_linear)"/>
<path d="M110.798 497.152C110.765 494.187 111.204 491.575 112.457 487.23C131.882 434.132 133.52 407.364 133.52 407.364L159.999 407.246C159.999 407.246 161.819 433.512 181.716 486.427C183.289 490.195 183.471 493.641 183.674 496.831L183.792 513.816C183.803 516.374 181.716 518.483 179.158 518.494L177.873 518.504L116.781 518.782L115.496 518.793C112.927 518.804 110.83 516.728 110.819 514.159L110.798 497.152Z" fill="url(#paint5_linear)"/>
<path d="M110.798 497.152C110.798 496.67 110.808 496.199 110.83 495.739C110.969 494.262 111.643 492.603 114.875 492.582L180.207 492.282C182.561 492.367 183.343 494.176 183.589 495.311C183.621 495.814 183.664 496.328 183.696 496.82L183.813 513.806C183.824 515.411 183.011 516.824 181.769 517.669C181.031 518.172 180.132 518.472 179.179 518.483L177.895 518.494L116.802 518.772L115.528 518.782C114.244 518.793 113.077 518.269 112.232 517.434C111.386 516.599 110.862 515.432 110.851 514.148L110.798 497.152Z" fill="url(#paint6_radial)"/>
<path d="M314.979 246.348C324.162 210.407 318.008 181.777 318.008 181.777L326.452 181.734L326.656 181.574C314.262 115.75 256.326 66.0987 186.949 66.4198C108.796 66.773 45.7233 130.424 46.0765 208.577C46.4297 286.731 110.08 349.803 188.234 349.45C249.905 349.172 302.178 309.474 321.304 254.343C321.872 251.999 321.797 247.804 314.979 246.348Z" fill="url(#paint7_radial)"/>
<path d="M310.237 279.035L65.877 280.148C71.3998 289.428 77.95 298.012 85.3672 305.761L290.972 304.829C298.336 297.005 304.8 288.368 310.237 279.035Z" fill="#D8CFF7"/>
<path d="M235.062 312.794L280.924 312.585L280.74 272.021L234.877 272.23L235.062 312.794Z" fill="#512BD4"/>
<path d="M243.001 297.626C242.691 297.626 242.434 297.53 242.22 297.327C242.006 297.123 241.899 296.866 241.899 296.588C241.899 296.299 242.006 296.042 242.22 295.839C242.434 295.625 242.691 295.528 243.001 295.528C243.312 295.528 243.568 295.635 243.782 295.839C243.996 296.042 244.114 296.299 244.114 296.588C244.114 296.877 244.007 297.123 243.793 297.327C243.568 297.519 243.312 297.626 243.001 297.626Z" fill="white"/>
<path d="M255.192 297.434H253.212L247.967 289.203C247.839 289 247.721 288.775 247.636 288.55H247.593C247.636 288.786 247.657 289.299 247.657 290.091L247.668 297.444H245.912L245.891 286.228H247.999L253.062 294.265C253.276 294.597 253.415 294.833 253.479 294.95H253.511C253.458 294.651 253.437 294.148 253.437 293.441L253.426 286.217H255.17L255.192 297.434Z" fill="white"/>
<path d="M263.733 297.412L257.589 297.423L257.568 286.206L263.465 286.195V287.779L259.387 287.79L259.398 290.969L263.155 290.958V292.532L259.398 292.542L259.409 295.86L263.733 295.85V297.412Z" fill="white"/>
<path d="M272.445 287.758L269.298 287.769L269.32 297.401H267.5L267.479 287.769L264.343 287.779V286.195L272.434 286.174L272.445 287.758Z" fill="white"/>
<path d="M315.279 246.337C324.355 210.836 318.457 182.483 318.308 181.798L171.484 182.462C171.484 182.462 162.226 181.563 162.268 190.018C162.311 198.463 162.761 222.341 162.878 248.746C162.9 254.172 167.363 256.773 170.863 256.751C170.874 256.751 311.618 252.213 315.279 246.337Z" fill="url(#paint8_radial)"/>
<path d="M227.685 246.798C227.685 246.798 250.183 228.827 254.571 225.499C258.959 222.17 262.812 221.977 266.869 225.445C270.925 228.913 293.616 246.498 293.616 246.498L227.685 246.798Z" fill="#A08BE8"/>
<path d="M320.748 256.141C320.748 256.141 324.943 248.414 315.279 246.348C315.289 246.305 170.927 246.894 170.927 246.894C167.566 246.905 163.232 244.925 162.846 241.671C162.857 244.004 162.878 246.369 162.889 248.756C162.91 253.68 166.582 256.27 169.878 256.698C170.21 256.73 170.542 256.773 170.874 256.773L180.742 256.73L320.748 256.141Z" fill="#512BD4"/>
<path d="M206.4 233.214C212.511 233.095 217.302 224.667 217.102 214.39C216.901 204.112 211.785 195.878 205.674 195.997C199.563 196.116 194.772 204.544 194.973 214.821C195.173 225.099 200.289 233.333 206.4 233.214Z" fill="#512BD4"/>
<path d="M306.249 214.267C306.356 203.989 301.488 195.605 295.377 195.541C289.266 195.478 284.225 203.758 284.118 214.037C284.011 224.315 288.878 232.699 294.99 232.763C301.101 232.826 306.142 224.545 306.249 214.267Z" fill="#512BD4"/>
<path d="M205.905 205.291C208.152 203.022 211.192 202.016 214.157 202.262C215.912 205.495 217.014 209.733 217.111 214.389C217.164 217.3 216.811 220.04 216.158 222.513C212.669 223.519 208.752 222.662 205.979 219.922C201.912 215.909 201.88 209.348 205.905 205.291Z" fill="#8065E0"/>
<path d="M294.996 204.285C297.255 202.016 300.294 200.999 303.259 201.256C305.164 204.628 306.309 209.209 306.256 214.239C306.224 216.808 305.892 219.259 305.303 221.485C301.793 222.523 297.843 221.678 295.061 218.916C291.004 214.892 290.972 208.342 294.996 204.285Z" fill="#8065E0"/>
<path d="M11.6342 357.017C10.9171 354.716 -5.72611 300.141 21.3204 258.903C36.9468 235.078 63.3083 221.035 99.6664 217.15L102.449 243.276C74.3431 246.273 54.4676 256.345 43.3579 273.202C23.0971 303.941 36.5722 348.733 36.7113 349.183L11.6342 357.017Z" fill="url(#paint9_linear)"/>
<path d="M95.1498 252.802C109.502 252.802 121.137 241.167 121.137 226.815C121.137 212.463 109.502 200.828 95.1498 200.828C80.7976 200.828 69.1628 212.463 69.1628 226.815C69.1628 241.167 80.7976 252.802 95.1498 252.802Z" fill="url(#paint10_radial)"/>
<path d="M72.0098 334.434L33.4683 329.307C26.597 328.397 20.2929 333.214 19.3725 340.085C18.4627 346.956 23.279 353.26 30.1504 354.181L68.6919 359.308C75.5632 360.217 81.8673 355.401 82.7878 348.53C83.6975 341.658 78.8705 335.344 72.0098 334.434Z" fill="#8A6FE8"/>
<path d="M3.73535 367.185L7.35297 393.076C8.36975 399.968 14.7702 404.731 21.6629 403.725C28.5556 402.708 33.3185 396.308 32.3124 389.415L28.5984 362.861L3.73535 367.185Z" fill="#8A6FE8"/>
<path d="M15.5194 374.988L34.849 405.427C38.6058 411.292 46.4082 413.005 52.2735 409.248C58.1387 405.491 59.8512 397.689 56.0945 391.823L41.7953 369.144L15.5194 374.988Z" fill="#8A6FE8"/>
<path d="M26.0511 363.739L51.8026 389.019C56.7688 393.911 64.7532 393.846 69.6445 388.88C74.5358 383.914 74.4715 375.929 69.516 371.038L43.2937 345.297L26.0511 363.739Z" fill="#8A6FE8"/>
<path d="M26.4043 381.912C40.987 381.912 52.8086 370.091 52.8086 355.508C52.8086 340.925 40.987 329.104 26.4043 329.104C11.8216 329.104 0 340.925 0 355.508C0 370.091 11.8216 381.912 26.4043 381.912Z" fill="url(#paint11_radial)"/>
<path d="M184.73 63.6308L157.819 66.5892L158.561 38.5412L177.888 36.4178L184.73 63.6308Z" fill="#8A6FE8"/>
<path d="M170.018 41.647C180.455 39.521 187.193 29.3363 185.067 18.8988C182.941 8.46126 172.757 1.72345 162.319 3.84944C151.882 5.97543 145.144 16.1601 147.27 26.5976C149.396 37.0351 159.58 43.773 170.018 41.647Z" fill="#D8CFF7"/>
<path d="M196.885 79.385C198.102 79.2464 198.948 78.091 198.684 76.8997C195.851 64.2818 183.923 55.5375 170.773 56.9926C157.622 58.4371 147.886 69.5735 147.865 82.4995C147.863 83.7232 148.949 84.6597 150.168 84.5316L196.885 79.385Z" fill="url(#paint12_radial)"/>
<defs>
<radialGradient id="paint0_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(382.004 103.457) scale(26.4058)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
<linearGradient id="paint1_linear" x1="214.439" y1="303.482" x2="236.702" y2="409.505" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<linearGradient id="paint2_linear" x1="231.673" y1="404.144" x2="297.805" y2="522.048" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<radialGradient id="paint3_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(280.957 469.555) rotate(-0.260742) scale(45.8326)">
<stop offset="0.034" stop-color="#522CD5"/>
<stop offset="0.9955" stop-color="#8A6FE8"/>
</radialGradient>
<linearGradient id="paint4_linear" x1="166.061" y1="303.491" x2="144.763" y2="409.709" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<linearGradient id="paint5_linear" x1="146.739" y1="407.302" x2="147.246" y2="518.627" gradientUnits="userSpaceOnUse">
<stop stop-color="#522CD5"/>
<stop offset="0.4397" stop-color="#8A6FE8"/>
</linearGradient>
<radialGradient id="paint6_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(148.63 470.023) rotate(179.739) scale(50.2476)">
<stop offset="0.034" stop-color="#522CD5"/>
<stop offset="0.9955" stop-color="#8A6FE8"/>
</radialGradient>
<radialGradient id="paint7_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(219.219 153.929) rotate(179.739) scale(140.935)">
<stop offset="0.4744" stop-color="#A08BE8"/>
<stop offset="0.8618" stop-color="#8065E0"/>
</radialGradient>
<radialGradient id="paint8_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(314.861 158.738) rotate(179.739) scale(146.053)">
<stop offset="0.0933" stop-color="#E1DFDD"/>
<stop offset="0.6573" stop-color="white"/>
</radialGradient>
<linearGradient id="paint9_linear" x1="54.1846" y1="217.159" x2="54.1846" y2="357.022" gradientUnits="userSpaceOnUse">
<stop offset="0.3344" stop-color="#9780E6"/>
<stop offset="0.8488" stop-color="#8A6FE8"/>
</linearGradient>
<radialGradient id="paint10_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(90.3494 218.071) rotate(-0.260742) scale(25.9924)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
<radialGradient id="paint11_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(25.805 345.043) scale(26.4106)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
<radialGradient id="paint12_radial" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(169.113 67.3662) rotate(-32.2025) scale(21.0773)">
<stop stop-color="#8065E0"/>
<stop offset="1" stop-color="#512BD4"/>
</radialGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 12 KiB

@@ -0,0 +1,15 @@
Any raw assets you want to be deployed with your application can be placed in
this directory (and child directories). Deployment of the asset to your application
is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
These files will be deployed with your package and will be accessible using Essentials:
async Task LoadMauiAsset()
{
using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
using var reader = new StreamReader(stream);
var contents = reader.ReadToEnd();
}
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="456" height="456" viewBox="0 0 456 456" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<path d="m 105.50037,281.60863 c -2.70293,0 -5.00091,-0.90042 -6.893127,-2.70209 -1.892214,-1.84778 -2.837901,-4.04181 -2.837901,-6.58209 0,-2.58722 0.945687,-4.80389 2.837901,-6.65167 1.892217,-1.84778 4.190197,-2.77167 6.893127,-2.77167 2.74819,0 5.06798,0.92389 6.96019,2.77167 1.93749,1.84778 2.90581,4.06445 2.90581,6.65167 0,2.54028 -0.96832,4.73431 -2.90581,6.58209 -1.89221,1.80167 -4.212,2.70209 -6.96019,2.70209 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 213.56111,280.08446 H 195.99044 L 149.69953,207.0544 c -1.17121,-1.84778 -2.14037,-3.76515 -2.90581,-5.75126 h -0.40578 c 0.36051,2.12528 0.54076,6.67515 0.54076,13.6496 v 65.13172 h -15.54349 v -99.36009 h 18.71925 l 44.7374,71.29798 c 1.89222,2.95695 3.1087,4.98917 3.64945,6.09751 h 0.26996 c -0.45021,-2.6325 -0.67573,-7.09015 -0.67573,-13.37293 v -64.02256 h 15.47557 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="m 289.25134,280.08446 h -54.40052 v -99.36009 h 52.23835 v 13.99669 h -36.15411 v 28.13085 h 33.31621 v 13.9271 h -33.31621 v 29.37835 h 38.31628 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
<path d="M 366.56466,194.72106 H 338.7222 v 85.3634 h -16.08423 v -85.3634 h -27.77455 v -13.99669 h 71.70124 z" style="fill:#ffffff;fill-rule:nonzero;stroke-width:0.838376" />
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

@@ -0,0 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<!-- Phase 1: Android only -->
<TargetFrameworks>net9.0-android</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>TafsirQuran.Maui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<EnableDefaultCssItems>false</EnableDefaultCssItems>
<Nullable>enable</Nullable>
<ApplicationTitle>تفسیر قرآن</ApplicationTitle>
<ApplicationId>com.tafsirquran.app</ApplicationId>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
</PropertyGroup>
<ItemGroup>
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#1F6B4A" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#1F6B4A" BaseSize="128,128" />
<MauiImage Include="Resources\Images\*" />
<MauiFont Include="Resources\Fonts\*" />
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.10" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TafsirQuran.UI\TafsirQuran.UI.csproj" />
<ProjectReference Include="..\TafsirQuran.Shared\TafsirQuran.Shared.csproj" />
</ItemGroup>
</Project>
+2
View File
@@ -0,0 +1,2 @@
/* Maui host shell — shared look comes from TafsirQuran.UI */
html, body { height: 100%; }
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+16
View File
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<title>تفسیر قرآن</title>
<base href="/" />
<link rel="stylesheet" href="_content/TafsirQuran.UI/css/app.css" />
<link rel="stylesheet" href="css/app.css" />
</head>
<body>
<div id="app">در حال بارگذاری...</div>
<script src="_framework/blazor.webview.js" autostart="false"></script>
<script src="_content/TafsirQuran.UI/js/app.js"></script>
</body>
</html>
+42
View File
@@ -0,0 +1,42 @@
namespace TafsirQuran.Shared.Dtos;
public record TafsirDto(Guid Id, string Title, string Author, string Slug, string? CoverUrl);
public record EpisodeListItemDto(
Guid Id,
string Title,
int SurahNumber,
string SurahNameFa,
int AyahNumber,
int DurationSeconds,
int SortOrder);
public record EpisodeDetailDto(
Guid Id,
Guid TafsirId,
string TafsirSlug,
string Title,
int SurahNumber,
string SurahNameFa,
int AyahNumber,
string AyahTextAr,
string? AyahTextFa,
string AudioUrl,
int DurationSeconds,
string? Summary);
public record ProgressDto(Guid EpisodeId, double PositionSeconds, DateTimeOffset UpdatedAt, EpisodeListItemDto? Episode);
public record UpsertProgressRequest(Guid EpisodeId, double PositionSeconds, string DeviceId);
public record FavoriteDto(Guid Id, Guid EpisodeId, DateTimeOffset CreatedAt, EpisodeListItemDto Episode);
public record BookmarkDto(Guid Id, Guid EpisodeId, string? Note, DateTimeOffset CreatedAt, EpisodeListItemDto Episode);
public record ToggleEpisodeRequest(Guid EpisodeId, string DeviceId, string? Note = null);
public record AuthRequest(string Email, string Password, string? DisplayName = null);
public record AuthResponse(Guid UserId, string Email, string DisplayName, string Token);
public record UserStatusDto(bool IsAuthenticated, Guid? UserId, string? Email, string? DisplayName);
@@ -0,0 +1,7 @@
namespace TafsirQuran.Shared.Services;
public interface IAuthTokenStore
{
Task<string?> GetTokenAsync();
Task SetTokenAsync(string? token);
}
@@ -0,0 +1,6 @@
namespace TafsirQuran.Shared.Services;
public interface IDeviceIdStore
{
Task<string> GetOrCreateAsync();
}
@@ -0,0 +1,119 @@
using System.Net.Http.Headers;
using System.Net.Http.Json;
using TafsirQuran.Shared.Dtos;
namespace TafsirQuran.Shared.Services;
public class TafsirApiClient(HttpClient http, IAuthTokenStore tokenStore)
{
private async Task EnsureAuthHeaderAsync()
{
var token = await tokenStore.GetTokenAsync();
http.DefaultRequestHeaders.Authorization = string.IsNullOrWhiteSpace(token)
? null
: new AuthenticationHeaderValue("Bearer", token);
}
public async Task<IReadOnlyList<TafsirDto>> GetTafsirsAsync(CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
return await http.GetFromJsonAsync<List<TafsirDto>>("api/tafsirs", ct) ?? [];
}
public async Task<IReadOnlyList<EpisodeListItemDto>> GetEpisodesAsync(string slug, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
return await http.GetFromJsonAsync<List<EpisodeListItemDto>>($"api/tafsirs/{slug}/episodes", ct) ?? [];
}
public async Task<EpisodeDetailDto?> GetEpisodeAsync(Guid id, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
return await http.GetFromJsonAsync<EpisodeDetailDto>($"api/episodes/{id}", ct);
}
public async Task<ProgressDto?> GetProgressAsync(string deviceId, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
var response = await http.GetAsync($"api/progress?deviceId={Uri.EscapeDataString(deviceId)}", ct);
if (response.StatusCode == System.Net.HttpStatusCode.NoContent)
return null;
response.EnsureSuccessStatusCode();
return await response.Content.ReadFromJsonAsync<ProgressDto>(ct);
}
public async Task SaveProgressAsync(UpsertProgressRequest request, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
var response = await http.PutAsJsonAsync("api/progress", request, ct);
response.EnsureSuccessStatusCode();
}
public async Task<IReadOnlyList<FavoriteDto>> GetFavoritesAsync(string deviceId, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
return await http.GetFromJsonAsync<List<FavoriteDto>>($"api/favorites?deviceId={Uri.EscapeDataString(deviceId)}", ct) ?? [];
}
public async Task AddFavoriteAsync(ToggleEpisodeRequest request, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
var response = await http.PostAsJsonAsync("api/favorites", request, ct);
response.EnsureSuccessStatusCode();
}
public async Task RemoveFavoriteAsync(Guid episodeId, string deviceId, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
var response = await http.DeleteAsync($"api/favorites/{episodeId}?deviceId={Uri.EscapeDataString(deviceId)}", ct);
response.EnsureSuccessStatusCode();
}
public async Task<IReadOnlyList<BookmarkDto>> GetBookmarksAsync(string deviceId, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
return await http.GetFromJsonAsync<List<BookmarkDto>>($"api/bookmarks?deviceId={Uri.EscapeDataString(deviceId)}", ct) ?? [];
}
public async Task AddBookmarkAsync(ToggleEpisodeRequest request, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
var response = await http.PostAsJsonAsync("api/bookmarks", request, ct);
response.EnsureSuccessStatusCode();
}
public async Task RemoveBookmarkAsync(Guid episodeId, string deviceId, CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
var response = await http.DeleteAsync($"api/bookmarks/{episodeId}?deviceId={Uri.EscapeDataString(deviceId)}", ct);
response.EnsureSuccessStatusCode();
}
public async Task<AuthResponse?> RegisterAsync(AuthRequest request, CancellationToken ct = default)
{
var response = await http.PostAsJsonAsync("api/auth/register", request, ct);
if (!response.IsSuccessStatusCode) return null;
return await response.Content.ReadFromJsonAsync<AuthResponse>(ct);
}
public async Task<AuthResponse?> LoginAsync(AuthRequest request, CancellationToken ct = default)
{
var response = await http.PostAsJsonAsync("api/auth/login", request, ct);
if (!response.IsSuccessStatusCode) return null;
return await response.Content.ReadFromJsonAsync<AuthResponse>(ct);
}
public async Task LogoutAsync(CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
await http.PostAsync("api/auth/logout", null, ct);
await tokenStore.SetTokenAsync(null);
}
public async Task<UserStatusDto> GetMeAsync(CancellationToken ct = default)
{
await EnsureAuthHeaderAsync();
return await http.GetFromJsonAsync<UserStatusDto>("api/auth/status", ct)
?? new UserStatusDto(false, null, null, null);
}
}
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
@@ -0,0 +1,118 @@
@inject IJSRuntime Js
@inject ApiOptions ApiOptions
@implements IAsyncDisposable
<div class="audio-player" @ref="root">
<div class="player-title">@Episode.Title</div>
<div class="player-actions">
<button type="button" class="chip @(IsFavorite ? "on" : null)" @onclick="OnFavoriteToggle">علاقه</button>
<button type="button" class="chip @(IsBookmarked ? "on" : null)" @onclick="OnBookmarkToggle">نشان</button>
</div>
<audio @ref="audioEl" preload="metadata" src="@AudioSrc"></audio>
<div class="player-controls">
<button type="button" class="play-btn" @onclick="TogglePlay">
@(playing ? "❚❚" : "▶")
</button>
<input class="seek" type="range" min="0" max="@duration.ToString("0.###")" step="0.1"
value="@current.ToString("0.###")" @oninput="OnSeek" />
<div class="time">@Format(current) / @Format(duration)</div>
</div>
</div>
@code {
[Parameter, EditorRequired] public EpisodeDetailDto Episode { get; set; } = default!;
[Parameter] public double InitialPosition { get; set; }
[Parameter] public bool IsFavorite { get; set; }
[Parameter] public bool IsBookmarked { get; set; }
[Parameter] public EventCallback OnFavoriteToggle { get; set; }
[Parameter] public EventCallback OnBookmarkToggle { get; set; }
[Parameter] public EventCallback<double> OnProgress { get; set; }
private ElementReference audioEl;
private ElementReference root;
private DotNetObjectReference<AudioPlayer>? self;
private bool playing;
private double current;
private double duration;
private Guid boundEpisodeId;
private string AudioSrc => ResolveAudioUrl(Episode.AudioUrl);
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
self = DotNetObjectReference.Create(this);
await Js.InvokeVoidAsync("tqAudio.bind", audioEl, self);
}
if (boundEpisodeId != Episode.Id)
{
boundEpisodeId = Episode.Id;
playing = false;
current = InitialPosition;
await Js.InvokeVoidAsync("tqAudio.load", audioEl, AudioSrc, InitialPosition);
}
}
private string ResolveAudioUrl(string url)
{
if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
return url;
return new Uri(new Uri(ApiOptions.BaseAddress), url.TrimStart('/')).ToString();
}
private async Task TogglePlay()
{
playing = await Js.InvokeAsync<bool>("tqAudio.toggle", audioEl);
}
private async Task OnSeek(ChangeEventArgs e)
{
if (double.TryParse(e.Value?.ToString(), out var v))
{
current = v;
await Js.InvokeVoidAsync("tqAudio.seek", audioEl, v);
await OnProgress.InvokeAsync(v);
}
}
[JSInvokable]
public async Task OnTime(double time, double dur, bool isPlaying)
{
current = time;
duration = dur > 0 ? dur : duration;
playing = isPlaying;
await InvokeAsync(StateHasChanged);
if (isPlaying && Math.Floor(time) % 5 == 0)
await OnProgress.InvokeAsync(time);
}
[JSInvokable]
public async Task OnPaused(double time)
{
playing = false;
current = time;
await OnProgress.InvokeAsync(time);
await InvokeAsync(StateHasChanged);
}
private static string Format(double seconds)
{
if (seconds < 0 || double.IsNaN(seconds) || double.IsInfinity(seconds)) seconds = 0;
var ts = TimeSpan.FromSeconds(seconds);
return ts.TotalHours >= 1 ? ts.ToString(@"h\:mm\:ss") : ts.ToString(@"mm\:ss");
}
public async ValueTask DisposeAsync()
{
try
{
await Js.InvokeVoidAsync("tqAudio.unbind", audioEl);
}
catch { /* ignore */ }
self?.Dispose();
}
}
+42
View File
@@ -0,0 +1,42 @@
@inherits LayoutComponentBase
@implements IDisposable
@inject AuthStateService Auth
<div class="app-shell @(sidebarOpen ? "sidebar-open" : null)">
<header class="topbar">
<button class="icon-btn" type="button" @onclick="ToggleSidebar" aria-label="منو">
<span class="burger"></span>
</button>
<a class="brand" href="/">تفسیر قرآن</a>
<div class="topbar-spacer"></div>
</header>
<div class="backdrop" @onclick="CloseSidebar"></div>
<aside class="sidebar">
<Sidebar OnNavigate="CloseSidebar" />
</aside>
<main class="content">
@Body
</main>
</div>
@code {
private bool sidebarOpen;
protected override void OnInitialized() => Auth.Changed += OnAuthChanged;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender) return;
await Auth.RefreshAsync();
await InvokeAsync(StateHasChanged);
}
private void OnAuthChanged() => InvokeAsync(StateHasChanged);
private void ToggleSidebar() => sidebarOpen = !sidebarOpen;
private void CloseSidebar() => sidebarOpen = false;
public void Dispose() => Auth.Changed -= OnAuthChanged;
}
+50
View File
@@ -0,0 +1,50 @@
@inject AuthStateService Auth
@inject NavigationManager Nav
<nav class="side-nav">
<div class="side-section">
<button class="side-item cascade-toggle" type="button" @onclick="() => tafsirsOpen = !tafsirsOpen">
<span>تفسیرها</span>
<span class="chevron @(tafsirsOpen ? "open" : null)">▾</span>
</button>
@if (tafsirsOpen)
{
<div class="cascade">
<NavLink class="side-item nested" href="/tafsir/ghatreh-chekani" @onclick="Navigate">
تفسیر قطره چکانی
</NavLink>
</div>
}
<NavLink class="side-item" href="/favorites" @onclick="Navigate">علاقه‌مندی‌ها</NavLink>
<NavLink class="side-item" href="/bookmarks" @onclick="Navigate">نشان‌شده‌ها</NavLink>
<NavLink class="side-item" href="/about" @onclick="Navigate">درباره ما</NavLink>
<NavLink class="side-item" href="/contact" @onclick="Navigate">تماس با ما</NavLink>
</div>
<div class="side-footer">
@if (Auth.Current.IsAuthenticated)
{
<div class="user-chip">@Auth.Current.DisplayName</div>
<button class="side-item danger" type="button" @onclick="Logout">خروج</button>
}
else
{
<NavLink class="side-item" href="/login" @onclick="Navigate">ورود / ثبت‌نام</NavLink>
}
</div>
</nav>
@code {
[Parameter] public EventCallback OnNavigate { get; set; }
private bool tafsirsOpen = true;
private async Task Navigate() => await OnNavigate.InvokeAsync();
private async Task Logout()
{
await Auth.LogoutAsync();
await OnNavigate.InvokeAsync();
Nav.NavigateTo("/");
}
}
+9
View File
@@ -0,0 +1,9 @@
@page "/about"
<section class="prose-page">
<h1>درباره ما</h1>
<p>
این اپلیکیشن برای شنیدن تفسیر قرآن کریم طراحی شده است.
فاز نخست با تفسیر قطره‌چکانی استاد قرائتی آغاز می‌شود و به‌تدریج مفسران و منابع بیشتری افزوده خواهد شد.
</p>
</section>
@@ -0,0 +1,45 @@
@page "/bookmarks"
@inject TafsirApiClient Api
@inject IDeviceIdStore DeviceStore
<section class="list-page">
<h1>نشان‌شده‌ها</h1>
@if (loading)
{
<p class="muted">در حال بارگذاری...</p>
}
else if (items.Count == 0)
{
<p class="muted">هنوز نشانی ذخیره نشده است.</p>
}
else
{
<ul class="simple-list">
@foreach (var item in items)
{
<li>
<a href="/tafsir/ghatreh-chekani">@item.Episode.Title</a>
<span class="ep-meta">@item.Episode.SurahNameFa — آیه @item.Episode.AyahNumber</span>
</li>
}
</ul>
}
</section>
@code {
private List<BookmarkDto> items = [];
private bool loading = true;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender) return;
var deviceId = await DeviceStore.GetOrCreateAsync();
try { items = (await Api.GetBookmarksAsync(deviceId)).ToList(); }
catch { items = []; }
finally
{
loading = false;
await InvokeAsync(StateHasChanged);
}
}
}
@@ -0,0 +1,7 @@
@page "/contact"
<section class="prose-page">
<h1>تماس با ما</h1>
<p>برای پیشنهاد، گزارش اشکال یا همکاری می‌توانید از ایمیل زیر استفاده کنید:</p>
<p><a href="mailto:hello@tafsirquran.app">hello@tafsirquran.app</a></p>
</section>
@@ -0,0 +1,45 @@
@page "/favorites"
@inject TafsirApiClient Api
@inject IDeviceIdStore DeviceStore
<section class="list-page">
<h1>علاقه‌مندی‌ها</h1>
@if (loading)
{
<p class="muted">در حال بارگذاری...</p>
}
else if (items.Count == 0)
{
<p class="muted">هنوز علاقه‌مندی‌ای ندارید.</p>
}
else
{
<ul class="simple-list">
@foreach (var item in items)
{
<li>
<a href="/tafsir/ghatreh-chekani">@item.Episode.Title</a>
<span class="ep-meta">@item.Episode.SurahNameFa — آیه @item.Episode.AyahNumber</span>
</li>
}
</ul>
}
</section>
@code {
private List<FavoriteDto> items = [];
private bool loading = true;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender) return;
var deviceId = await DeviceStore.GetOrCreateAsync();
try { items = (await Api.GetFavoritesAsync(deviceId)).ToList(); }
catch { items = []; }
finally
{
loading = false;
await InvokeAsync(StateHasChanged);
}
}
}
+53
View File
@@ -0,0 +1,53 @@
@page "/"
@inject TafsirApiClient Api
<section class="home">
<h1 class="sr-only">تفسیر قرآن</h1>
@if (loading)
{
<p class="muted">در حال بارگذاری...</p>
}
else if (tafsirs.Count == 0)
{
<a class="tafsir-tile" href="/tafsir/ghatreh-chekani">
<span class="tile-title">تفسیر قطره چکانی</span>
<span class="tile-author">قرائتی</span>
</a>
}
else
{
<div class="tile-grid">
@foreach (var t in tafsirs)
{
<a class="tafsir-tile" href="@($"/tafsir/{t.Slug}")">
<span class="tile-title">@t.Title</span>
<span class="tile-author">@t.Author</span>
</a>
}
</div>
}
</section>
@code {
private List<TafsirDto> tafsirs = [];
private bool loading = true;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender) return;
try
{
tafsirs = (await Api.GetTafsirsAsync()).ToList();
}
catch
{
tafsirs = [];
}
finally
{
loading = false;
await InvokeAsync(StateHasChanged);
}
}
}
+76
View File
@@ -0,0 +1,76 @@
@page "/login"
@inject TafsirApiClient Api
@inject AuthStateService Auth
@inject NavigationManager Nav
<section class="auth-page">
<h1>@(isRegister ? "ثبت‌نام" : "ورود")</h1>
<p class="muted">اختیاری است؛ بدون حساب هم می‌توانید گوش دهید و نشان بگذارید.</p>
<EditForm Model="model" OnValidSubmit="SubmitAsync" class="auth-form">
@if (isRegister)
{
<label>
نام نمایشی
<InputText @bind-Value="model.DisplayName" />
</label>
}
<label>
ایمیل
<InputText @bind-Value="model.Email" />
</label>
<label>
رمز عبور
<input type="password" @bind="model.Password" />
</label>
@if (!string.IsNullOrEmpty(error))
{
<p class="error">@error</p>
}
<button class="primary-btn" type="submit" disabled="@busy">
@(isRegister ? "ایجاد حساب" : "ورود")
</button>
</EditForm>
<button class="link-btn" type="button" @onclick="() => isRegister = !isRegister">
@(isRegister ? "حساب دارید؟ ورود" : "حساب ندارید؟ ثبت‌نام")
</button>
</section>
@code {
private readonly AuthModel model = new();
private bool isRegister;
private bool busy;
private string? error;
private async Task SubmitAsync()
{
busy = true;
error = null;
try
{
var req = new AuthRequest(model.Email, model.Password, model.DisplayName);
var result = isRegister ? await Api.RegisterAsync(req) : await Api.LoginAsync(req);
if (result is null)
{
error = isRegister ? "ثبت‌نام ناموفق بود." : "ورود ناموفق بود.";
return;
}
await Auth.SetSessionAsync(result);
Nav.NavigateTo("/");
}
finally
{
busy = false;
}
}
private sealed class AuthModel
{
public string Email { get; set; } = "";
public string Password { get; set; } = "";
public string? DisplayName { get; set; }
}
}
+148
View File
@@ -0,0 +1,148 @@
@page "/tafsir/{Slug}"
@inject TafsirApiClient Api
@inject IDeviceIdStore DeviceStore
<section class="tafsir-page">
<header class="page-header">
<h1>@title</h1>
<p class="muted">@author</p>
</header>
@if (loading)
{
<p class="muted">در حال بارگذاری...</p>
}
else
{
<div class="episode-layout">
<div class="episode-list">
@foreach (var ep in episodes)
{
<button type="button"
class="episode-row @(selected?.Id == ep.Id ? "active" : null)"
@onclick="() => SelectAsync(ep.Id)">
<span class="ep-title">@ep.Title</span>
<span class="ep-meta">@ep.SurahNameFa — آیه @ep.AyahNumber</span>
</button>
}
</div>
<div class="player-panel">
@if (detail is null)
{
<p class="muted">یک آیه را انتخاب کنید</p>
}
else
{
<div class="ayah-block">
<p class="ayah-ar">@detail.AyahTextAr</p>
@if (!string.IsNullOrWhiteSpace(detail.AyahTextFa))
{
<p class="ayah-fa">@detail.AyahTextFa</p>
}
</div>
<AudioPlayer @key="detail.Id"
Episode="detail"
InitialPosition="initialPosition"
IsFavorite="isFavorite"
IsBookmarked="isBookmarked"
OnFavoriteToggle="ToggleFavorite"
OnBookmarkToggle="ToggleBookmark"
OnProgress="SaveProgress" />
}
</div>
</div>
}
</section>
@code {
[Parameter] public string Slug { get; set; } = "";
private string title = "تفسیر";
private string author = "";
private bool loading = true;
private string? loadedForSlug;
private List<EpisodeListItemDto> episodes = [];
private EpisodeListItemDto? selected;
private EpisodeDetailDto? detail;
private double initialPosition;
private bool isFavorite;
private bool isBookmarked;
private string deviceId = "";
private bool ready;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender) ready = true;
if (!ready || string.IsNullOrWhiteSpace(Slug) || loadedForSlug == Slug) return;
loading = true;
loadedForSlug = Slug;
deviceId = await DeviceStore.GetOrCreateAsync();
try
{
var tafsirs = await Api.GetTafsirsAsync();
var tafsir = tafsirs.FirstOrDefault(t => t.Slug == Slug);
title = tafsir?.Title ?? "تفسیر";
author = tafsir?.Author ?? "";
episodes = (await Api.GetEpisodesAsync(Slug)).ToList();
var progress = await Api.GetProgressAsync(deviceId);
var startId = progress?.Episode?.Id;
if (startId is null || episodes.All(e => e.Id != startId))
startId = episodes.FirstOrDefault()?.Id;
if (startId is Guid id)
{
initialPosition = progress?.EpisodeId == id ? progress.PositionSeconds : 0;
await SelectAsync(id, keepPosition: true);
}
}
finally
{
loading = false;
await InvokeAsync(StateHasChanged);
}
}
private async Task SelectAsync(Guid id, bool keepPosition = false)
{
selected = episodes.FirstOrDefault(e => e.Id == id);
detail = await Api.GetEpisodeAsync(id);
if (!keepPosition) initialPosition = 0;
var favorites = await Api.GetFavoritesAsync(deviceId);
var bookmarks = await Api.GetBookmarksAsync(deviceId);
isFavorite = favorites.Any(f => f.EpisodeId == id);
isBookmarked = bookmarks.Any(b => b.EpisodeId == id);
}
private async Task ToggleFavorite()
{
if (detail is null) return;
if (isFavorite)
await Api.RemoveFavoriteAsync(detail.Id, deviceId);
else
await Api.AddFavoriteAsync(new ToggleEpisodeRequest(detail.Id, deviceId));
isFavorite = !isFavorite;
}
private async Task ToggleBookmark()
{
if (detail is null) return;
if (isBookmarked)
await Api.RemoveBookmarkAsync(detail.Id, deviceId);
else
await Api.AddBookmarkAsync(new ToggleEpisodeRequest(detail.Id, deviceId));
isBookmarked = !isBookmarked;
}
private async Task SaveProgress(double position)
{
if (detail is null) return;
await Api.SaveProgressAsync(new UpsertProgressRequest(detail.Id, position, deviceId));
}
}
+6
View File
@@ -0,0 +1,6 @@
<Router AppAssembly="typeof(Routes).Assembly">
<Found Context="routeData">
<RouteView RouteData="routeData" DefaultLayout="typeof(AppLayout)" />
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
</Router>
@@ -0,0 +1,6 @@
namespace TafsirQuran.UI.Services;
public class ApiOptions
{
public string BaseAddress { get; set; } = "http://localhost:5080/";
}
@@ -0,0 +1,44 @@
using TafsirQuran.Shared.Dtos;
using TafsirQuran.Shared.Services;
namespace TafsirQuran.UI.Services;
public class AuthStateService(TafsirApiClient api, IAuthTokenStore tokenStore)
{
public UserStatusDto Current { get; private set; } = new(false, null, null, null);
public event Action? Changed;
public async Task RefreshAsync()
{
try
{
Current = await api.GetMeAsync();
}
catch
{
Current = new(false, null, null, null);
}
Changed?.Invoke();
}
public async Task SetSessionAsync(AuthResponse? response)
{
if (response is null)
{
await tokenStore.SetTokenAsync(null);
Current = new(false, null, null, null);
}
else
{
await tokenStore.SetTokenAsync(response.Token);
Current = new(true, response.UserId, response.Email, response.DisplayName);
}
Changed?.Invoke();
}
public async Task LogoutAsync()
{
try { await api.LogoutAsync(); } catch { /* ignore */ }
await SetSessionAsync(null);
}
}
@@ -0,0 +1,45 @@
using Microsoft.JSInterop;
using TafsirQuran.Shared.Services;
namespace TafsirQuran.UI.Services;
public class BrowserAuthTokenStore(IJSRuntime js) : IAuthTokenStore
{
private const string Key = "tq_auth_token";
private string? _memory;
private bool _loaded;
public async Task<string?> GetTokenAsync()
{
if (_loaded) return _memory;
try
{
_memory = await js.InvokeAsync<string?>("tqStorage.get", Key);
_loaded = true;
return _memory;
}
catch (InvalidOperationException)
{
return _memory;
}
catch (JSException)
{
return _memory;
}
}
public async Task SetTokenAsync(string? token)
{
_memory = token;
_loaded = true;
try
{
if (string.IsNullOrWhiteSpace(token))
await js.InvokeVoidAsync("tqStorage.remove", Key);
else
await js.InvokeVoidAsync("tqStorage.set", Key, token);
}
catch (InvalidOperationException) { }
catch (JSException) { }
}
}
@@ -0,0 +1,42 @@
using Microsoft.JSInterop;
using TafsirQuran.Shared.Services;
namespace TafsirQuran.UI.Services;
public class BrowserDeviceIdStore(IJSRuntime js) : IDeviceIdStore
{
private const string Key = "tq_device_id";
private string? _memory;
public async Task<string> GetOrCreateAsync()
{
if (!string.IsNullOrWhiteSpace(_memory))
return _memory;
try
{
var existing = await js.InvokeAsync<string?>("tqStorage.get", Key);
if (!string.IsNullOrWhiteSpace(existing))
{
_memory = existing;
return existing;
}
var id = Guid.NewGuid().ToString("N");
await js.InvokeVoidAsync("tqStorage.set", Key, id);
_memory = id;
return id;
}
catch (InvalidOperationException)
{
// JS not available yet (prerender) — temporary id until after render
_memory ??= Guid.NewGuid().ToString("N");
return _memory;
}
catch (JSException)
{
_memory ??= Guid.NewGuid().ToString("N");
return _memory;
}
}
}
@@ -0,0 +1,23 @@
using Microsoft.Extensions.DependencyInjection;
using TafsirQuran.Shared.Services;
namespace TafsirQuran.UI.Services;
public static class UiServiceCollectionExtensions
{
public static IServiceCollection AddTafsirUi(this IServiceCollection services, string apiBaseAddress)
{
var normalized = apiBaseAddress.TrimEnd('/') + "/";
services.AddSingleton(new ApiOptions { BaseAddress = normalized });
services.AddScoped<IDeviceIdStore, BrowserDeviceIdStore>();
services.AddScoped<IAuthTokenStore, BrowserAuthTokenStore>();
services.AddScoped<AuthStateService>();
services.AddScoped(sp =>
{
var http = new HttpClient { BaseAddress = new Uri(normalized) };
var tokens = sp.GetRequiredService<IAuthTokenStore>();
return new TafsirApiClient(http, tokens);
});
return services;
}
}
+22
View File
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<SupportedPlatform Include="browser" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.10" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.10" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TafsirQuran.Shared\TafsirQuran.Shared.csproj" />
</ItemGroup>
</Project>
+14
View File
@@ -0,0 +1,14 @@
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using TafsirQuran.Shared.Dtos
@using TafsirQuran.Shared.Services
@using TafsirQuran.UI
@using TafsirQuran.UI.Components
@using TafsirQuran.UI.Layout
@using TafsirQuran.UI.Pages
@using TafsirQuran.UI.Services
Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

+228
View File
@@ -0,0 +1,228 @@
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;700&family=Amiri:wght@400;700&display=swap');
:root {
--bg: #f3efe6;
--bg-accent: #e7efe8;
--ink: #1c2b24;
--muted: #5d6b63;
--brand: #1f6b4a;
--brand-deep: #134632;
--surface: rgba(255, 255, 255, 0.72);
--line: rgba(28, 43, 36, 0.12);
--danger: #9b3b3b;
--radius: 18px;
--shadow: 0 18px 40px rgba(28, 43, 36, 0.08);
--sidebar-width: 280px;
--font: "Vazirmatn", sans-serif;
--font-ar: "Amiri", serif;
}
* { box-sizing: border-box; }
html, body {
margin: 0;
padding: 0;
font-family: var(--font);
color: var(--ink);
background:
radial-gradient(1200px 600px at 100% -10%, #dce9df 0%, transparent 55%),
radial-gradient(900px 500px at -10% 100%, #efe4d2 0%, transparent 50%),
var(--bg);
min-height: 100%;
direction: rtl;
}
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
.sr-only {
position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
overflow: hidden; clip: rect(0,0,0,0); border: 0;
}
.app-shell { min-height: 100vh; }
.topbar {
position: sticky; top: 0; z-index: 20;
display: flex; align-items: center; gap: 0.75rem;
padding: 0.85rem 1rem;
backdrop-filter: blur(14px);
background: rgba(243, 239, 230, 0.82);
border-bottom: 1px solid var(--line);
}
.brand {
font-weight: 700;
font-size: 1.15rem;
letter-spacing: -0.02em;
}
.icon-btn {
width: 42px; height: 42px;
border: 1px solid var(--line);
border-radius: 12px;
background: var(--surface);
display: grid; place-items: center;
cursor: pointer;
}
.burger, .burger::before, .burger::after {
display: block; width: 16px; height: 2px; background: var(--ink); border-radius: 2px;
content: ""; position: relative;
}
.burger::before { top: -5px; position: absolute; }
.burger::after { top: 5px; position: absolute; }
.sidebar {
position: fixed; inset: 0 auto 0 0; /* LTR physical: for RTL put on right */
right: 0; left: auto;
width: min(var(--sidebar-width), 86vw);
background: #163528;
color: #f4f7f5;
transform: translateX(105%);
transition: transform .28s ease;
z-index: 30;
display: flex; flex-direction: column;
padding: 1.25rem 0.75rem;
box-shadow: var(--shadow);
}
.app-shell.sidebar-open .sidebar { transform: translateX(0); }
.backdrop {
position: fixed; inset: 0; background: rgba(10, 18, 14, 0.35);
opacity: 0; pointer-events: none; transition: opacity .28s ease; z-index: 25;
}
.app-shell.sidebar-open .backdrop { opacity: 1; pointer-events: auto; }
.side-nav { display: flex; flex-direction: column; height: 100%; gap: 1rem; }
.side-section { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.side-footer { border-top: 1px solid rgba(255,255,255,0.12); padding-top: 0.75rem; }
.side-item {
display: flex; align-items: center; justify-content: space-between;
padding: 0.85rem 0.9rem;
border-radius: 12px;
color: inherit;
border: 0;
background: transparent;
width: 100%;
text-align: right;
cursor: pointer;
}
.side-item:hover, .side-item.active { background: rgba(255,255,255,0.08); }
.side-item.nested { padding-right: 1.6rem; font-size: 0.95rem; color: #d7e6dd; }
.side-item.danger { color: #ffc9c9; }
.cascade { display: flex; flex-direction: column; gap: 0.15rem; }
.chevron { transition: transform .2s ease; opacity: .8; }
.chevron.open { transform: rotate(180deg); }
.user-chip { padding: 0.5rem 0.9rem; color: #c7d8ce; font-size: 0.9rem; }
.content { padding: 1.25rem 1rem 2.5rem; max-width: 980px; margin: 0 auto; }
.home { padding-top: 1.5rem; }
.tile-grid { display: grid; gap: 1rem; }
.tafsir-tile {
display: flex; flex-direction: column; justify-content: flex-end;
min-height: 220px;
padding: 1.5rem;
border-radius: 28px;
background:
linear-gradient(160deg, rgba(31,107,74,0.92), rgba(19,70,50,0.95)),
radial-gradient(circle at 20% 20%, rgba(255,255,255,0.18), transparent 40%);
color: #f7faf8;
box-shadow: var(--shadow);
transition: transform .2s ease, box-shadow .2s ease;
}
.tafsir-tile:hover { transform: translateY(-3px); box-shadow: 0 22px 48px rgba(19,70,50,0.22); }
.tile-title { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 700; }
.tile-author { margin-top: 0.35rem; font-size: 0.95rem; opacity: 0.85; }
.page-header h1, .list-page h1, .prose-page h1, .auth-page h1 {
margin: 0 0 0.35rem; font-size: 1.6rem;
}
.muted { color: var(--muted); }
.error { color: var(--danger); }
.episode-layout {
display: grid;
gap: 1rem;
}
@media (min-width: 860px) {
.episode-layout { grid-template-columns: 1fr 1.1fr; align-items: start; }
}
.episode-list {
display: flex; flex-direction: column; gap: 0.45rem;
max-height: 60vh; overflow: auto; padding-left: 0.25rem;
}
.episode-row {
border: 1px solid var(--line);
background: var(--surface);
border-radius: 14px;
padding: 0.85rem 1rem;
text-align: right;
cursor: pointer;
display: flex; flex-direction: column; gap: 0.2rem;
}
.episode-row.active, .episode-row:hover {
border-color: rgba(31,107,74,0.45);
background: #fff;
}
.ep-title { font-weight: 600; }
.ep-meta { color: var(--muted); font-size: 0.85rem; }
.player-panel {
border: 1px solid var(--line);
background: var(--surface);
border-radius: 22px;
padding: 1.1rem;
box-shadow: var(--shadow);
}
.ayah-block { margin-bottom: 1rem; }
.ayah-ar {
font-family: var(--font-ar);
font-size: clamp(1.4rem, 3vw, 1.9rem);
line-height: 2;
margin: 0 0 0.5rem;
}
.ayah-fa { margin: 0; color: var(--muted); }
.audio-player { display: flex; flex-direction: column; gap: 0.85rem; }
.player-title { font-weight: 600; }
.player-actions { display: flex; gap: 0.5rem; }
.chip {
border: 1px solid var(--line);
background: #fff;
border-radius: 999px;
padding: 0.35rem 0.85rem;
cursor: pointer;
}
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.player-controls { display: grid; grid-template-columns: auto 1fr auto; gap: 0.75rem; align-items: center; }
.play-btn {
width: 48px; height: 48px; border-radius: 50%;
border: 0; background: var(--brand); color: #fff; cursor: pointer;
}
.seek { width: 100%; accent-color: var(--brand); }
.time { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.simple-list { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.6rem; }
.simple-list li {
padding: 0.9rem 1rem; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
display: flex; flex-direction: column; gap: 0.2rem;
}
.prose-page p, .auth-page p { line-height: 1.9; color: var(--muted); }
.auth-form { display: grid; gap: 0.85rem; max-width: 420px; margin-top: 1rem; }
.auth-form label { display: grid; gap: 0.35rem; font-size: 0.95rem; }
.auth-form input {
border: 1px solid var(--line); border-radius: 12px; padding: 0.75rem 0.9rem; background: #fff;
}
.primary-btn {
border: 0; border-radius: 12px; padding: 0.85rem 1rem;
background: var(--brand); color: #fff; cursor: pointer;
}
.primary-btn:disabled { opacity: 0.6; cursor: default; }
.link-btn {
margin-top: 0.85rem; border: 0; background: transparent; color: var(--brand-deep); cursor: pointer;
}
+63
View File
@@ -0,0 +1,63 @@
window.tqStorage = {
get: (key) => localStorage.getItem(key),
set: (key, value) => localStorage.setItem(key, value),
remove: (key) => localStorage.removeItem(key)
};
window.tqAudio = {
_handlers: new WeakMap(),
bind: (audio, dotnet) => {
if (!audio) return;
const onTime = () => dotnet.invokeMethodAsync('OnTime', audio.currentTime || 0, audio.duration || 0, !audio.paused);
const onPause = () => dotnet.invokeMethodAsync('OnPaused', audio.currentTime || 0);
const onEnded = () => dotnet.invokeMethodAsync('OnPaused', audio.currentTime || 0);
audio.addEventListener('timeupdate', onTime);
audio.addEventListener('pause', onPause);
audio.addEventListener('ended', onEnded);
audio.addEventListener('loadedmetadata', onTime);
window.tqAudio._handlers.set(audio, { onTime, onPause, onEnded, dotnet });
window.addEventListener('pagehide', () => {
if (!audio.paused) {
dotnet.invokeMethodAsync('OnPaused', audio.currentTime || 0);
}
});
},
unbind: (audio) => {
const h = window.tqAudio._handlers.get(audio);
if (!h || !audio) return;
audio.removeEventListener('timeupdate', h.onTime);
audio.removeEventListener('pause', h.onPause);
audio.removeEventListener('ended', h.onEnded);
window.tqAudio._handlers.delete(audio);
},
load: async (audio, src, position) => {
if (!audio) return;
audio.src = src;
audio.load();
const seek = () => {
if (position && !Number.isNaN(position)) {
try { audio.currentTime = position; } catch (_) { /* ignore */ }
}
};
audio.addEventListener('loadedmetadata', seek, { once: true });
},
toggle: async (audio) => {
if (!audio) return false;
if (audio.paused) {
await audio.play();
return true;
}
audio.pause();
return false;
},
seek: (audio, value) => {
if (!audio) return;
audio.currentTime = Number(value) || 0;
}
};
+24
View File
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#1f6b4a" />
<meta name="description" content="تفسیر قرآن کریم — صوت و متن" />
<base href="/" />
<link rel="manifest" href="manifest.webmanifest" />
<link rel="apple-touch-icon" href="icons/icon-192.png" />
<link rel="stylesheet" href="_content/TafsirQuran.UI/css/app.css" />
<link rel="stylesheet" href="@Assets["app.css"]" />
<HeadOutlet @rendermode="InteractiveServer" />
</head>
<body>
<TafsirQuran.UI.Routes @rendermode="InteractiveServer" />
<script src="_framework/blazor.web.js"></script>
<script src="_content/TafsirQuran.UI/js/app.js"></script>
<script src="service-worker-register.js"></script>
</body>
</html>
@@ -0,0 +1,9 @@
@inherits LayoutComponentBase
@Body
<div id="blazor-error-ui" data-nosnippet>
An unhandled error has occurred.
<a href="." class="reload">Reload</a>
<span class="dismiss">🗙</span>
</div>
@@ -0,0 +1,20 @@
#blazor-error-ui {
color-scheme: light only;
background: lightyellow;
bottom: 0;
box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
display: none;
left: 0;
padding: 0.6rem 1.25rem 0.7rem 1.25rem;
position: fixed;
width: 100%;
z-index: 1000;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 0.75rem;
top: 0.5rem;
}

Some files were not shown because too many files have changed in this diff Show More