Commit 77f56353 authored by Nico Alt's avatar Nico Alt

Use Jekyll plugin

https://gitlab.com/fdroid/jekyll-fdroid

I received a lot of help from @fxedel doing this.
parent 11d0e3fb
......@@ -5,3 +5,4 @@ node_modules/*
*.sublime-project
*.sublime-workspace
*.log
Gemfile.lock
......@@ -12,13 +12,10 @@ test:
- export LANG=en_US.UTF-8
- export LANGUAGE=en_US:en
- export LC_ALL=en_US.UTF-8
- apt-get install -y curl
- curl -sL https://deb.nodesource.com/setup_6.x | bash -
- apt-get install -y nodejs
- npm install
- nodejs build.js
- gem install jekyll jekyll-include-cache jekyll-feed jekyll-paginate-v2 jekyll-redirect-from
- jekyll build -d test
- apt-get install -y zlib1g-dev
- gem install jekyll bundler
- bundle install
- bundle exec jekyll build -d test
artifacts:
paths:
- test
......@@ -35,13 +32,10 @@ pages:
- export LANG=en_US.UTF-8
- export LANGUAGE=en_US:en
- export LC_ALL=en_US.UTF-8
- apt-get install -y curl
- curl -sL https://deb.nodesource.com/setup_6.x | bash -
- apt-get install -y nodejs
- npm install
- nodejs build.js
- gem install jekyll jekyll-include-cache jekyll-feed jekyll-paginate-v2 jekyll-redirect-from
- jekyll build -d public
- apt-get install -y zlib1g-dev
- gem install jekyll bundler
- bundle install
- bundle exec jekyll build -d public
artifacts:
paths:
- public
......
source 'https://rubygems.org'
gem "jekyll"
group :jekyll_plugins do
gem "jekyll-feed"
gem "jekyll-include-cache"
gem "jekyll-paginate-v2"
gem "jekyll-redirect-from"
#gem "jekyll-fdroid", :path => "../jekyll-fdroid"
gem 'jekyll-fdroid', :git => 'https://gitlab.com/fdroid/jekyll-fdroid.git', :branch => 'master'
end
......@@ -6,51 +6,27 @@ It is based on Jekyll and you can find the development version
## Building
Always navigate into the root directory of this repository before you run the build commands.
#### Generate app data (optional, only for browsing)
You need to have Node.js 6.x installed. On Debian and Ubuntu, you can download a script that sets up a ppa which lets you install Node.js with the package manager.
Or have a look at the [official website](https://nodejs.org/en/download/) for other distros and installation possibilities.
````
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
````
For the very first time (or if the `package.json` file has been updated in newer versions),
you have to install all dependencies needed for Node.js by running:
````
npm install
````
To generate the app data, execute the `build.js` script each time:
````
nodejs build.js
````
#### Build website with Jekyll
You need to have Jekyll 3.2+ installed.
This is easily done with Gem which depends on Ruby 2.0+. You also need to install the dependencies described in `_config.yml` with gem.
You need to have Jekyll 3.2+ installed what is easily done with Gem which depends on Ruby 2.0+.
Because of the F-Droid plugin you need to have zlib installed.
```
sudo apt-get install ruby-full build-essential
sudo gem install jekyll jekyll-include-cache jekyll-paginate-v2 jekyll-redirect-from
sudo apt-get install ruby-full build-essential zlib1g-dev
sudo gem install jekyll bundler
bundle install
```
To build the website, run:
```
jekyll build
bundle exec jekyll build
```
Or if you want to build and also start a local server at localhost:4000, use:
If you want to build the website and
serve it with a local server at [localhost:4000](http://localhost:4000),
use:
```
jekyll serve
bundle exec jekyll serve
```
## License
......
......@@ -16,7 +16,6 @@ include:
- "_pages"
collections:
apps:
output: true
docs:
output: true
permalink: /docs/:title/
......@@ -25,7 +24,8 @@ gems:
- jekyll-paginate-v2
- jekyll-redirect-from
- jekyll-feed
- jekyll-fdroid
feed:
path: feed
pagination:
enabled: true
\ No newline at end of file
enabled: true
<a class="app-header" href="{{ include.app.url | prepend: site.baseurl }}">
<a class="app-header" href="{{ include.app.beautifulURL | prepend: site.baseurl }}">
<img class="app-icon" src="https://f-droid.org/repo/icons/{{ include.app.icon }}" />
<div class="app-info">
......@@ -10,4 +10,4 @@
<span class="app-summary">{{ include.app.summary }}</span><span class="app-license">{{ include.app.license }}</span>
</div>
</div>
</a>
\ No newline at end of file
</a>
......@@ -18,8 +18,8 @@ layout: default
</header>
<div class="post-content">
{{ content }}
<div class="app-description">
{{ page.description }}
</div>
</article>
\ No newline at end of file
const fs = require("fs");
const xml = require("node-xml");
// delete old apps
require("rimraf").sync("_apps/*");
// download xml data
require('https').get('https://f-droid.org/repo/index.xml', (res) => {
let data = '';
let time1 = (new Date()).getTime();
let time2;
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
const apps = [];
let currentApp;
let property;
// get apps by parsing the xml
new xml.SaxParser(function(cb) {
let isPackage = false;
cb.onStartElementNS(function(elem, attrs, prefix, uri, namespaces) {
switch (elem) {
case "application":
currentApp = attrs[0][1];
apps.push({});
break;
case "id":
property = "package";
break;
case "added":
property = "added";
break;
case "name":
property = "title";
break;
case "summary":
property = "summary";
break;
case "license":
property = "license";
break;
case "icon":
property = "icon";
break;
case "lastupdated":
property = "lastupdated";
break;
case "package":
isPackage = true;
break;
}
});
cb.onEndElementNS(function(elem, prefix, uri) {
switch (elem) {
case "package":
isPackage = false;
break;
}
})
cb.onCharacters(function(chars) {
if (property !== undefined && !isPackage) {
apps[apps.length - 1][property] = chars;
}
property = undefined;
});
}).parseString(data);
// create new apps directory if necessary
if (!fs.existsSync('_apps')) {
fs.mkdirSync('_apps');
}
// create app files
for (let app of apps) {
let appData = [
`---`,
`layout: app`,
`permalink: "/packages/apps/${app.package}/"`,
`redirect_from:`,
` - "/app/${app.package}/"`,
`---`
];
for (let property of ['package', 'title', 'summary', 'license', 'icon', 'added', 'lastupdated']) {
if (app[property] !== undefined) {
appData.splice(
appData.length-1, 0,
`${property}: "${app[property]}"`
);
}
}
fs.writeFileSync(`_apps/${app.package}.html`, appData.join('\n'));
}
});
});
{
"name": "fdroid-website",
"version": "1.0.0",
"description": "Jekyll and Node.js code of the website that is going to be used on F-Droid.org.",
"main": "build.js",
"dependencies": {
"node-xml": "^1.0.2",
"rimraf": "^2.5.4"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/fdroid/fdroid-website.git"
},
"author": "",
"license": "AGPL-3.0",
"bugs": {
"url": "https://gitlab.com/fdroid/fdroid-website/issues"
},
"homepage": "https://gitlab.com/fdroid/fdroid-website/blob/master/README.md"
}
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