Skip to content

Commit

Permalink
Too much stuff for a commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
jpxd committed Sep 13, 2015
1 parent 4c28ac3 commit 0af02bf
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 673 deletions.
13 changes: 7 additions & 6 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#Node Wiki
# Node Wiki

A simple git based wiki system for markdown files written in node.js.

[![screenshot](https://raw.githubusercontent.com/besker/nodewiki/master/static/screenshot_new.jpg)](http://github.com/besker/nodewiki)
##What it does
[![screenshot](https://raw.githubusercontent.com/jpxd/nodewiki/master/static/screenshot.jpg)](http://github.com/jpxd/nodewiki)

## What it does

This is a simple wiki system that uses markdown (text) files as its
database. It reads and writes to the text files in the directory it was
Expand All @@ -14,7 +15,7 @@ automatically does a git commit on each file save.

## Install

npm install nodewiki -g
npm install -g jpxd/nodewiki

*note: you may need sudo*

Expand All @@ -37,7 +38,7 @@ If your computer is connected to a network, then the `--local` option is
highly recommended.


###Options
### Options
`-a <IPv4_addr>`
`--addr=<IPv4_addr>`
`--addr <IPv4_addr>`
Expand All @@ -64,7 +65,7 @@ Display a short help message.
Listen on <port> rather than 8888. The default port can be changed
from 8888 by setting the PORT environment variable.

###Examples
### Examples

`nodewiki`
Starts node wiki
Expand Down
8 changes: 3 additions & 5 deletions lib/allowedExtensions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
var path = require("path");
var path = require('path');

// checks if a given file name is allowed (this is usually for reading or writing)
function checkExtension(fileName) {
if (path.extname(fileName) == ".md" || path.extname(fileName) == ".mdown" || path.extname(fileName) == ".markdown" || path.extname(fileName) == ".mkd" || path.extname(fileName) == ".mkdn" || path.extname(fileName) == ".txt") {
return true;
}
return false;
var allowedExtensions = ['.md', '.mdown', '.markdown', '.mkd', '.mkdn', '.txt'];
return allowedExtensions.indexOf(path.extname(fileName)) >= 0;
}

exports.checkExtension = checkExtension;
4 changes: 2 additions & 2 deletions lib/getDir.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fs = require("fs");
var allowedExtensions = require("./allowedExtensions");
var fs = require('fs');
var allowedExtensions = require('./allowedExtensions');

// get contents of current directory
function getDir(directory) {
Expand Down
2 changes: 1 addition & 1 deletion lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function commit(file, directory) {
// create new git process which adds the file needed to be commited
var git = child_process.spawn('git', ['add', file.name], {
cwd: directory
})
});

git.stdout.on('data', function (data) {
console.log('git: ' + data);
Expand Down
12 changes: 6 additions & 6 deletions lib/mdserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ var languageOverrides = {
js: 'javascript',
clj: 'clojure',
html: 'xml'
}
};

marked.setOptions({
// gfm: true,
// pendantic: false,
// sanitize: true,
highlight: function (code, lang) {
if (languageOverrides[lang]) lang = languageOverrides[lang];
return hljs.LANGUAGES[lang] ? hljs.highlight(lang, code).value : hljs.highlightAuto(code).value;
return (lang && hljs.getLanguage(lang)) ? hljs.highlight(lang, code).value : hljs.highlightAuto(code).value;
}
});


function sendFile(file, directory, socket) {
// make sure only markdown files are sent
if (allowedExtensions.checkExtension(file.name) == true) {
if (allowedExtensions.checkExtension(file.name) === true) {
fs.readFile(directory + file.name, 'utf-8', function (err, data) {
if (err) {
console.log('read file error: ' + err);
Expand All @@ -38,7 +38,7 @@ function sendFile(file, directory, socket) {
});
} else {
// only send the markdown file if there have been no errors
var markdownParsed = marked(data)
var markdownParsed = marked(data);
socket.emit('readFileReply', {
fileContents: markdownParsed,
error: {
Expand All @@ -62,7 +62,7 @@ function sendFile(file, directory, socket) {
}

function saveFile(file, directory, socket) {
if (allowedExtensions.checkExtension(file.name) == true && typeof file.content != 'undefined') {
if (allowedExtensions.checkExtension(file.name) === true && typeof file.content != 'undefined') {
// only allow markdown files to be saved
console.log('saving file');
fs.writeFile(directory + file.name, file.content, function (err, data) {
Expand All @@ -80,7 +80,7 @@ function saveFile(file, directory, socket) {
fileName: file.name
});
// if (process.argv[2] == 'git' || process.argv[2] == '--git'){
if (nodewiki.gitMode == true) {
if (nodewiki.gitMode === true) {
git.commit(file, directory);
console.log('git.commit called');
} else {
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nodewiki",
"version": "0.1.3",
"author": "Nafis Hossain <nhoss2@gmail.com>",
"version": "0.2.0",
"author": "jpxd <jpxd@omnix.io>",
"description": "A simple wiki that uses markdown files",
"license": "MIT",
"scripts": {
Expand All @@ -16,12 +16,12 @@
"dependencies": {
"connect": "2.3.x",
"socket.io": "0.9.x",
"marked": "0.2.9",
"marked": "0.3.5",
"posix-getopt": "1.0.x",
"highlight.js": "7.3.x"
"highlight.js": "8.8.0"
},
"repository": {
"type": "git",
"url": "git://github.com/nhoss2/nodewiki.git"
"url": "git://github.com/jpxd/nodewiki.git"
}
}
Binary file added screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions static/css/style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
html, body {
font-size: 100%;
overflow-x: hidden;
/* Prevent scroll on narrow devices */
font-family: 'PT Sans', sans-serif;
}

#header {
margin-top: 35px;
}

#content #content_header #edit_save_buttons {
Expand Down Expand Up @@ -84,6 +88,19 @@ html, body {
padding-bottom: 5px;
}

#markdown_content > h1:first-child {
margin-top: 0;
}

pre code {
padding: 0;
background: inherit;
font-family: 'PT Mono', monospace;
}

img {
max-width: 100%;
}

/*
* Menu
Expand Down Expand Up @@ -126,8 +143,3 @@ html, body {
/* 6 columns */
}
}

pre code {
padding: 0;
background: inherit;
}
Loading

0 comments on commit 0af02bf

Please sign in to comment.