Skip to content

Commit

Permalink
documentation and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmaierhofer committed Mar 24, 2022
1 parent 0037851 commit 05ee532
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 45 deletions.
34 changes: 28 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
[![Windows](https://github.com/aardvark-community/screenshotr/actions/workflows/windows.yml/badge.svg)](https://github.com/aardvark-community/screenshotr/actions/workflows/windows.yml)
[![Linux](https://github.com/aardvark-community/screenshotr/actions/workflows/linux.yml/badge.svg)](https://github.com/aardvark-community/screenshotr/actions/workflows/linux.yml)
[![MacOS](https://github.com/aardvark-community/screenshotr/actions/workflows/mac.yml/badge.svg)](https://github.com/aardvark-community/screenshotr/actions/workflows/mac.yml)


# Quickstart

Use the appropriate version of `run` and `screenshotr` for your OS.
- e.g. `./run.sh` and `./screenshotr.sh` for Linux
- or `run.cmd` and `screenshotr.cmd` for Windows

```bash
git clone https://github.com/stefanmaierhofer/screenshotr.git
cd screenshotr
run
```
Open https://localhost:5021/ in a your browser.

```bash
screenshotr import -e https://localhost:5021 --addRandomLabels ./directory/with/images
```

# Server

- `git clone https://github.com/stefanmaierhofer/screenshotr.git`
Expand All @@ -15,13 +34,16 @@
```csharp
using Screenshotr;

var client = await ScreenshotrHttpClient.Create(endpoint.AbsoluteUri);

var filename = "example.jpg";
var buffer = File.ReadAllBytes(filename);
var tags = new [] { "foo", "bar" };
var timestamp = new FileInfo(filename).LastWriteTime;
var foo = await client.ImportScreenshot(buffer, tags, timestamp);
var endpoint = "https://localhost:5021";

var client = await ScreenshotrHttpClient.Connect(endpoint);

await client.ImportScreenshot(
buffer: File.ReadAllBytes(filename),
tags: new[] { "foo", "bar" },
timestamp: new FileInfo(filename).LastWriteTime
);
```

# Command Line Tool
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
### 1.1.0
- documentation and cleanup
### 1.0.0
- init
2 changes: 1 addition & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ PUSHD %~dp0
dotnet tool restore
dotnet paket restore

dotnet build src/screenshotr.sln
dotnet build src/screenshotr.sln -c Release

dotnet publish -c Release -o publish/screenshotr src/screenshotr
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
dotnet tool restore
dotnet paket restore

dotnet build src/screenshotr.sln --configuration Release
dotnet build src/screenshotr.sln -c Release

dotnet publish -c Release -o publish/screenshotr src/screenshotr
5 changes: 1 addition & 4 deletions src/Screenshotr.App/Program.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.FileProviders;
using Screenshotr;
using System.Threading.Tasks;

var builder = WebApplication.CreateBuilder(args);

Console.WriteLine($"[ScreenshotrService] init ...");
var screenshotrEndpoint = builder.Configuration["Screenshotr:Data"];
screenshotrEndpoint = Path.GetFullPath(screenshotrEndpoint);
Console.WriteLine($"[ScreenshotrService] service endpoint {screenshotrEndpoint}");
var screenshotrService = ScreenshotrRepositoryClient.Create(screenshotrEndpoint);
var screenshotrService = ScreenshotrRepositoryClient.Connect(screenshotrEndpoint);
var status = await screenshotrService.GetStatus(new());
Console.WriteLine($"[ScreenshotrService] version {status.Version}");
Console.WriteLine($"[ScreenshotrService] base directory is {screenshotrEndpoint}");
Expand Down
4 changes: 2 additions & 2 deletions src/Screenshotr.Base/ScreenshotClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ public static Task<IScreenshotrApi> Connect(string endpoint)
public static async Task<IScreenshotrApi> Connect(Uri endpoint)
{
IScreenshotrApi client = endpoint.IsFile
? ScreenshotrRepositoryClient.Create(endpoint.AbsolutePath)
: await ScreenshotrHttpClient.Create(endpoint.AbsoluteUri)
? ScreenshotrRepositoryClient.Connect(endpoint.AbsolutePath)
: await ScreenshotrHttpClient.Connect(endpoint.AbsoluteUri)
;

return client;
Expand Down
2 changes: 1 addition & 1 deletion src/Screenshotr.Base/ScreenshotrRepositoryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public ScreenshotrRepositoryClient(Repository repository)
_repo = repository;
}

public static ScreenshotrRepositoryClient Create(string baseDirectory)
public static ScreenshotrRepositoryClient Connect(string baseDirectory)
{
var repo = Repository.Init(baseDirectory);
return new ScreenshotrRepositoryClient(repo);
Expand Down
2 changes: 1 addition & 1 deletion src/Screenshotr.Client/ScreenshotrHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private ScreenshotrHttpClient(string endpoint)
_httpClient = new HttpClient() { BaseAddress = new Uri(endpoint) };
}

public static async Task<ScreenshotrHttpClient> Create(string endpoint)
public static async Task<ScreenshotrHttpClient> Connect(string endpoint)
{
var client = new ScreenshotrHttpClient(endpoint);

Expand Down
32 changes: 3 additions & 29 deletions src/screenshotr/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,9 @@
* Screenshotr CLI
*/

using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Formats.Png;
using SixLabors.ImageSharp.PixelFormats;
using System.Configuration;
using Microsoft.Extensions.Configuration;
using Microsoft.AspNetCore.SignalR.Client;
using System.Collections.Immutable;


//var foo = Custom.Entry.Create("foo", new Foo(Title: "My Title", Custom: new Bla(2022, 03, 10)));
//var j = JsonSerializer.Serialize(foo, Utils.JsonOptions);
//var foo_ = JsonSerializer.Deserialize<Custom.Entry>(j, Utils.JsonOptions);
//var x1 = foo_.GetAs<Foo>();

//var img0 = Image.Load<Rgba32>(File.ReadAllBytes(@"T:\a.jpg"));
//var img1 = Image.Load<Rgba32>(File.ReadAllBytes(@"T:\b.jpg"));
//var thumb0 = Repository.Resize(img0, new Size(256, 256));
//var thumb1 = Repository.Resize(img1, new Size(256, 256));
//await thumb0.SaveAsPngAsync(@"T:\a.thumb.png", new PngEncoder() { ColorType = PngColorType.RgbWithAlpha });
//await thumb1.SaveAsPngAsync(@"T:\b.thumb.png", new PngEncoder() { ColorType = PngColorType.RgbWithAlpha });
//return;

//var uri0 = new Uri("C:/Data/Development");
//var uri1 = new Uri("https://localhost:5001/");
//var foo = Image.Identify(@"T:\IMG_2797.CR2");
using SixLabors.ImageSharp;

//var repo = Repository.Init(@"T:/screenshotr/testrepo");
//var tags = repo.Entries.Values.SelectMany(e => e.Tags).GroupBy(x => x).Select(g => (g.Key, g.Count())).ToArray();
//return;

IConfiguration Configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
Expand Down Expand Up @@ -163,8 +137,8 @@ async Task Import(string[] args)
if (filesAndFolders.Count == 0) { Usage(); return; }

IScreenshotrApi repo = endpoint.IsFile
? ScreenshotrRepositoryClient.Create(endpoint.AbsolutePath)
: await ScreenshotrHttpClient.Create(endpoint.AbsoluteUri)
? ScreenshotrRepositoryClient.Connect(endpoint.AbsolutePath)
: await ScreenshotrHttpClient.Connect(endpoint.AbsoluteUri)
;

var countFilenames = 0;
Expand Down

0 comments on commit 05ee532

Please sign in to comment.