This commit is contained in:
Anton McClure 2020-07-01 20:33:28 -04:00
parent 965bd9ae1e
commit 5065d993a0
No known key found for this signature in database
GPG Key ID: 95F468320CF39788
3 changed files with 74 additions and 0 deletions

30
wiki/index.php Normal file
View File

@ -0,0 +1,30 @@
<?php
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
$title = "Summit News";
?>
<?php require_once '/var/www/tilde/server/header1.php' ?>
<?php require_once '/var/www/tilde/server/header2.php' ?>
<p>If you want to contribute, check out the
<a href="https://tildegit.org/pubnix/site/src/branch/master/wiki">source repo</a> and open a PR!
</p>
<hr />
<div class="content">
<?php
foreach (array_reverse(glob("pages/*.md")) as $page) {
$yaml = $parser->parse(file_get_contents($page))->getYAML();
if (!$yaml["published"]) continue; ?>
<a href="<?=basename($page, ".md")?>"><?=$yaml["title"]?></a> - <?=$yaml["date"]?><br>
<?php }
} else {
require_once '/var/www/tilde/server/header1.php';
$pg = $parser->parse(file_get_contents("pages/{$_GET["page"]}.md"));
$yml = $pg->getYAML();
$PageTitle = $yml['title'];
require_once '/var/www/tilde/server/header2.php';?>
<a href="../">&lt; wiki</a>
<?=$pg->getContent()?>
<?php }
require_once '/var/www/tilde/server/footer.php' ?>

36
wiki/json2mb.rb Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env ruby
require 'yaml'
require 'json'
require 'optparse'
require 'ostruct'
require 'fileutils'
#quit unless our script gets two command line arguments
unless ARGV.length == 3
puts "Dude, not the right number of arguments."
puts "Usage: ruby json2md.rb [-j][-y] json_file.json yaml_file.yaml\n"
exit
end
$json_file = ARGV[1]
$yaml_file = ARGV[2]
options = OpenStruct.new
OptionParser.new do |opt|
opt.on('-j', '--json', 'Convert to JSON') { |o| options.json = o }
opt.on('-y', '--yaml', 'Convert to YAML') { |o| options.yaml = o }
end.parse!
case
when options.yaml == true
y_file = File.open("#{$yaml_file}", 'a')
y_file.write(YAML.dump(JSON.parse(IO.read($json_file))))
y_file.close
puts "Converted to YAML. Output file is #{$yaml_file}"
when options.json == true
j_file = YAML.load_file(File.open("#{$yaml_file}", 'r'))
File.write "#{$json_file}", JSON.pretty_generate(j_file)
puts "Converted to JSON. Output file is #{$json_file}"
end

8
wiki/pages/TEMPLATE Normal file
View File

@ -0,0 +1,8 @@
---
published: false
date: January 1, 1980
title: Title
author: anton
---
Content