forked from jf44/sol2kml
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmd2html.php
More file actions
145 lines (117 loc) · 3.44 KB
/
md2html.php
File metadata and controls
145 lines (117 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
// index.php
// JF 2009 - 2017
//define ('DEBUG', 0); // debogage maison !:))
define ('DEBUG', 1);
define ('DEBUG2', 0);
require_once('include/utils.php'); // utilitaires divers
require_once('lang/GetStringClass.php'); // localisation
require_once('sol_include/sol_config.php'); // utilitaires de connexion au serveur SOL
$version="0.1-20170331";
$lang='en'; // par defaut
$filename='README.md';
$module='sol2kml'; // pour charger le bon fichier de langue !
$tlanglist=array(); // Langues disponibles
if (!empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS'])) {
$uri = 'https://';
} else {
$uri = 'http://';
}
//$url_serveur_local = $uri.$_SERVER['HTTP_HOST'].':'.$_SERVER['SERVER_PORT'].get_url_pere($_SERVER['SCRIPT_NAME']);
$url_serveur_local = $uri.$_SERVER['HTTP_HOST'].get_url_pere($_SERVER['SCRIPT_NAME']);
// DEBUG
//echo "<br>URL : $url_serveur_local<br />\n";
$dir_serveur = dirname($_SERVER['SCRIPT_FILENAME']);
// DEBUG
//echo "<br>Répertoire serveur : $dir_serveur<br />\n";
// Nom du script chargé dynamiquement.
$phpscript=substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"],'/')+1);
$appli=$uri.$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"];
//echo $appli;
//exit;
// COOKIES INPUT
if (isset($_COOKIE["sollang"]) && !empty($_COOKIE["sollang"])){
$lang=$_COOKIE["sollang"];
}
// GET
if (isset($_GET['lang'])){
$lang=$_GET['lang'];
}
if (isset($_GET['filename'])){
$filename=$_GET['filename'];
}
if (isset($lang) && ($lang!="") ){
setcookie("sollang", $lang);
}
// Localisation linguistique
$al= new GetString();
$tlanglist=$al->getAllLang('./lang',$module);
if ($aFile = $al->setLang('./lang', $lang, $module)){
require_once($aFile); // pour la localisation linguistique
}
entete();
echo '<div id="console">
';
if (empty($filename)){
$filename='README.md';
}
echo '<article id=\'parsed\'><noscript id=\'md\'>';
echo get_readmefile($filename);
echo '</noscript></article>
';
echo '
<script src=js/mmd/mmd.min.js></script>
<script>
onload = function()
{
var $ = function(id){ return document.getElementById(id); };
var src = $(\'md\').textContent;
var then = Date.now();
var html = mmd(src);
var now = Date.now();
// document.title += \' Just parsed \'+ src.length +\' md -> \'+ html.length +\'b html in \'+ (now-then) +\'ms\';
$(\'parsed\').innerHTML = html;
}
</script>
';
echo '</div>
';
enqueue();
// ----------
function get_readmefile($filename){
if (file_exists($filename)){
return file_get_contents($filename);
}
else{
return ("# ERROR\n\n**Not any $filename down there**\n");
}
}
//---------
function entete(){
global $appli;
global $filename;
global $al;
global $lang;
global $tlanglist;
echo '<!DOCTYPE html>
<html dir="ltr" lang="fr" xml:lang="fr">
<head>
<title>Sailonline Tools</title>
<meta name="ROBOTS" content="none,noarchive">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="Author" content="JF">
<meta name="description" content="SailOnLine Tools"/>
<link rel="author" title="Auteur" href="mailto:jean.fruitet@free.fr">
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
';
echo '<div id="bandeau">
<h1 align="center">'.$filename.'</h1>
<p align="center">
<a href="index.php?lang='.$lang.'">'.$al->get_string('home').'</a> - <a href="'.$appli.'?lang='.$lang.'&filename=README.md">Readme Doc</a> - <a href="'.$appli.'?lang='.$lang.'&filename=DEVELOPER.md">Developer Doc</a>
</p>
</div>
';
}
?>