Commit 78c4eeaf authored by Hans-Christoph Steiner's avatar Hans-Christoph Steiner

Merge branch 'category-browser' into 'master'

Browse by category

See merge request !52
parents d6b8d7ae fe215c83
Pipeline #140777735 failed with stage
in 2 minutes and 28 seconds
---
layout: page
title: " "
---
{% assign app_category_escaped = page.app_category | replace: '&', '&' %}
{% assign filtered_packages = site.packages | where_exp: "item", "item.categories contains app_category_escaped" | sort: "last_updated" | reverse %}
<h3>{{ site.data.strings.app_categories[page.app_category] }}</h3>
<div id="package-list">
{% for package in filtered_packages %}
{% include package-list-item.html package=package %}
{% endfor %}
</div>
---
layout: page
title: " "
pagination:
enabled: true
collection: packages
per_page: 30
trail:
before: 4
after: 4
permalink: '/:num/'
sort_field: 'title'
title: ':title'
---
<div id="full-package-list">
{% for package in paginator.posts %}
{% include package-list-item.html package=package %}
{% endfor %}
{% include_cached browse-paginator-navigation.html paginator=paginator permalink=page.dir %}
</div>
---
layout: page
title: " "
---
{% for app_category in site.app_categories %}
{% assign app_category_escaped = app_category | replace: '&', '&amp;' %}
{% assign filtered_packages = site.packages | where_exp: "item", "item.categories contains app_category_escaped" | sort: "last_updated" | reverse %}
{% if filtered_packages.size > 0 %}
<h3>{{ site.data.strings.app_categories[app_category] }}</h3>
<div id="package-list">
{% for package in filtered_packages limit: 3 %}
{% include package-list-item.html package=package %}
{% endfor %}
</div>
{% assign app_category_url = app_category | replace: ' & ', '_' %}
<p><a href="{{ site.baseurl }}/categories/{{ app_category_url }}/">{{ site.data.strings.app_categories.show_all_packages | replace: '%d', filtered_packages.size }}</a></p>
{% endif %}
{% endfor %}
......@@ -22,4 +22,5 @@ require "jekyll/FDroidLastUpdatedPackagesTag"
require "jekyll/FDroidLatestPackagesTag"
require "jekyll/FDroidPackageDetailGenerator"
require "jekyll/FDroidPackageDetailPage"
require "jekyll/FDroidCategoryDetailPage"
require "jekyll/FDroidRepoInfoTag"
......@@ -24,7 +24,7 @@ module Jekyll
@name = "index.html"
self.process(@name)
self.read_yaml((File.expand_path "../../_pages", File.dirname(__FILE__)), 'browse.html')
self.read_yaml((File.expand_path "../../_pages", File.dirname(__FILE__)), 'categories-overview.html')
end
end
end
# F-Droid's Jekyll Plugin
#
# Copyright (C) 2017 Nico Alt
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
module Jekyll
class FDroidCategoryDetailPage < ReadYamlPage
# @param [Jekyll::Site] site
# @param [string] base
# @param [string] app_category
def initialize(site, base, app_category)
@site = site
@base = base
@dir = 'categories'
# Avoid special characters in URL, otherwise language support doesn't work
app_category_url = app_category.dup
app_category_url.sub! ' & ', '_'
@name = "#{app_category_url}/index.html"
self.process(@name)
self.read_yaml(get_layout_dir, 'category-packages.html')
self.data['app_category'] = app_category
end
def get_layout_dir()
layout_dir_override = File.join(site.source, '_layouts')
if File.exists? File.join(layout_dir_override, 'category-packages.html')
layout_dir_override
else
File.expand_path '../../_layouts', File.dirname(__FILE__)
end
end
end
end
......@@ -37,12 +37,6 @@ module Jekyll
site.config["sass"]["load_paths"] << (File.expand_path "../../_sass", File.dirname(__FILE__))
end
# Enable pagination
if site.config["pagination"].nil? || site.config["pagination"].empty?
site.config["pagination"] = Hash.new
end
site.config["pagination"]["enabled"] = true
index = FDroid::IndexV1.download(site.config["fdroid-repo"], site.active_lang || 'en_US')
# Generate detail page for every package
......@@ -56,6 +50,12 @@ module Jekyll
site.pages << FDroidPackageDetailPage.new(site, site.source, package)
site.collections["packages"].docs << FDroidPackageDetailPage.new(site, site.source, package)
end
# Generate category pages with filtered package list
site.config["app_categories"].each do |category|
site.pages << FDroidCategoryDetailPage.new(site, site.source, category)
end
# Generate browsing pages
site.includes_load_paths << (File.expand_path "../../_includes", File.dirname(__FILE__))
site.pages << FDroidBrowsingPage.new(site, site.source)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment