Skip to content

fedora-infra/asknot-ng

Repository files navigation

asknot-ng

Build Status

Ask not what $ORG can do for you, but what you can do for $ORG.

Written by @ralphbean. Inspired by the original work of Josh Matthews, Henri Koivuneva, and others.

I stumbled upon and loved the original whatcanidoformozilla.org and wanted to deploy it for the Fedora Community but I found that I couldn’t easily change the questions and links that were presented. A year went by and in 2015 I wrote this: “asknot-ng”.

The gist of this “next generation” rewrite is to make it as configurable as possible. There is a primary script, asknot-ng.py that works like a static-site generator. It takes as input three things:

  • A questions file, written in yaml (see the example or Fedora’s file). You’ll have to write your own one of these.
  • A template file, written in mako (the default should work for everybody).
  • A ‘theme’ argument to specify what CSS to use. The default is nice enough, but you’ll probably want to customize it to your own use case.

We have a Fedora instance up and running if you’d like to poke it.

Translation status

Tools

  1. HTML5 - The Structure.
  2. CSS3 - The Style.
  3. Javascript - The Functions.
  4. Jquery - JavaScript libraries to select, remove, clone, and modify different elements on the page.
  5. Bootstrap - Bootstrap is a front end framework used to design responsive web pages and applications.

Requirements

The site-generator script is written in Python, so you’ll need that. Furthermore, see requirements.txt or just run::

$ sudo dnf install python-mako PyYAML python-virtualenv

The script can optionally generate an svg visualizing your question tree. This requires pygraphviz which you could install like so:

$ sudo dnf install python-pygraphviz

Giving it a run

Install the requirements, first.

Clone the repo::

$ git clone https://github.com/fedora-infra/asknot-ng.git
$ cd asknot-ng

Create a virtualenv into which you can install the module.

$ virtualenv --system-site-packages venv
$ source venv/bin/activate
$ python setup.py develop

Run the script with the Fedora configuration::

$ ./asknot-ng.py templates/index.html questions/fedora.yml l10n/fedora/locale --theme fedora
Wrote build/en/index.html

and open up build/en/index.html in your favorite browser.

Preparing Translations

First, setup a virtualenv, install Babel, and build the egg info.

$ virtualenv venv
$ source venv/bin/activate
$ pip install Babel
$ python setup.py develop

Then, extract the translatable strings:

$ python setup.py extract_messages --output-file l10n/fedora/locale/asknot-ng.pot --input-dir=.

Container

Asknot can be build and released as a container, to do so you can use the provided Dockerfile.

Releasing a container
podman build -t asknot .

The Dockerfile makes use of multistage container build, meaning that in a first stage a container is used to prepare the translations and build the static pages then the static content is copied to a second container which is used to serve this content.

Running Container
podman run --name=asknot -d -p 8080:80 --net=host localhost/asknot
Composing Container

Asknot can be build and released as a container, in other similar way to do so you can use the provided Dockerfile-compose file.

podman-compose up -d
Verifiying

In your Favorite Browser Just type:

 localhost:8080

Application Deployment

asknot-ng currently runs on Fedora infrastructure Openshift instance. There are 2 deployments one in staging and one in production.

The deployment of new version to these environment is managed from the github repository, thanks to the following 2 branches staging and production.

Staging

To deploy a change to the staging environment you need to push the commits to the staging branch, then Openshift will trigger a build using the Dockerfile located in this repository and deploy the new application.

Production

To deploy a change in the production environment you need to push the commits to the production branch, then Openshift will trigger a build using the Dockerfile located in this repository and deploy the new application.

Contributing back

asknot-ng is licensed GPLv3+ and we’d love to get patches back containing even the things you might not think we want. If you have a questions file for your repo, a modified template, or a CSS theme for your use case, please send them to us. It would be nice to build a library of deployments so we can all learn.

Note: While the application is licensed GPLv3+, The Fedora 22 wallpaper used is licensed under a Creative Commons Attribution 4 License.

Of course, bug reports and patches to the main script are appreciated as always.

Happy Hacking!