Skip to content

Commit

Permalink
add curseforge markdown style
Browse files Browse the repository at this point in the history
  • Loading branch information
DeDiamondPro committed May 30, 2024
1 parent e3032a7 commit ef6a242
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 11 deletions.
13 changes: 12 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ tasks {
versionNumber.set(mod_version)
versionName.set("[${getPrettyVersionRange()}-${platform.loaderStr}] Resourcify $mod_version")
uploadFile.set(remapJar.get().archiveFile as Any)
versionType.set(when {
mod_version.contains("beta", true) -> "beta"
mod_version.contains("alpha", true) -> "alpha"
else -> "release"
})
gameVersions.addAll(getSupportedVersionList())
if (platform.isFabric) {
loaders.add("fabric")
Expand All @@ -301,6 +306,7 @@ tasks {
} else if (platform.isFabric) {
required.project("fabric-api")
required.project("fabric-language-kotlin")
optional.project("modmenu")
}
}
}
Expand All @@ -316,6 +322,7 @@ tasks {
} else if (platform.isFabric) {
requiredDependency("fabric-api")
requiredDependency("fabric-language-kotlin")
optionalDependency("modmenu")
}
})
gameVersionStrings.addAll(getSupportedVersionList())
Expand All @@ -328,7 +335,11 @@ tasks {
} else if (platform.isNeoForge) {
addGameVersion("NeoForge")
}
releaseType = "release"
releaseType = when {
mod_version.contains("beta", true) -> "beta"
mod_version.contains("alpha", true) -> "alpha"
else -> "release"
}
mainArtifact(remapJar.get().archiveFile, closureOf<CurseArtifact> {
displayName = "[${getPrettyVersionRange()}-${platform.loaderStr}] Resourcify $mod_version"
})
Expand Down
14 changes: 12 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
## Resourcify 1.4.0+beta.1

- Add support for CurseForge
- Settings page to configure the default pack source and some other settings
### Major new features
- Add support for CurseForge, you can now browse and install resource packs from CurseForge. There is a new dropdown on the browse page to switch between CurseForge and modrinth.
- Add settings GUI, allowing you to configure the default source. The config can be accessed via the mod menu (on fabric you need the `mod menu` mod to be able to access the config).

### What's next for 1.4.0
Other features that will be added in Resourcify 1.4.0 in a later beta:
- Support expandable spoilers in project descriptions
- Dependency management and automatic installation of dependencies

### Other changes

- Convert backend to an abstract service api, allowing for easier support for more services
- Fix background breaking when using essential (or another mod with universalcraft) in mc 1.20.5+
- Fix crash in case of malformed html in markdown
- Fix localizations not working on 1.12.2 forge
- Suppress some errors that were causing log spam in some scenarios
- Added small bisect hosting ad to the top of the browse page, this is to help support the project and can be disabled in the new settings page

----------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DescriptionPage(screen: ProjectScreen) : UIBlock(color = Color(0, 0, 0, 10
screen.project.getDescription().thenAccept {
Window.enqueueRenderOperation {
try {
markdown(it).constrain {
markdown(it, screen.service.getMarkdownStyle()).constrain {
x = 6.pixels()
y = 6.pixels()
width = 100.percent() - 12.pixels()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package dev.dediamondpro.resourcify.services

import dev.dediamondpro.minemark.elementa.style.MarkdownStyle
import dev.dediamondpro.resourcify.services.ads.DefaultAdProvider
import dev.dediamondpro.resourcify.services.ads.IAdProvider
import dev.dediamondpro.resourcify.util.default
import java.util.concurrent.CompletableFuture

interface IService {
Expand Down Expand Up @@ -35,4 +37,6 @@ interface IService {
fun getSortOptions(): Map<String, String>

fun getAdProvider(): IAdProvider = DefaultAdProvider

fun getMarkdownStyle(): MarkdownStyle = MarkdownStyle.default()
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package dev.dediamondpro.resourcify.services.curseforge

import dev.dediamondpro.minemark.elementa.style.MarkdownStyle
import dev.dediamondpro.minemark.style.HeadingLevelStyleConfig
import dev.dediamondpro.minemark.style.HeadingStyleConfig
import dev.dediamondpro.minemark.style.ImageStyleConfig
import dev.dediamondpro.minemark.style.LinkStyleConfig
import dev.dediamondpro.resourcify.services.ISearchData
import dev.dediamondpro.resourcify.services.IService
import dev.dediamondpro.resourcify.services.ProjectType
import dev.dediamondpro.resourcify.util.*
import org.apache.http.client.utils.URIBuilder
import java.awt.Color
import java.net.URL
import java.util.concurrent.CompletableFuture

Expand Down Expand Up @@ -114,4 +120,19 @@ object CurseForgeService : IService {
"11" to "resourcify.browse.sort.newest",
"3" to "resourcify.browse.sort.updated",
)

override fun getMarkdownStyle(): MarkdownStyle {
return MarkdownStyle(
imageStyle = ImageStyleConfig(SanitizingImageProvider),
linkStyle = LinkStyleConfig(Color(65, 105, 225), ConfirmingBrowserProvider),
headerStyle = HeadingStyleConfig(
HeadingLevelStyleConfig(2f, 12f), // h1
HeadingLevelStyleConfig(1.66f, 10f), // h2
HeadingLevelStyleConfig(1.33f, 8f), // h3
HeadingLevelStyleConfig(1f, 4f), // h4
HeadingLevelStyleConfig(1f, 4f), // h5
HeadingLevelStyleConfig(1f, 4f) // h6
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ fun UIComponent.isHidden(): Boolean = !parent.children.contains(this)

fun markdown(
markdown: String,
style: MarkdownStyle = MarkdownStyle(
imageStyle = ImageStyleConfig(SanitizingImageProvider), linkStyle = LinkStyleConfig(
Color(65, 105, 225), ConfirmingBrowserProvider
)
)
style: MarkdownStyle = MarkdownStyle.default()
): MineMarkComponent {
// Create a MineMark component with our own image and browser provider
return MineMarkComponent(markdown, style)
}
}

fun MarkdownStyle.Companion.default(): MarkdownStyle = MarkdownStyle(
imageStyle = ImageStyleConfig(SanitizingImageProvider), linkStyle = LinkStyleConfig(
Color(65, 105, 225), ConfirmingBrowserProvider
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ object NetworkUtil {

fun clearCache() {
for ((url, future) in currentlyFetching) {
future.cancel(true)
try {
future.cancel(true)
} catch (_: Exception) {
}
currentlyFetching.remove(url)
}
cache.clear()
Expand Down

0 comments on commit ef6a242

Please sign in to comment.