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

Fix generation of app files #96

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:

- name: Build
run: |
rm _apps/*
ruby ./generate-flatpak.rb

- name: Commit
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ bundle install

### Updating Apps

The list of apps is generated with a simple Ruby script. To rebuild the app list, run:
The list of apps is generated with a simple Ruby script. To rebuild the app list, delete the existing files so any removals (e.g. end-of-life apps) are reflected, then run the script:

```shell
rm _apps/*
ruby generate-flatpak.rb
```

Expand Down
15 changes: 4 additions & 11 deletions _layouts/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,10 @@
<header>
<div class="constrain">
<img class="icon" width="64" height="64"
{% for icon in page.icons %}
{% if icon[0] == "64@2" %}
srcset="{{ icon[1] }} 2x"
{% elsif icon[0] == "128" %}
srcset="{{ icon[1] }}"
{% elsif icon[0] == "64" %}
srcset="{{ icon[1] }}"
{% endif %}
{% endfor %}
src="https://cdn.rawgit.com/elementary/icons/c048cf1bdf9d7735638c1cfe1eea64831e46c83f/apps/64/application-default-icon.svg"
alt="{{ page.title }} icon" />
srcset="https://flatpak.elementary.io/repo/appstream/x86_64/icons/64x64/{{ page.app_id }}.png"
src="https://raw.githubusercontent.com/elementary/icons/main/apps/64/application-default-icon.svg"
alt="{{ page.title }} icon"
/>

<h1>{{ page.title }}</h1>
<p>{{ page.developer }}</p>
Expand Down
62 changes: 26 additions & 36 deletions generate-flatpak.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@
require 'nokogiri'
require 'cgi'

###########
# FLATPAK #
###########

# HTTPS doesn't work
componentsDataGz = URI.open('http://flatpak.elementary.io/repo/appstream/x86_64/appstream.xml.gz')
componentsDataGz = URI.open('https://flatpak.elementary.io/repo/appstream/x86_64/appstream.xml.gz')
xmlData = Zlib::GzipReader.new( componentsDataGz ).read
componentsData = Nokogiri::XML(xmlData)
componentsData = Nokogiri::XML(xmlData,&:noblanks)

template = '---
app_id: ((id))
Expand All @@ -25,8 +20,6 @@
dist: flatpak
screenshots:
((screenshots))
icons:
((icons))
color:
primary: "((color_primary))"
primary-text: "((color_text))"
Expand All @@ -38,11 +31,30 @@

((description))'

puts 'about to iterate thru components...'
componentsData.css("components component").each do | component |
next if component.get_attribute("type") != "desktop"
componentsData.css("components component").each do |component|
next unless (component.get_attribute("type") == "desktop" || component.get_attribute("type") == "desktop-application")

component.xpath('name[@xml:lang]').each do |name|
name.remove
end

component.xpath('summary[@xml:lang]').each do |summary|
summary.remove
end

component.xpath('description[@xml:lang]').each do |description|
description.remove
end

component.xpath('keyword[@xml:lang]').each do |keyword|
keyword.remove
end

component.xpath('caption[@xml:lang]').each do |caption|
caption.remove
end

puts "Generating #{component.at_css('name').content}"
puts "\nGenerating #{component.at_css('name').content}"

appFile = template.dup

Expand Down Expand Up @@ -118,33 +130,10 @@
image = component.at_css('image')
if not image.nil?
screenshots += ' - ' + image.content + "\n"

end
# TODO: multiple screenshots
# releaseHash = ""
# unless doc['Screenshots'].nil?
# doc['Screenshots'].each do |screenshot|
# screenshots += " - " + URI::encode("#{mediaBase}/#{screenshot['source-image']['url']}") + "\n"
# releaseHash = screenshot['source-image']['url'].split("/")[0..3].join("/") if releaseHash.empty?
# end
# end
appFile.sub!('((screenshots))', screenshots.rstrip)

icons = ""
icon_prefix = "https://flatpak.elementary.io/repo/appstream/x86_64/icons/"

icon64 = component.at_css('icon[width="64"]')
if not icon64.nil?
icons += ' "64": ' + icon_prefix + '64x64/' + icon64.content + "\n"
end

icon128 = component.at_css('icon[width="128"]')
if not icon128.nil?
icons += ' "128": ' + icon_prefix + '128x128/' + icon128.content + "\n"
end

appFile.sub!('((icons))', icons.rstrip)

releases = ""
# TODO: Releases
# unless doc['Releases'].nil?
Expand All @@ -169,3 +158,4 @@
file.write(appFile)
end
end

17 changes: 5 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,11 @@ <h2>Made for elementary OS</h2>
{% for app in flatpak_apps %}
{% assign id = app.id | remove: '/' %}
<a class="app button {{app.dist}}" href="{{site.baseurl}}/{{app.slug}}" title="{{app.summary}}" id="{{id}}" tabindex="0">
<img width="64" height="64"
{% for icon in app.icons %}
{% if icon[0] == "64@2" %}
srcset="{{icon[1]}} 2x"
{% elsif icon[0] == "128" %}
srcset="{{icon[1]}}"
{% elsif icon[0] == "64" %}
srcset="{{icon[1]}}"
{% endif %}
{% endfor %}
src="https://cdn.rawgit.com/elementary/icons/c048cf1bdf9d7735638c1cfe1eea64831e46c83f/apps/64/application-default-icon.svg"
alt="{{app.title}} icon" />
<img class="icon" width="64" height="64" loading="lazy"
srcset="https://flatpak.elementary.io/repo/appstream/x86_64/icons/64x64/{{ id }}.png"
src="https://raw.githubusercontent.com/elementary/icons/main/apps/64/application-default-icon.svg"
alt="{{ app.title }} icon"
/>

<span class="title">{{ app.title }}</span>
<span class="summary">{{ app.summary }}</span>
Expand Down