Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(iss-1)!: version 2.0.0 overhaul #2

Merged
merged 93 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
c3cb8fb
feat(repo): Update instances of .io to .com
AJCJ1 Oct 14, 2024
5b94c0c
feat(test): update tests to use compatible .net version for macOS
AJCJ1 Oct 14, 2024
3eda4ec
fix(repo): prepare repo for nuget package upload
AJCJ1 Oct 15, 2024
308dd47
feat(repo): Use class input UrlboxOptions to improve typing
AJCJ1 Oct 16, 2024
31ee319
feat(repo): Upgrade package from dotnet 2.0 -> 6.0
AJCJ1 Oct 16, 2024
d5bb2b3
feat(repo): Install dependencies for using env vars locally and in gh…
AJCJ1 Oct 16, 2024
70a4a70
feat(repo): add webhook secret to Urlbox overload, and urlbox api end…
AJCJ1 Oct 16, 2024
8dbc95c
feat(repo): implement post sync and post async methods, including res…
AJCJ1 Oct 16, 2024
a33a6db
feat(repo): add tests for render and render async endpoints for succe…
AJCJ1 Oct 16, 2024
a26001c
fix(repo): ensure strings are included in array string representations
AJCJ1 Oct 17, 2024
37b80e5
fix(repo): change cookies to obj and fix string interpretation of array
AJCJ1 Oct 17, 2024
59ff448
fix(repo): update cookie type to be tighter to string OR string[]
AJCJ1 Oct 17, 2024
dd1bd68
feat(repo): add a fromCredentials static method, and a webhook verifi…
AJCJ1 Oct 17, 2024
3ccd5ea
fix(repo): update validator to handle header edge cases
AJCJ1 Oct 18, 2024
82f2f43
feat(repo): add contribution guide including how to set env vars for …
AJCJ1 Oct 18, 2024
fe67dc0
fix(repo): ensure options only accepts one of html or url but not both
AJCJ1 Oct 18, 2024
d093059
feat(repo): add metadata/side renders as types to sync response, with…
AJCJ1 Oct 22, 2024
0297648
fix(repo): make download method throw error with urlbox error message
AJCJ1 Oct 22, 2024
17982f5
fix(repo): update urlbox sln to recognise the urlbox.csproj file
AJCJ1 Oct 22, 2024
b791199
feat(repo): implement takeScreenshot
AJCJ1 Oct 29, 2024
3475fc1
feat(repo): create Urlbox interface + factory for Dependency injection
AJCJ1 Oct 29, 2024
02e18cf
feat(tests): Add tests for checking Urlbox can be instantiated via DI…
AJCJ1 Oct 29, 2024
f0dc1f3
feat(tests): enable parallel testing
AJCJ1 Oct 29, 2024
70d2003
feat(repo): add helper methods takemp4 takepdf takewithmeta takemobil…
AJCJ1 Nov 5, 2024
5cb10b9
feat(repo): add section on render links and the api reference in readme:
AJCJ1 Nov 8, 2024
b22f1e9
feat(repo): create an options builder for fluent options creation, wi…
AJCJ1 Nov 14, 2024
ac9af6f
feat(repo): add in tests for validating screenshot options
AJCJ1 Nov 14, 2024
b1f38fc
feat(repo): implement validation for engine version
AJCJ1 Nov 18, 2024
a840aa5
feat(repo): upgrade package version to 2.0.0, add changelog to readme
AJCJ1 Nov 18, 2024
4f362d4
fix(repo): rename namespace from screenshots to UrlboxSDK
AJCJ1 Nov 25, 2024
68fb56f
feat(repo): add signed and unsigned variants of render link calls
AJCJ1 Nov 25, 2024
bdd9d5c
fix(repo): update snakeCaseNamingPolicy with tests
AJCJ1 Nov 25, 2024
a0e62d1
feat(repo): introduce UrlboxException, thrown on err with more meanin…
AJCJ1 Nov 25, 2024
9aac91c
fix(repo): update urlboxexception to not use init
AJCJ1 Nov 26, 2024
fadbce2
fix(repo): wip - enable nullable on project, introduce enums, tests p…
AJCJ1 Nov 26, 2024
9eb55fc
fix(repo): handle nullable warnings that came out from enabling nulla…
AJCJ1 Nov 27, 2024
6af28dd
feat(repo): add final enum types to options
AJCJ1 Nov 29, 2024
3a3d5f7
fix(repo): make ints nullable in options
AJCJ1 Nov 29, 2024
e16e7dd
feat(repo): add ability to override base url, with tests
AJCJ1 Nov 29, 2024
03d5747
feat(repo): add ability to use Render() and RenderAsync() with a dict…
AJCJ1 Nov 29, 2024
6e2e858
fix(repo): rename target project for tests
AJCJ1 Nov 29, 2024
13fbb50
feat(repo): add tests for getstatus
AJCJ1 Nov 29, 2024
9ff0180
feat(repo): add an extension method for DI easy injectionwhich takes …
AJCJ1 Dec 3, 2024
94d70bc
feat(repo): add a class to mock http requests with use of moq
AJCJ1 Dec 11, 2024
504bd1a
feat(repo): add partial class to implement constructor for the quickt…
AJCJ1 Dec 11, 2024
65d1f12
feat(repo): add internal constructor for testing, which allows mockin…
AJCJ1 Dec 11, 2024
b9a4237
feat(repo): extract value validation logic for reusability
AJCJ1 Dec 11, 2024
7bb05de
feat(repo): make render links signed by default
AJCJ1 Dec 11, 2024
b8f3b35
feat(repo): update the readme with the new DI instructions
AJCJ1 Dec 13, 2024
1553854
fix(repo): move private methods in urlbox to bottom of file, add over…
AJCJ1 Dec 16, 2024
ef4c30d
feat(repo): add example for fail on options
AJCJ1 Dec 16, 2024
0b8d9b5
chore(repo): ensure images show in readme, add example outputs
AJCJ1 Dec 16, 2024
5c80496
chore(repo): add examples to TOC
AJCJ1 Dec 16, 2024
31441ce
chore(repo): remove full page and mobile helper methods
AJCJ1 Dec 16, 2024
154824f
chore(repo): add examples for full page and mobile
AJCJ1 Dec 16, 2024
4965ba8
feat(repo): implement extraction methods for side formats
AJCJ1 Dec 17, 2024
3363422
feat(repo): update readme with extraction methods and how to use IDic…
AJCJ1 Dec 17, 2024
6d15666
fix(repo): ensure nullable fields dont show up in render response
AJCJ1 Dec 18, 2024
a5e54f4
feat(repo): ensure user agent is added to each request
AJCJ1 Dec 18, 2024
a5a8305
feat(repo): add gh test running workflow
AJCJ1 Dec 20, 2024
589d6d9
feat(repo): add in a new project showing example and webhooks
AJCJ1 Dec 20, 2024
5dcecbc
fix(repo): ensure null values dont show in responses
AJCJ1 Dec 20, 2024
7bb4b5c
feat(repo): add deployment workflow less deploy step
AJCJ1 Dec 20, 2024
881a40c
feat(repo): add in push to nuget
AJCJ1 Dec 23, 2024
339ae01
refactor(repo): comment out deploy step and test release step in depl…
AJCJ1 Jan 21, 2025
dcee320
refactor(repo): add release please configs
AJCJ1 Jan 21, 2025
22d55f1
refactor(repo): use latest ubuntu to stop warning
AJCJ1 Jan 21, 2025
1e9fcc1
refactor(repo): update release please action to latest
AJCJ1 Jan 21, 2025
2ab55b0
refactor(repo): remove release type
AJCJ1 Jan 21, 2025
ac11619
chore(repo): trivial change in readme to trigger release-please
AJCJ1 Jan 21, 2025
a2df740
refactor(repo): change * for . in root def for release please config
AJCJ1 Jan 21, 2025
3798d48
chore(repo): trivial change in readme to trigger release-please
AJCJ1 Jan 21, 2025
5ecf39e
refactor(repo): add annotations for release please auto-versioning
AJCJ1 Jan 21, 2025
df43ab2
refactor(repo): add back in deploy step less nuget push
AJCJ1 Jan 21, 2025
665ef1c
refactor(repo): run deploy job on push to release-please-test, not on…
AJCJ1 Jan 21, 2025
5bf6fbb
chore(release-please-test): release 1.1.0
github-actions[bot] Jan 21, 2025
d26a246
refactor(repo): trivial change to readme to test release
AJCJ1 Jan 21, 2025
0b7139d
chore(release-please-test): release 1.2.0
github-actions[bot] Jan 21, 2025
9683c49
Merge pull request #17 from urlbox/release-please--branches--release-…
AJCJ1 Jan 21, 2025
9cea489
refactor(repo): ensure release step outputs to deploy step in nuget a…
AJCJ1 Jan 21, 2025
3b28897
chore(release-please-test): release 1.3.0
github-actions[bot] Jan 21, 2025
f931022
Merge pull request #19 from urlbox/release-please--branches--release-…
AJCJ1 Jan 21, 2025
9c04c96
refactor(repo): ensure release step outputs to deploy step in nuget a…
AJCJ1 Jan 21, 2025
7237d5e
chore(release-please-test): release 1.4.0
github-actions[bot] Jan 21, 2025
5a3d8e9
Merge pull request #20 from urlbox/release-please--branches--release-…
AJCJ1 Jan 21, 2025
34fed37
refactor(repo): trivial change to readme to test release
AJCJ1 Jan 21, 2025
bf728eb
chore(release-please-test): release 1.5.0
github-actions[bot] Jan 21, 2025
1c18daf
Merge pull request #22 from urlbox/release-please--branches--release-…
AJCJ1 Jan 21, 2025
82b8a99
refactor(repo): update versions back to 1.0.2
AJCJ1 Jan 21, 2025
46c2a65
chore(release-please-test): release 1.1.0 (#24)
github-actions[bot] Jan 21, 2025
51ab438
chore(release-please-test): release 1.2.0 (#25)
github-actions[bot] Jan 21, 2025
28dfb5c
chore(release-please-test): release 1.3.0 (#26)
github-actions[bot] Jan 21, 2025
5b8fa4f
chore(repo): ensure deploy action only runs when merging to master, a…
AJCJ1 Jan 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/deploy_to_nuget.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy to NuGet

on:
push:
branches:
- master

permissions:
contents: write
pull-requests: write

jobs:
release:
name: Release Using Release Please
runs-on: ubuntu-24.04
strategy:
matrix:
dotnet-version: [6.0]
steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v4

# Set up .NET
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
cache: true
cache-dependency-path: "./UrlboxSDK"

# Restore dependencies
- name: Restore dependencies
run: dotnet restore ./UrlboxSDK

# Run tests
- name: Run tests
run: dotnet test

# https://github.com/googleapis/release-please/blob/72b0ab360c3d6635397e8b02f4d3f9f53932e23c/docs/customizing.md
- name: Create Release
id: create_release
uses: googleapis/release-please-action@v4
with:
target-branch: release-please-test
outputs:
release_created: ${{ steps.create_release.outputs.release_created }}

deploy:
needs: release
if: ${{ needs.release.outputs.release_created }}
name: Push to NuGet registry
runs-on: ubuntu-24.04
strategy:
matrix:
dotnet-version: [6.0]
steps:
# Build the project
- name: Build the project
run: dotnet build ./UrlboxSDK --configuration Release --no-restore

# Pack the NuGet package somewhere unique
- name: Pack NuGet package
run: dotnet pack --configuration Release --no-build --output ./package

# Push the NuGet package to NuGet.org
- name: Publish to NuGet
run: dotnet nuget push "./package/*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

28 changes: 28 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: run tests

on:
push:

jobs:
test:
permissions:
contents: read
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [6.0]
steps:
- name: Checkout urlbox-dotnet
uses: actions/checkout@v4

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
cache: true
cache-dependency-path: "./UrlboxSDK"

- name: Install dependencies
run: dotnet restore

- name: Run tests
run: dotnet test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ Thumbs.db

# dotCover
*.dotCover

.idea
4 changes: 4 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
".": "1.3.0"
}

673 changes: 673 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions Example/Example.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../UrlboxSDK/UrlboxSDK.csproj" />
</ItemGroup>

</Project>
95 changes: 95 additions & 0 deletions Example/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using UrlboxSDK.DI.Extension;
using UrlboxSDK;
using UrlboxSDK.Response.Resource;
using UrlboxSDK.Exception;
using UrlboxSDK.Options.Resource;
using UrlboxSDK.Webhook.Resource;
using System.Text.Json;

var builder = WebApplication.CreateBuilder(args);

// Add Urlbox to the service container
builder.Services.AddUrlbox(options =>
{
// TODO Replace these with your keys from the dashboard: https://urlbox.com/dashboard/api
options.Key = "YOUR PUBLISHABLE API KEY HERE";
options.Secret = "YOUR SECRET KEY HERE";
// TODO optionally add this in to test out webhooks
options.WebhookSecret = "YOUR WEBHOOK SECRET KEY HERE";
// if you need to use one of our specific subdomains
// options.BaseUrl = "https://api-eu.urlbox.com";
});

var app = builder.Build();

// Urlbox gets injected by the service container
app.MapGet("/", async (HttpContext context, IUrlbox urlbox) =>
{
try
{
// Use the static .Options() method to choose your options
UrlboxOptions options = Urlbox.Options(url: "https://urlbox.com/docs")
// Play around with various options here
.Format(Format.Jpeg)
// Want to test out webhooks? see the POST endpoint below
// .WebhookUrl("https://YOUR NGROK FORWARDING ENDPOINT/webhook/urlbox")
.Build();

// Runs an async render, polls for success
// AsyncUrlboxResponse takeScreenshotResponse = await urlbox.TakeScreenshot(options);

// Runs an async render, gives status response
AsyncUrlboxResponse renderAsyncResponse = await urlbox.RenderAsync(options);

// Runs an sync render, waits for success before returning
// SyncUrlboxResponse renderSyncResponse = await urlbox.Render(options);

return Results.Json(new
{
message = "Screenshot generated!",
// ResponseFromTakeScreenshot = takeScreenshotResponse,
ResponseFromRenderAsync = renderAsyncResponse,
// ResponseFromRenderSync = renderSyncResponse
});
}
// Want to test how the exception looks? try this as the url in options: "https://notresolvableurlbox.com"
catch (UrlboxException ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.RequestId);
return Results.Json(new { message = "Failed to generate screenshot, urlbox exception", error = ex.Message, reqId = ex.RequestId });
}
});

/*
Webhook Example:

1. Make sure you've set your webhook secret in your Urlbox instantiation (line 16)
2. Get ngrok (make an account and install on your computer) https://ngrok.com/
3. Run this project with `dotnet run`.
4. Using ngrok expose the localhost port the .net server runs on EG for 5096 `ngrok http 5096`
4. Take the ngrok forwarding address shown in CLI EG https://2c85-80-41-190-113.ngrok-free.app and
replace the above .WebhookUrl() arg with it in your options, including the /webhook/urlbox endpoint.
5. Make a request to the GET endpoint "/" above with one of the render methods, and Urlbox will make a POST to your ngrok endpoint /webhook/urlbox.
EG: curl -i http://localhost:5096
*/
app.MapPost("/webhook/urlbox", async (HttpContext context, IUrlbox urlbox) =>
{
using StreamReader stream = new StreamReader(context.Request.Body);

if (!context.Request.Headers.TryGetValue("x-urlbox-signature", out var headerValue))
{
throw new Exception("Header 'x-urlbox-signature' not found.");
}

UrlboxWebhookResponse verifiedResponse = urlbox.VerifyWebhookSignature(headerValue.ToString(), await stream.ReadToEndAsync());

string json = JsonSerializer.Serialize(verifiedResponse, new JsonSerializerOptions
{
WriteIndented = true
});

Console.WriteLine(json);
});

app.Run();
38 changes: 38 additions & 0 deletions Example/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:52163",
"sslPort": 44353
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5096",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7078;http://localhost:5096",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": false,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
8 changes: 8 additions & 0 deletions Example/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions Example/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Binary file added Examples/highlight.pdf
Binary file not shown.
35 changes: 35 additions & 0 deletions Examples/html.html

Large diffs are not rendered by default.

Binary file added Examples/javascript.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Examples/mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Examples/mp4.mp4
Binary file not shown.
Binary file added Examples/pdf.pdf
Binary file not shown.
Binary file added Images/gh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/projectKeys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/urlbox-graphic.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/urlbox-png.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading