Compare commits

..

8 Commits

Author SHA1 Message Date
4fd51e24d0 Added tags to sources
All checks were successful
continuous-integration/drone/pr Build is passing
2023-06-15 21:54:17 -07:00
ac5efe3113 using a card view to show the posts 2023-06-15 21:53:24 -07:00
7a7cd9966b docker cleanup 2023-06-15 21:52:00 -07:00
09d9543f3d makefile time 2023-06-15 21:51:37 -07:00
de52f8df79 Attempting to push the docker image to docker hub 2023-06-15 21:51:29 -07:00
23f0c2efae added example compose file 2023-06-15 21:51:15 -07:00
d6ab6fa402 Moving Dockerfile to the root 2023-06-15 21:50:36 -07:00
8c7a5e65fb fixing title and navbar 2023-06-15 21:50:03 -07:00
13 changed files with 109 additions and 67 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
appsettings.json
**/bin/
**/obj/

View File

@ -6,15 +6,17 @@ name: build
steps:
- name: build image
image: plugins/docker
environment:
PAT:
from_secret: DockerPushPat
settings:
repo: 192.168.1.196:5000/jtom38/newsbot-portal
registry: 192.168.1.196:5000
insecure: true
tags:
- latest
username: jtom38
password: $PAT
repo: jtom38/newsbot-portal
trigger:
branch:
- master
- releases/*
---
kind: pipeline

View File

@ -2,6 +2,6 @@ namespace Newsbot.Portal.Blazor.Server;
public static class Global
{
public static HttpClient HttpClient { get; set; }
public static HttpClient? HttpClient { get; set; }
public static string? DefaultInstanceUri { get; set; }
}

View File

@ -7,12 +7,6 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<Content Include="..\.dockerignore">
<Link>.dockerignore</Link>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Newsbot.Collector.Client\Newsbot.Collector.Client.csproj" />
</ItemGroup>

View File

@ -1,7 +1,9 @@
@page "/articles/newest"
@page "/articles/latest"
@using Newsbot.Collector.Client
@using Newsbot.Collector.Client.Domain.Dto
<h3>List Articles</h3>
<PageTitle>Latest</PageTitle>
<h3>Latest Posts</h3>
<div class="container">
<div class="row">
@ -11,7 +13,10 @@
<div class="card" style="width: 18rem;">
<img src="@item.Thumbnail" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">@item.Title</h5>
<h5 class="card-title">
<a href="@item.Url" target="_blank">@item.Title</a>
</h5>
<p class="card-text">@item.PubDate</p>
<p class="card-text">@item.Description</p>
<a href="@item.Url" class="btn btn-primary" target="_blank">View</a>
</div>

View File

@ -2,32 +2,42 @@
@using Newsbot.Collector.Client.Domain.Dto
@using Newsbot.Collector.Client
<h3>ListBySource</h3>
<PageTitle>@Record?.Name</PageTitle>
<h3>@Record?.Name</h3>
<table>
<tr>
<td>Title</td>
<td>Publish Date</td>
</tr>
<div class="container">
<div class="row">
@foreach (var item in Data ??= new List<ArticlesDto>())
{
<tr>
<td>
<a href="@item.Url" target="_blank">@item.Title</a><br/>
</td>
<td>@item.PubDate</td>
</tr>
<div class="col-sm">
<div class="card" style="width: 18rem;">
<img src="@item.Thumbnail" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">
<a href="@item.Url" target="_blank">@item.Title</a>
</h5>
<p class="card-text">@item.PubDate</p>
<p class="card-text">@item.Description</p>
<a href="@item.Url" class="btn btn-primary" target="_blank">View</a>
</div>
</div>
</div>
}
</table>
</div>
</div>
@code {
[Parameter]
public string? Id { get; set; }
List<ArticlesDto>? Data { get; set; }
SourcesDto? Record { get; set; }
protected override async Task OnInitializedAsync()
{
var s = new SourcesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
Record = await s.GetAsync(Guid.Parse(Id ?? ""));
var c = new ArticlesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
var items = await c.ListBySourceAsync(Guid.Parse(Id ?? ""));
Data = items;

View File

@ -1,33 +0,0 @@
@page "/articles/sources"
@using Newsbot.Collector.Client
@using Newsbot.Collector.Client.Domain.Dto
<h3>Select Source</h3>
<table>
<tr>
<td>Source</td>
<td>Name</td>
<td>Type</td>
</tr>
@foreach (var item in Items ??= new List<SourcesDto>())
{
<tr>
<td>@item.Source</td>
<td>
<a href="/articles/sources/@item.Id">@item.Name</a>
</td>
<td>@item.Type</td>
</tr>
}
</table>
@code {
private List<SourcesDto>? Items { get; set; }
protected override async Task OnInitializedAsync()
{
var c = new SourcesClient(Global.HttpClient, Global.DefaultInstanceUri ?? "");
Items = await c.ListAsync();
}
}

View File

@ -1,4 +1,4 @@
@page "/sources/list"
@page "/sources"
@using Newsbot.Collector.Client
@using Newsbot.Collector.Client.Domain.Dto
@ -8,6 +8,7 @@
<tr>
<td>Title</td>
<td>Publish Date</td>
<td>Tags</td>
</tr>
@foreach (var item in Data ??= new List<SourcesDto>())
{
@ -21,12 +22,34 @@
<a href="@item.Url" target="_blank">@item.Name</a><br/>
</td>
<td>@item.Source</td>
<td>@FlattenTags(@item.Tags ??= new List<string>())</td>
<td>
<a href="/articles/sources/@item.Id">View News</a>
</td>
</tr>
}
</table>
@code {
private List<SourcesDto> Data { get; set; }
private List<SourcesDto>? Data { get; set; }
private string FlattenTags(List<string> tags)
{
string res = "";
foreach (var tag in tags)
{
if (res == "")
{
res = tag;
}
else
{
res += $", {tag}";
}
}
return res;
}
protected override async Task OnInitializedAsync()
{

View File

@ -1,6 +1,6 @@
@inherits LayoutComponentBase
<PageTitle>Newsbot.Portal.Blazor.Server</PageTitle>
<PageTitle>Newsbot</PageTitle>
<div class="page">
<div class="sidebar">
@ -8,8 +8,10 @@
</div>
<main>
<div class="top-row px-4">
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
<a href="">Login</a>
</div>
<article class="content px-4">

View File

@ -1,6 +1,6 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">Newsbot.Portal.Blazor.Server</a>
<a class="navbar-brand" href="">Newsbot</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
@ -20,8 +20,8 @@
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="sources/list">
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
<NavLink class="nav-link" href="sources">
<span class="oi oi-list-rich" aria-hidden="true"></span> Sources
</NavLink>
</div>
</nav>

16
docker-compose.yml Normal file
View File

@ -0,0 +1,16 @@
version: "3"
networks:
newsbot:
services:
portal:
image: newsbot.portal:latest
environment:
Logging__LogLevel__Default: "Information"
Logging__LogLevel__Microsoft.AspNetCore: "Warning"
DefaultInstanceUri: "http://192.168.1.225:5001"
ports:
- "5002:80"
networks:
- newsbot

20
makefile Normal file
View File

@ -0,0 +1,20 @@
.PHONY: help
help: ## Shows this help command
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
build: ## builds the application
dotnet restore
dotnet build
pub: ## Build and publish the artifacts
dotnet restore
dotnet publish -o out
rm ./out/appsettings.json
docker-build: ## Generates the docker image
docker build -t "newsbot.portal" .
docker image ls | grep newsbot.portal
docker-run: ## Runs the docker compose
docker compose up -d