openhpibadge

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2021 License: MIT Imports: 9 Imported by: 0

README

open-hpi-badge

Build Status GitHub GoDoc Docker Pulls Test Coverage Release

Tiny go server that serves a custom api endpoint for shields.io to embed openHPI related badges on the web.

go get github.com/romnn/open-hpi-badge/cmd/openhpibadge

You can also download pre built binaries from the releases page, or use the docker image:

docker pull romnn/openhpibadge

For a list of options, run with --help.

Deploying the server

There are a few options for deploying your endpoint:

  1. Running the binary

    go build github.com/romnn/open-hpi-badge/cmd/openhpibadge
    ./openhpibadge --port 8080 --prod
    

    You can also download pre built binaries from the releases page

  2. Using docker

    docker run -p 8080:8080 romnn/open-hpi-badge --port 8080 --prod
    
Using the badges

https://img.shields.io/endpoint?url=...&style=...

Usage as a library

The package can also be imported as a library that exports the core functionality to build your more custom endpoint or service.

import github.com/romnn/open-hpi-badge

For example, you can scrape an openHPI mooc by URL:

course, err := openhpibadge.ScrapeMOOCByURL("https://open.hpi.de/courses/neuralnets2020")
if err != nil {
    panic(err)
}
fmt.Println(course.Participants.Current)
course, err := openhpibadge.ScrapeMOOCByName("neuralnets2020")
if err != nil {
    panic(err)
}
fmt.Println(course.Participants.Current)

For more examples, see examples/.

Development
Prerequisites

Before you get started, make sure you have installed the following tools::

$ python3 -m pip install -U cookiecutter>=1.4.0
$ python3 -m pip install pre-commit bump2version invoke ruamel.yaml halo
$ go get -u golang.org/x/tools/cmd/goimports
$ go get -u golang.org/x/lint/golint
$ go get -u github.com/fzipp/gocyclo
$ go get -u github.com/mitchellh/gox  # if you want to test building on different architectures

Remember: To be able to excecute the tools downloaded with go get, make sure to include $GOPATH/bin in your $PATH. If echo $GOPATH does not give you a path make sure to run (export GOPATH="$HOME/go" to set it). In order for your changes to persist, do not forget to add these to your shells .bashrc.

With the tools in place, it is strongly advised to install the git commit hooks to make sure checks are passing in CI:

invoke install-hooks

You can check if all checks pass at any time:

invoke pre-commit

Note for Maintainers: After merging changes, tag your commits with a new version and push to GitHub to create a release:

bump2version (major | minor | patch)
git push --follow-tags
Internationalization

Developers who want to add or update translations can follow these steps:

cd cmd/openhpibadge
# Update the english ones as you wish and eventually sync them
goi18n extract -outdir intn
# This creates a translate.*.toml with all untranslated messages
goi18n merge -outdir intn intn/active.*.toml
# Merges the translate.*.toml back into the active.*.toml
goi18n merge -outdir intn intn/active.*.toml intn/translate.*.toml
# Stores the files as binary assets
go-bindata intn/

For information on internationalization, see the guide.

Note

This project is still in the alpha stage and should not be considered production ready.

Documentation

Index

Constants

View Source
const Version = "0.1.1"

Version is incremented using bump2version

Variables

This section is empty.

Functions

func ValidOpenHPIMoocURL

func ValidOpenHPIMoocURL()

ValidOpenHPIMoocURL ...

Types

type MOOC

type MOOC struct {
	URL          string
	Title        string
	Participants Participants
	Language     string
	Start        time.Time
	End          time.Time
}

MOOC ...

func ScrapeMOOCByName

func ScrapeMOOCByName(name string) (*MOOC, error)

ScrapeMOOCByName ...

func ScrapeMOOCByURL

func ScrapeMOOCByURL(URL string) (*MOOC, error)

ScrapeMOOCByURL ...

func (*MOOC) Equal

func (m *MOOC) Equal(other *MOOC) (bool, bool)

Equal ...

type Participants

type Participants struct {
	Start, End, Current int
}

Participants ...

Directories

Path Synopsis
cmd
openhpibadge command
Code generated for package main by go-bindata DO NOT EDIT.
Code generated for package main by go-bindata DO NOT EDIT.
examples
example1 command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL