Skip to content

Commit

Permalink
Add AGPL license to all files, fix namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
aMytho committed Oct 28, 2023
1 parent e7628ec commit 17ba971
Show file tree
Hide file tree
Showing 72 changed files with 1,511 additions and 1,385 deletions.
3 changes: 2 additions & 1 deletion App.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using Blazored.Toast.Configuration
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Blazored.Toast.Configuration

<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
Expand Down
6 changes: 4 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
Copyright (C)
Copyright (C) Jonathan Shull

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.

To Contact: Create an issue on https://github.com/aMytho/pdf-acc-toolset
1 change: 1 addition & 0 deletions Pages/About.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@page "/about"
<div class="prose-invert prose-sky prose lg:prose-xl w-full max-w-none pb-4">
<h1>
Expand Down
1 change: 1 addition & 0 deletions Pages/Alpha.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@page "/alpha"
<div class="prose-invert prose-sky prose lg:prose-xl w-full max-w-none pb-4">
<h1>
Expand Down
2 changes: 2 additions & 0 deletions Pages/Docs/Content/Tools/AttrubuteModifier.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@

@layout DocumentationLayout
@using Pdf_Acc_Toolset.Services.UI;
@page "/docs/tools/attribute"
Expand Down
1 change: 1 addition & 0 deletions Pages/Docs/Content/Tools/ListGenerator.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@layout DocumentationLayout
@using Pdf_Acc_Toolset.Services.UI;
@page "/docs/tools/list"
Expand Down
1 change: 1 addition & 0 deletions Pages/Docs/Content/Tools/TableGenerator.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@layout DocumentationLayout
@using Pdf_Acc_Toolset.Services.UI;
@page "/docs/tools/table"
Expand Down
1 change: 1 addition & 0 deletions Pages/Docs/Content/Tools/TagGenerator.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@layout DocumentationLayout
@using Pdf_Acc_Toolset.Services.UI;
@page "/docs/tools/tag"
Expand Down
1 change: 1 addition & 0 deletions Pages/Docs/Content/Tools/Tools.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@layout DocumentationLayout
@using Pdf_Acc_Toolset.Services.UI;
@page "/docs/tools"
Expand Down
1 change: 1 addition & 0 deletions Pages/Docs/Documentation.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@page "/docs"

<h1>Documentation</h1>
Expand Down
1 change: 1 addition & 0 deletions Pages/Docs/_Imports.razor
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@layout DocumentationLayout
1 change: 1 addition & 0 deletions Pages/Import/ImportPassword.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services.Util;
@using System.ComponentModel.DataAnnotations;

Expand Down
3 changes: 2 additions & 1 deletion Pages/Import/ImportSettings.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using System.ComponentModel.DataAnnotations;
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using System.ComponentModel.DataAnnotations;
@using Pdf_Acc_Toolset.Services.Pdf.Lang;

<h3 class="text-2xl font-bold">Import Settings</h3>
Expand Down
3 changes: 2 additions & 1 deletion Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using Pdf_Acc_Toolset.Pages.Import;
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Pages.Import;
@inject NavigationManager Navigation;

@page "/"
Expand Down
1 change: 1 addition & 0 deletions Pages/Index.razor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset
using Microsoft.AspNetCore.Components.Forms;
using Pdf_Acc_Toolset.Pages.Import;
using Pdf_Acc_Toolset.Services;
Expand Down
3 changes: 2 additions & 1 deletion Pages/Save.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using Pdf_Acc_Toolset.Pages.Tasks;
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Pages.Tasks;
@inject IJSRuntime JSRuntime;
@page "/export";

Expand Down
1 change: 1 addition & 0 deletions Pages/Save.razor.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using Pdf_Acc_Toolset.Services;
Expand Down
1 change: 1 addition & 0 deletions Pages/SaveComplete.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@inject NavigationManager Navigation;
@page "/complete"

Expand Down
1 change: 1 addition & 0 deletions Pages/Selection/InsertionPoint.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services.Tools.Selection

<label for="insertion">Choose the insertion point:</label>
Expand Down
1 change: 1 addition & 0 deletions Pages/Selection/Limit.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
<p>
Limit the amount of items that can be selected.
This is mostly used to prevent duplicate entries when they are not desired.
Expand Down
1 change: 1 addition & 0 deletions Pages/Selection/Selection.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using System.ComponentModel.DataAnnotations;
<div class="mt-0 text-lg">
<hr class="w-11/12 text-center m-4" />
Expand Down
1 change: 1 addition & 0 deletions Pages/Selection/SelectionType.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Pages.Selection.SelectionTypes

<label for="selection">Choose a selection type:</label>
Expand Down
1 change: 1 addition & 0 deletions Pages/Selection/SelectionTypes/Attribute.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services.Tools.Selection

