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

grafx 2.8.3174,71 #203523

Merged
merged 2 commits into from
Mar 3, 2025
Merged
Changes from all commits
Commits
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
31 changes: 26 additions & 5 deletions Casks/g/grafx.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
cask "grafx" do
version "2.8.3104,67"
sha256 "c637e21fcdbd5f3ee77e12c3d637b21f22cceedc2d7082f18e874685f9346cf6"
version "2.8.3174,71"
sha256 "b0207e50bddf10e289d03ba2dd52e7fe1c5c5ee32293cc2441eb9e0aac536891"

url "https://pulkomandy.tk/projects/GrafX#{version.major}/downloads/#{version.csv.second}"
name "GrafX2"
desc "256 colour painting program"
homepage "https://pulkomandy.tk/projects/GrafX#{version.major}"

# Upstream lists a number of files for macOS on the download page
# (https://pulkomandy.tk/projects/GrafX2/downloads) but it's not clear which
# variant we should use. The homepage links to grafx2.eu as the "Main website"
# and its download page links to a specific download for macOS, so we check
# that instead. The full version isn't listed on the page, so we have to check
# the filename in the `Content-Disposition` header of the download response.
# NOTE: The grafx2.eu download page uses an iframe from grafx2.chez.com for
# the page content, so we're checking the iframe URL.
livecheck do
url "https://pulkomandy.tk/projects/GrafX2/downloads"
regex(%r{href=.*?/downloads/(\d+)[\s'">]+Grafx2\.app-x86_64-sdl2-v?(\d+(?:\.\d+)+)\.zip}im)
url "http://grafx2.chez.com/index.php?static3/downloads"
regex(%r{Mac\s*OS.*?href=.*?/projects/GrafX#{version.major}/downloads/(\d+)/?["' >]}im)
strategy :page_match do |page, regex|
page.scan(regex).map { |match| "#{match[1]},#{match[0]}" }
# Match the ID for the macOS download
download_id = page.scan(regex).flatten.max_by { |v| Version.new(v) }
next unless download_id

# Fetch the headers for the download URL
download_headers = Homebrew::Livecheck::Strategy.page_headers("https://pulkomandy.tk/projects/GrafX#{version.major}/downloads/#{download_id}")
next if download_headers.blank?

# Match the version from the filename in the `Content-Disposition` header
merged_headers = download_headers.reduce(&:merge)
version = merged_headers["content-disposition"]&.[](/Grafx\d+\.app.*?v?(\d+(?:\.\d+)+)/i, 1)
next unless version

"#{version},#{download_id}"
end
end

Expand Down
Loading