Skip to content

Commit

Permalink
Added ability to adjust a sponsors display rate (#1070)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixoi authored and Katrix committed May 12, 2023
1 parent 2df1a46 commit 4ff9111
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 49 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up NodeJS
uses: actions/setup-node@v3
with:
node-version: 16.16.0

- name: Set up JDK
uses: actions/setup-java@v1
with:
Expand Down
11 changes: 8 additions & 3 deletions ore/app/views/home.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@

@import controllers.sugar.Requests.OreRequest
@import ore.OreConfig
@import ore.Sponsor
@()(implicit messages: Messages, flash: Flash, request: OreRequest[_], config: OreConfig, assetsFinder: AssetsFinder)

@randomSponsor = @{
val logos = config.sponge.sponsors
val sponsors = config.sponge.sponsors

val index = new Random().nextInt(logos.size)
logos(index)
val totalWeight = sponsors.map(_.weight).sum
var randomNumber = Random.nextInt(totalWeight)

sponsors.find { sponsor =>
randomNumber < sponsor.weight || { randomNumber -= sponsor.weight; false }
}.getOrElse(sponsors.last)
}

@scripts = {
Expand Down
2 changes: 1 addition & 1 deletion ore/conf/messages
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ general.docs = Docs
general.javadocs = Javadocs
general.plugins = Plugins
general.getsponge = Downloads
general.irc = Chat
general.discord = Discord
general.edit = Edit
general.cancel = Cancel
general.save = Save
Expand Down
37 changes: 27 additions & 10 deletions ore/conf/ore-default-settings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -234,30 +234,47 @@ sponge {

# Sponsors from high to low donation amounts
sponsors = [
{
"name": "BisectHosting",
"image": "images/sponsors/bisecthosting.svg",
"link": "https://bisecthosting.com/sponge",
"weight": 37
},
{
"name": "Apex Hosting",
"image": "images/sponsors/apexhosting.png",
"link": "https://apexminecrafthosting.com/"
"link": "https://apexminecrafthosting.com/",
"weight": 27
},
{
"name": "Minecraft Index",
"image": "images/sponsors/minecraftindex.svg",
"link": "https://minecraftindex.net/",
"weight": 17
},
{
"name": "Shockbyte",
"image":"images/sponsors/shockbyte.png",
"link": "https://shockbyte.com/",
"weight": 10
},
{
"name": "CreeperHost",
"image": "images/sponsors/creeperhost.svg",
"link": "https://billing.creeperhost.net/link.php?id=8"
"link": "https://billing.creeperhost.net/link.php?id=8",
"weight": 1
},
{
"name": "JetBrains",
"image": "images/sponsors/jetbrains.svg",
"link": "https://www.jetbrains.com/"
"link": "https://www.jetbrains.com/",
"weight": 1
},
{
"name": "YourKit",
"image": "images/sponsors/yourkit.png",
"link": "https://www.yourkit.com/"
},
{
"name": "Minecraft Index",
"image": "images/sponsors/minecraftindex.svg",
"link": "https://minecraftindex.net/"
},
"link": "https://www.yourkit.com/",
"weight": 1
}
]
}
1 change: 1 addition & 0 deletions ore/public/images/sponsors/bisecthosting.svg
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 ore/public/images/sponsors/shockbyte.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion oreClient/src/main/resources/assets/entries/font-awesome.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
faSadTear, faCheckCircle as farCheckCircle, faClock
} from '@fortawesome/free-regular-svg-icons'

import { faDiscord } from '@fortawesome/free-brands-svg-icons'

config.autoAddCss = false;

library.add(fasStar, fasGem, faEye, faDownload, faServer, faComment, faWrench, faMoneyBillAlt, faPuzzlePiece, faGamepad,
Expand All @@ -23,6 +25,6 @@ library.add(fasStar, fasGem, faEye, faDownload, faServer, faComment, faWrench, f
faCheck, faReply, faSave, faTimes, faPencilAlt, faArrowLeft, faCog, faPlayCircle, faEdit, faKey, faCalendar, faFile,
faUpload, faPaperPlane, faPlusSquare, faSearch, farStar, faExternalLinkAlt, faMinusSquare, faBug, faFileArchive,
faTerminal, faStopCircle, faClipboard, faWindowClose, faSadTear, faUnlockAlt, farGem, faLink, farCheckCircle, faClock,
faInfo, fasCheckCircle, faTimesCircle, faEyeSlash, faUserTag);
faInfo, fasCheckCircle, faTimesCircle, faEyeSlash, faUserTag, faDiscord);

dom.watch();
48 changes: 24 additions & 24 deletions oreClient/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1102,38 +1102,38 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@fortawesome/fontawesome-common-types@6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.1.1.tgz#7dc996042d21fc1ae850e3173b5c67b0549f9105"
integrity sha512-wVn5WJPirFTnzN6tR95abCx+ocH+3IFLXAgyavnf9hUmN0CfWoDjPT/BAWsUVwSlYYVBeCLJxaqi7ZGe4uSjBA==
"@fortawesome/fontawesome-common-types@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.4.0.tgz#88da2b70d6ca18aaa6ed3687832e11f39e80624b"
integrity sha512-HNii132xfomg5QVZw0HwXXpN22s7VBHQBv9CeOu9tfJnhsWQNd2lmTNi8CSrnw5B+5YOmzu1UoPAyxaXsJ6RgQ==

