1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-01 07:15:22 +02:00

Merge pull request #267 from ostera/feature/index

feature: pages index.
This commit is contained in:
Ruben Vereecken 2015-04-12 21:31:45 +02:00
commit e5a0bf268b
5 changed files with 39 additions and 0 deletions

8
Makefile Normal file
View file

@ -0,0 +1,8 @@
index:
@TLDRHOME=`pwd` ./scripts/build_index.rb
@echo "Index rebuilt."
setup:
@cp ./scripts/pre-commit .git/hooks
@chmod +x .git/hooks/pre-commit
@echo "Git pre-commit hook installed."

View file

@ -28,6 +28,7 @@ You can access these pages on your computer using one of the following clients:
- [Exilir client](https://github.com/edgurgel/tldr): binaries available soon - [Exilir client](https://github.com/edgurgel/tldr): binaries available soon
- [C++ client](https://github.com/tldr-pages/tldr-cpp-client): `brew tap tldr-pages/tldr && brew install tldr` - [C++ client](https://github.com/tldr-pages/tldr-cpp-client): `brew tap tldr-pages/tldr && brew install tldr`
- [Android client](https://github.com/gianasista/tldr-viewer): available on [Google Play](https://play.google.com/store/apps/details?id=de.gianasista.tldr_viewer) - [Android client](https://github.com/gianasista/tldr-viewer): available on [Google Play](https://play.google.com/store/apps/details?id=de.gianasista.tldr_viewer)
– [Web client](https://github.com/ostera/tldr.js): try tldr on your browser [here](https://ostera.github.io/tldr.js)!
Let us know if you are building one and we can add it to this list! Let us know if you are building one and we can add it to this list!

1
pages/index.json Normal file

File diff suppressed because one or more lines are too long

25
scripts/build_index.rb Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env ruby
require "json"
commands = {}
Dir["#{ENV["TLDRHOME"]}/pages/**/*.md"].each do |file|
# "./pages/osx/xsltproc.md",
file = file.split("/")
name = file.pop().gsub(".md","")
platform = file.pop()
unless commands.key?(name)
commands[name] = {
name: name,
platform: [platform]
}
else
commands[name][:platform] << platform
end
end
commands = commands.map do |k,v| v end
File.write("#{ENV["TLDRHOME"]}/pages/index.json", {commands: commands}.to_json)

4
scripts/pre-commit Normal file
View file

@ -0,0 +1,4 @@
#!/bin/sh
make index
git add ./pages/index.json