Browse Source

Merge pull request #267 from ostera/feature/index

feature: pages index.
Ruben Vereecken 10 years ago
parent
commit
e5a0bf268b
5 changed files with 38 additions and 0 deletions
  1. 8 0
      Makefile
  2. 1 0
      README.md
  3. 0 0
      pages/index.json
  4. 25 0
      scripts/build_index.rb
  5. 4 0
      scripts/pre-commit

+ 8 - 0
Makefile

@@ -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."

+ 1 - 0
README.md

@@ -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
 - [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)
+– [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!
 

File diff suppressed because it is too large
+ 0 - 0
pages/index.json


+ 25 - 0
scripts/build_index.rb

@@ -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 - 0
scripts/pre-commit

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

Some files were not shown because too many files changed in this diff