"@fortawesome/fontawesome-svg-core@6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.1.1.tgz#3424ec6182515951816be9b11665d67efdce5b5f"
integrity sha512-NCg0w2YIp81f4V6cMGD9iomfsIj7GWrqmsa0ZsPh59G7PKiGN1KymZNxmF00ssuAlo/VZmpK6xazsGOwzKYUMg==
"@fortawesome/fontawesome-svg-core@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.4.0.tgz#3727552eff9179506e9203d72feb5b1063c11a21"
integrity sha512-Bertv8xOiVELz5raB2FlXDPKt+m94MQ3JgDfsVbrqNpLU9+UE2E18GKjLKw+d3XbeYPqg1pzyQKGsrzbw+pPaw==
dependencies:
"@fortawesome/fontawesome-common-types" "6.1.1"
"@fortawesome/fontawesome-common-types" "6.4.0"

"@fortawesome/free-brands-svg-icons@6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@fortawesome/free-brands-svg-icons/-/free-brands-svg-icons-6.1.1.tgz#3580961d4f42bd51dc171842402f23a18a5480b1"
integrity sha512-mFbI/czjBZ+paUtw5NPr2IXjun5KAC8eFqh1hnxowjA4mMZxWz4GCIksq6j9ZSa6Uxj9JhjjDVEd77p2LN2Blg==
"@fortawesome/free-brands-svg-icons@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@fortawesome/free-brands-svg-icons/-/free-brands-svg-icons-6.4.0.tgz#c785cf5563231eadc5ef5f8cd0274e0b8920433f"
integrity sha512-qvxTCo0FQ5k2N+VCXb/PZQ+QMhqRVM4OORiO6MXdG6bKolIojGU/srQ1ptvKk0JTbRgaJOfL2qMqGvBEZG7Z6g==
dependencies:
"@fortawesome/fontawesome-common-types" "6.1.1"
"@fortawesome/fontawesome-common-types" "6.4.0"

"@fortawesome/free-regular-svg-icons@6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@fortawesome/free-regular-svg-icons/-/free-regular-svg-icons-6.1.1.tgz#3f2f58262a839edf0643cbacee7a8a8230061c98"
integrity sha512-xXiW7hcpgwmWtndKPOzG+43fPH7ZjxOaoeyooptSztGmJxCAflHZxXNK0GcT0uEsR4jTGQAfGklDZE5NHoBhKg==
"@fortawesome/free-regular-svg-icons@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@fortawesome/free-regular-svg-icons/-/free-regular-svg-icons-6.4.0.tgz#cacc53bd8d832d46feead412d9ea9ce80a55e13a"
integrity sha512-ZfycI7D0KWPZtf7wtMFnQxs8qjBXArRzczABuMQqecA/nXohquJ5J/RCR77PmY5qGWkxAZDxpnUFVXKwtY/jPw==
dependencies:
"@fortawesome/fontawesome-common-types" "6.1.1"
"@fortawesome/fontawesome-common-types" "6.4.0"

"@fortawesome/free-solid-svg-icons@6.1.1":
version "6.1.1"
resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.1.1.tgz#3369e673f8fe8be2fba30b1ec274d47490a830a6"
integrity sha512-0/5exxavOhI/D4Ovm2r3vxNojGZioPwmFrKg0ZUH69Q68uFhFPs6+dhAToh6VEQBntxPRYPuT5Cg1tpNa9JUPg==
"@fortawesome/free-solid-svg-icons@6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.4.0.tgz#48c0e790847fa56299e2f26b82b39663b8ad7119"
integrity sha512-kutPeRGWm8V5dltFP1zGjQOEAzaLZj4StdQhWVZnfGFCvAPVvHh8qk5bRrU4KXnRRRNni5tKQI9PBAdI6MP8nQ==
dependencies:
"@fortawesome/fontawesome-common-types" "6.1.1"
"@fortawesome/fontawesome-common-types" "6.4.0"

"@gar/promisify@^1.0.1":
version "1.1.2"
Expand Down
4 changes: 2 additions & 2 deletions orePlayCommon/app/ore/OreConfig.scala
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ object OreConfig {
case class Sponge(
logo: String,
service: String,
sponsors: Seq[Logo]
sponsors: Seq[Sponsor]
)

case class Auth(
Expand Down Expand Up @@ -223,4 +223,4 @@ object OreConfig {
)
}

case class Logo(name: String, image: String, link: String)
case class Sponsor(name: String, image: String, link: String, weight: Int)
4 changes: 2 additions & 2 deletions orePlayCommon/app/views/layout/header.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<li><a href="https://www.spongepowered.org/downloads">
<i class="fa-fw fas fa-download"></i>@messages("general.getsponge")
</a></li>
<li><a href="https://www.spongepowered.org/chat">
<i class="fa-fw fas fa-comment"></i>@messages("general.irc")
<li><a href="https://discord.gg/sponge">
<i class="fa-fw fab fa-discord"></i>@messages("general.discord")
</a></li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion project/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object Settings {
val scalaVer = "2.13.6"

val commonSettings = Seq(
version := "2.0.0-M2.9",
version := "2.0.0-M2.10",
scalaVersion := scalaVer,
scalacOptions ++= Seq(
"-deprecation",
Expand Down
Loading

0 comments on commit 4ff9111

Please sign in to comment.