浏览代码

Merge pull request #267 from ostera/feature/index

feature: pages index.
Ruben Vereecken 10 年之前
父节点
当前提交
e5a0bf268b
共有 5 个文件被更改,包括 38 次插入0 次删除
  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
 - [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!
 
 

文件差异内容过多而无法显示
+ 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

部分文件因为文件数量过多而无法显示