Skip to content

Commit

Permalink
v0.2.0
Browse files Browse the repository at this point in the history
 * Add htmx JS library
 * Add some Bootstrap initialization JS
 * Refactor out inline onerror handler into JS file
 * Refactor common footer
 * Fix favicon
 * Fix bad file separators in URL image file paths
 * Add formatting to many integers
  • Loading branch information
D-Cysteine committed Jan 9, 2023
1 parent 7c3f67e commit 8374048
Show file tree
Hide file tree
Showing 28 changed files with 3,459 additions and 25 deletions.
Binary file modified favicon/favicon.ico
Binary file not shown.
Binary file modified favicon/favicon.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 modified favicon/favicon.xcf
Binary file not shown.
Binary file modified libs/NESQL-Exporter-0.2.0-sql.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ public class WebSecurityConfig {
@Autowired
ExternalConfig externalConfig;

private static final String CONTENT_SECURITY_POLICY = Joiner.on("; ").join(
"default-src 'self'",
// This is the hash of our image onerror handler:
// this.src='/image/missing.png';this.onerror='';
"script-src 'self' 'sha256-KrWF/SaFRimyTg5FZWV3gqZlxM6hGYkkM1k3ePvN71w=' 'unsafe-hashes'");
private static final String CONTENT_SECURITY_POLICY =
Joiner.on("; ").join(
new String[]{"default-src 'self'"});

@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.dcysteine.nesql.server.display.Icon;
import com.github.dcysteine.nesql.server.plugin.base.display.recipe.DisplayRecipe;
import com.github.dcysteine.nesql.server.util.StringUtil;
import com.github.dcysteine.nesql.server.util.UrlBuilder;
import com.github.dcysteine.nesql.sql.base.fluid.Fluid;
import com.github.dcysteine.nesql.sql.base.fluid.FluidGroupRepository;
Expand Down Expand Up @@ -41,7 +42,7 @@ public static Icon buildIcon(Fluid fluid) {
return Icon.builder()
.setDescription(fluid.getLocalizedName())
.setUrl(UrlBuilder.buildFluidUrl(fluid))
.setImageFilePath(fluid.getImageFilePath())
.setImageFilePath(StringUtil.formatFilePath(fluid.getImageFilePath()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.dcysteine.nesql.server.display.Icon;
import com.github.dcysteine.nesql.server.plugin.base.display.recipe.DisplayRecipe;
import com.github.dcysteine.nesql.server.util.Constants;
import com.github.dcysteine.nesql.server.util.NumberUtil;
import com.github.dcysteine.nesql.server.util.UrlBuilder;
import com.github.dcysteine.nesql.sql.base.fluid.FluidGroup;
import com.google.auto.value.AutoValue;
Expand Down Expand Up @@ -30,7 +31,8 @@ public static Icon buildIcon(FluidGroup fluidGroup) {
Icon icon;
if (!fluidGroup.getFluidStacks().isEmpty()) {
int size = fluidGroup.getFluidStacks().size();
String description = String.format("Fluid Group (%d fluid stacks)", size);
String description =
String.format("Fluid Group (%s fluid stacks)", NumberUtil.formatInteger(size));
Icon innerIcon = DisplayFluidStack.buildIcon(fluidGroup.getFluidStacks().first());
if (size == 1) {
description = String.format("Fluid Group (%s)", innerIcon.getDescription());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.dcysteine.nesql.server.display.Icon;
import com.github.dcysteine.nesql.server.plugin.base.display.recipe.DisplayRecipe;
import com.github.dcysteine.nesql.server.util.StringUtil;
import com.github.dcysteine.nesql.server.util.UrlBuilder;
import com.github.dcysteine.nesql.sql.base.item.Item;
import com.github.dcysteine.nesql.sql.base.item.ItemGroupRepository;
Expand Down Expand Up @@ -54,7 +55,7 @@ public static Icon buildIcon(Item item) {
return Icon.builder()
.setDescription(item.getLocalizedName())
.setUrl(UrlBuilder.buildItemUrl(item))
.setImageFilePath(item.getImageFilePath())
.setImageFilePath(StringUtil.formatFilePath(item.getImageFilePath()))
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.dcysteine.nesql.server.display.Icon;
import com.github.dcysteine.nesql.server.plugin.base.display.recipe.DisplayRecipe;
import com.github.dcysteine.nesql.server.util.Constants;
import com.github.dcysteine.nesql.server.util.NumberUtil;
import com.github.dcysteine.nesql.server.util.UrlBuilder;
import com.github.dcysteine.nesql.sql.base.item.ItemGroup;
import com.github.dcysteine.nesql.sql.base.item.ItemRepository;
Expand Down Expand Up @@ -64,7 +65,8 @@ public static Icon buildIcon(ItemGroup itemGroup, ItemRepository itemRepository)
String url = UrlBuilder.buildItemGroupUrl(itemGroup);
Icon icon;
if (!itemStacks.isEmpty()) {
String description = String.format("Item Group (%d item stacks)", size);
String description =
String.format("Item Group (%s item stacks)", NumberUtil.formatInteger(size));
Icon innerIcon = DisplayItemStack.buildIcon(itemStacks.first());
if (size == 1) {
description = String.format("Item Group (%s)", innerIcon.getDescription());
Expand All @@ -77,8 +79,9 @@ public static Icon buildIcon(ItemGroup itemGroup, ItemRepository itemRepository)
} else if (!wildcardItemStacks.isEmpty()) {
String description =
String.format(
"Wildcard Item Group (%d keys, %d item stacks)",
wildcardItemStacks.size(), size);
"Wildcard Item Group (%s keys, %s item stacks)",
NumberUtil.formatInteger(wildcardItemStacks.size()),
NumberUtil.formatInteger(size));
Icon innerIcon =
DisplayWildcardItemStack.buildIcon(wildcardItemStacks.first(), itemRepository);
if (wildcardItemStacks.size() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.dcysteine.nesql.server.Main;
import com.github.dcysteine.nesql.server.display.Icon;
import com.github.dcysteine.nesql.server.util.Constants;
import com.github.dcysteine.nesql.server.util.UrlBuilder;
import com.github.dcysteine.nesql.sql.base.item.Item;
import com.github.dcysteine.nesql.sql.base.item.ItemRepository;
Expand Down Expand Up @@ -29,17 +30,18 @@ public static Icon buildIcon(
icon = Icon.builder()
.setDescription(
String.format(
"Wildcard Item Stack (%d)", wildcardItemStack.getItemId()))
"Wildcard Item Stack (#%d)", wildcardItemStack.getItemId()))
.setUrl(UrlBuilder.getMissingUrl())
.setTopLeft(Integer.toString(wildcardItemStack.getItemId()))
.setImageFilePath(Constants.MISSING_IMAGE)
.setTopLeft(String.format("#%d", wildcardItemStack.getItemId()))
.setBottomRight(Integer.toString(wildcardItemStack.getStackSize()))
.build();
} else {
Icon itemIcon = DisplayItem.buildIcon(items.get(0));
icon = itemIcon.toBuilder()
.setDescription(
String.format("Wildcard Item Stack (%s)", itemIcon.getDescription()))
.setTopLeft(Integer.toString(wildcardItemStack.getItemId()))
.setTopLeft(String.format("#%d", wildcardItemStack.getItemId()))
.setBottomRight(Integer.toString(wildcardItemStack.getStackSize()))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.dcysteine.nesql.server.plugin.base.display.item.DisplayItemStackWithProbability;
import com.github.dcysteine.nesql.server.util.Constants;
import com.github.dcysteine.nesql.server.Main;
import com.github.dcysteine.nesql.server.util.NumberUtil;
import com.github.dcysteine.nesql.server.util.UrlBuilder;
import com.github.dcysteine.nesql.sql.base.item.ItemRepository;
import com.github.dcysteine.nesql.sql.base.recipe.Dimension;
Expand Down Expand Up @@ -77,9 +78,13 @@ public static Icon buildIcon(Recipe recipe) {
description += String.format(" (%s)", innerIcon.getDescription());
} else if (numFluidOutputs > 0) {
description +=
String.format(" (%d items, %d fluids)", numItemOutputs, numFluidOutputs);
String.format(
" (%s items, %s fluids)",
NumberUtil.formatInteger(numItemOutputs),
NumberUtil.formatInteger(numFluidOutputs));
} else {
description += String.format(" (%d items)", numItemOutputs);
description +=
String.format(" (%s items)", NumberUtil.formatInteger(numItemOutputs));
}

icon = innerIcon.toBuilder()
Expand All @@ -92,7 +97,8 @@ public static Icon buildIcon(Recipe recipe) {
if (numFluidOutputs == 1) {
description += String.format(" (%s)", innerIcon.getDescription());
} else {
description += String.format(" (%d fluids)", numFluidOutputs);
description +=
String.format(" (%s fluids)", NumberUtil.formatInteger(numFluidOutputs));
}

icon = innerIcon.toBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.dcysteine.nesql.server.util;

import java.io.File;

public class StringUtil {
// Static class.
private StringUtil() {}

public static String formatFilePath(String filePath) {
return filePath.replace(File.separatorChar, '/');
}
}
Binary file modified src/main/resources/static/favicon.ico
Binary file not shown.
25 changes: 25 additions & 0 deletions src/main/resources/static/htmx/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BSD 2-Clause License

Copyright (c) 2020, Big Sky Software
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 8374048

Please sign in to comment.