<p>Choose an attribute to select.</p>
Expand Down
1 change: 1 addition & 0 deletions Pages/Selection/SelectionTypes/DocumentRoot.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
<p>
This selection will target the document root tag. This is the easiest selection method.
</p>
Expand Down
1 change: 1 addition & 0 deletions Pages/Selection/SelectionTypes/Tag.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
<p>
Choose the tag type. This selection will likely <b>select multiple items</b>. Use the limit feature accordingly.
</p>
Expand Down
185 changes: 95 additions & 90 deletions Pages/Selection/SelectionValidator.cs
Original file line number Diff line number Diff line change
@@ -1,114 +1,119 @@

// Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset
using iText.Kernel.Pdf.Tagutils;
using Pdf_Acc_Toolset.Services;
using Pdf_Acc_Toolset.Services.Tools.Selection;
using Pdf_Acc_Toolset.Services.Util;
using Pdf_Acc_Toolset.Services;

namespace Pdf_Acc_Toolset.Pages.Selection
namespace Pdf_Acc_Toolset.Pages.Selection;

public static class SelectionValidator
{
public static class SelectionValidator
/// <summary>
/// Validates a selection model. Shows warnings to the user if invalid
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static bool Validate(Selection.SelectionModel model)
{
/// <summary>
/// Validates a selection model. Shows warnings to the user if invalid
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static bool Validate(Selection.SelectionModel model)
// Check limit
if (model.Limit < 1)
{
// Check limit
if (model.Limit < 1) {
NotificationUtil.Inform(NotificationType.Error, "Invalid limit. Limit must be greater than 1");
return false;
}
NotificationUtil.Inform(NotificationType.Error, "Invalid limit. Limit must be greater than 1");
return false;
}

// Based on selection, check the data entered
// Handle tag errors
if (model.selection.type == SelectionType.SSelectionType.Tag) {
Console.WriteLine(model.selection.type + " is the type");
Console.WriteLine(Enum.IsDefined(typeof(TagType), model.selection.tag));
if (!Enum.IsDefined(typeof(TagType), model.selection.tag))
{
NotificationUtil.Inform(NotificationType.Error, "Invalid tag. Select a valid tag for targeting.");
return false;
}
// Based on selection, check the data entered
// Handle tag errors
if (model.selection.type == SelectionType.SSelectionType.Tag)
{
Console.WriteLine(model.selection.type + " is the type");
Console.WriteLine(Enum.IsDefined(typeof(TagType), model.selection.tag));
if (!Enum.IsDefined(typeof(TagType), model.selection.tag))
{
NotificationUtil.Inform(NotificationType.Error, "Invalid tag. Select a valid tag for targeting.");
return false;
}
// Handle attribute errors
if (model.selection.type == SelectionType.SSelectionType.Attribute) {
if (model.selection.attrWithVal.val == null || model.selection.attrWithVal.val.Length < 1) {
NotificationUtil.Inform(NotificationType.Error, "Invalid attribute value. You must provide a value");
return false;
}
}
// Handle attribute errors
if (model.selection.type == SelectionType.SSelectionType.Attribute)
{
if (model.selection.attrWithVal.val == null || model.selection.attrWithVal.val.Length < 1)
{
NotificationUtil.Inform(NotificationType.Error, "Invalid attribute value. You must provide a value");
return false;
}
}

if (
model.selection.type == SelectionType.SSelectionType.Default
|| model.selection.type == SelectionType.SSelectionType.Tag
)
{
// Prevent inserting adjacent to the document root
if (
model.selection.type == SelectionType.SSelectionType.Default
|| model.selection.type == SelectionType.SSelectionType.Tag
(model.InsertionPoint == Services.Tools.Selection.InsertionPoint.BeforeSelection
|| model.InsertionPoint == Services.Tools.Selection.InsertionPoint.AfterSelection)
&& (model.selection.type == SelectionType.SSelectionType.Default
|| model.selection.tag == TagType.Document)
)
{
// Prevent inserting adjacent to the document root
if (
(model.InsertionPoint == Services.Tools.Selection.InsertionPoint.BeforeSelection
|| model.InsertionPoint == Services.Tools.Selection.InsertionPoint.AfterSelection)
&& (model.selection.type == SelectionType.SSelectionType.Default
|| model.selection.tag == TagType.Document)
)
{
NotificationUtil.Inform(NotificationType.Error,
"You cannot use Before Selection or After Selection on the Document Root. Try a child selection instead!");
return false;
}
NotificationUtil.Inform(NotificationType.Error,
"You cannot use Before Selection or After Selection on the Document Root. Try a child selection instead!");
return false;
}

// Probably fine
return true;
}

/// <summary>
/// Based on the model type, create the proper selection class
/// </summary>
/// <param name="model"></param>
/// <param name="tag">The root tag</param>
/// <returns></returns>
public static Services.Tools.Selection.Selection CreateSelection(Selection.SelectionModel model, TagTreePointer tag)
// Probably fine
return true;
}

/// <summary>
/// Based on the model type, create the proper selection class
/// </summary>
/// <param name="model"></param>
/// <param name="tag">The root tag</param>
/// <returns></returns>
public static Services.Tools.Selection.Selection CreateSelection(Selection.SelectionModel model, TagTreePointer tag)
{
return model.selection.type switch
{
return model.selection.type switch
{
SelectionType.SSelectionType.Default => new DefaultSelection(tag, model.InsertionPoint, model.Limit),
SelectionType.SSelectionType.Attribute => new AttributeSelection(tag, model.InsertionPoint, model.selection.attrWithVal.attr, model.selection.attrWithVal.val, model.Limit),
SelectionType.SSelectionType.Tag => new TagSelection(tag, model.InsertionPoint, model.selection.tag, model.Limit),
_ => null
};
}
SelectionType.SSelectionType.Default => new DefaultSelection(tag, model.InsertionPoint, model.Limit),
SelectionType.SSelectionType.Attribute => new AttributeSelection(tag, model.InsertionPoint, model.selection.attrWithVal.attr, model.selection.attrWithVal.val, model.Limit),
SelectionType.SSelectionType.Tag => new TagSelection(tag, model.InsertionPoint, model.selection.tag, model.Limit),
_ => null
};
}

public static bool CheckSelectionMatches(Selection.SelectionModel selectionModel)
public static bool CheckSelectionMatches(Selection.SelectionModel selectionModel)
{
// Validate selection
if (!Validate(selectionModel))
{
// Validate selection
if (!Validate(selectionModel))
{
return false;
}
return false;
}

// Create selection class from model
TagTreePointer pointer = PdfManager.GetTagRoot();
Services.Tools.Selection.Selection selection = CreateSelection(selectionModel, pointer);
if (selection == null)
{
NotificationUtil.Inform(NotificationType.Error, "No selection class matches the input.");
return false;
}
// Create selection class from model
TagTreePointer pointer = PdfManager.GetTagRoot();
Services.Tools.Selection.Selection selection = CreateSelection(selectionModel, pointer);
if (selection == null)
{
NotificationUtil.Inform(NotificationType.Error, "No selection class matches the input.");
return false;
}

// See if any matches are found
selection.FindElements();
if (selection.FoundSelection())
{
NotificationUtil.Inform(
NotificationType.Success, "Found " + selection.GetSelection().Count + " Element(s)"
);
return true;
} else {
NotificationUtil.Inform(NotificationType.Warning, "No elements found!");
return false;
}
// See if any matches are found
selection.FindElements();
if (selection.FoundSelection())
{
NotificationUtil.Inform(
NotificationType.Success, "Found " + selection.GetSelection().Count + " Element(s)"
);
return true;
}
else
{
NotificationUtil.Inform(NotificationType.Warning, "No elements found!");
return false;
}
}
}
}
1 change: 1 addition & 0 deletions Pages/Tailwind/TailwindPlaceholder.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
<!--
This file holds tailwind styles that cannot be detected by the compiler.
Mostly used for conditional classes.
Expand Down
1 change: 1 addition & 0 deletions Pages/Tasks/IndividualTask.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services;


Expand Down
1 change: 1 addition & 0 deletions Pages/Tasks/TaskInfo.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services;
@using Pdf_Acc_Toolset.Services.Tools;

Expand Down
3 changes: 2 additions & 1 deletion Pages/Tasks/Tasks.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using Pdf_Acc_Toolset.Services;
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services;
@page "/tasks";

<h2 class="text-4xl font-bold">Tasks</h2>
Expand Down
1 change: 1 addition & 0 deletions Pages/Testing.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services.Tools.Selection
@using Pdf_Acc_Toolset.Services
@page "/testing"
Expand Down
1 change: 1 addition & 0 deletions Pages/Toasts/Notification.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Services.Util;
@inject IToastService toastService;

Expand Down
1 change: 1 addition & 0 deletions Pages/ToolPicker.razor
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
@using Pdf_Acc_Toolset.Pages.Tools;
@using Pdf_Acc_Toolset.Services;
@page "/tools"
Expand Down
3 changes: 2 additions & 1 deletion Pages/Toolbox.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="py-4 px-2">
@* Copyright (C) Jonathan Shull - See license file at github.com/amytho/pdf-acc-toolset *@
<div class="py-4 px-2">
<div class="flex flex-wrap">
<button class="bg-emerald-900 hover:bg-emerald-800 p-4 m-2 rounded-lg cursor-pointer"
@onclick="@(e => SelectTool(e, 0))">List Generator</button>
Expand Down
Loading

0 comments on commit 17ba971

Please sign in to comment.