{"id":544,"date":"2019-07-14T15:11:27","date_gmt":"2019-07-14T22:11:27","guid":{"rendered":"http:\/\/35.243.195.209\/?p=544"},"modified":"2021-04-19T19:23:05","modified_gmt":"2021-04-20T02:23:05","slug":"github-synchronized-markdown-based-and-auth-enabled-wiki-system","status":"publish","type":"post","link":"https:\/\/nanzhou.cc\/index.php\/2019\/07\/14\/github-synchronized-markdown-based-and-auth-enabled-wiki-system\/","title":{"rendered":"Github-Synchronized, Markdown-based, and Auth-Enabled Wiki System"},"content":{"rendered":"<h2>Summary<\/h2>\n<p>In this post, I will introduce how to set up a personal Wiki system with the following features,<\/p>\n<ol>\n<li>Github-Synchronized: All pages are synchronized on Github;<\/li>\n<li>Markdown-based: All pages can be written in Markdown;<\/li>\n<li>Auth-Enabled: Visitors can view and admins can view\/edit.<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>I provide a ready-to-use Docker image.<\/p>\n<pre><code class=\"language-bash\">sudo docker run \\\n-v ${PWD}:\/home\/wiki_repo \\\n-p 4567:4567 \\\n-e GITHUB_CLIENT_ID=xxx \\\n-e GITHUB_CLIENT_SECRET=xxx \\\n-e AUTH_EMAIL=fighternan@gmail.com \\\n--name wiki \\\nfighternan\/auth_wiki:latest<\/code><\/pre>\n<p>There are three environment varibles you should set. <code>GITHUB_CLIENT_ID <\/code> and <code>GITHUB_CLIENT_SECRET<\/code> are available once you set your Github OAuth App. See <a href=\"https:\/\/developer.github.com\/var\/www\/htmls\/building-oauth-apps\/creating-an-oauth-app\/\">here<\/a> for official tutorial. <code>AUTH_EMAIL<\/code> specifies the user who can edit the pages. Other users can only view the pages.<\/p>\n<p>If you want to build your customized image. See <a href=\"https:\/\/github.com\/FighterNan\/Auth-Gollum-Wiki-Image\/\">my repo here<\/a> and develop your images.<\/p>\n<h2>Details<\/h2>\n<h3>Gollum<\/h3>\n<p>Gollum is a wiki using git as the back end storage mechanism and written mostly in Ruby. It is the wiki system used by the GitHub web hosting system. Gollum pages may be written in a variety of formats such as Markdown. See <a href=\"https:\/\/github.com\/gollum\/gollum\">here<\/a> for installation tutorial.<\/p>\n<h3>Github Wiki<\/h3>\n<p>For every Github repository, you can create a Wiki, which is separate from your main project. You can clone it, look at it, edit pages and structure, and push your changes back up. For example, I have a wiki repo <a href=\"https:\/\/github.com\/FighterNan\/FighterNan.github.io\/wiki\">here<\/a>.<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/FighterNan\/FighterNan.github.io.wiki.git<\/code><\/pre>\n<h3>Set up Your Wiki Service<\/h3>\n<p>Once you clone the Wiki repo and install Gollum, people can view and edit your pages through a Web GUI.<\/p>\n<pre><code>cd FighterNan.github.io.wiki &amp;&amp; gollum<\/code><\/pre>\n<p>The system can be run without networks. Once you have Internet available, you can back them up though <code>git push<\/code>.<\/p>\n<h3>Authentication<\/h3>\n<p>You may want to share your Wiki but do not want others to edit the pages. <a href=\"https:\/\/github.com\/arr2036\/omnigollum\">omnigollum<\/a> provides the authentication packages. Use the configuration below.<\/p>\n<pre><code class=\"language-ruby\">Gollum::Page.send :remove_const, :FORMAT_NAMES if defined? Gollum::Page::FORMAT_NAMES\n\n## Omni Auth\nrequire 'omnigollum'\nrequire 'omniauth\/strategies\/github'\n\nwiki_options = {\n  :live_preview =&gt; false,\n  :allow_uploads =&gt; true,\n  :per_page_uploads =&gt; true,\n  :allow_editing =&gt; true,\n  :css =&gt; true,\n  :js =&gt; true,\n  :mathjax =&gt; true,\n  :h1_title =&gt; true\n}\nPrecious::App.set(:wiki_options, wiki_options)\n\noptions = {\n  # OmniAuth::Builder block is passed as a proc\n  :providers =&gt; Proc.new do\n    # Found https:\/\/github.com\/settings\/var\/www\/htmllications\/\n    provider :github, 'Client ID', 'Client Secret'\n  end,\n  :dummy_auth =&gt; false,\n  # If you want to make pages private:\n  #:protected_routes =&gt; ['\/private*'],\n\n  # Specify committer name as just the user name\n  :author_format =&gt; Proc.new { |user| user.name },\n  # Specify committer e-mail as just the user e-mail\n  :author_email =&gt; Proc.new { |user| user.email },\n\n  # Authorized users\n  :authorized_users =&gt; [\"your_email@example.com\"],\n}\n## :omnigollum options *must* be set before the Omnigollum extension is registered\nPrecious::App.set(:omnigollum, options)\nPrecious::App.register Omnigollum::Sinatra<\/code><\/pre>\n<p>Run your application again by <code>gollumn --config auth.rb<\/code>. The original script and post are available <a href=\"https:\/\/ronnieroller.com\/Gollum\">here<\/a>.<\/p>\n<h3>Github OAuth App<\/h3>\n<p>You can achieve authentication through Github OAuth App without passing the password to the Wiki System. Follow the tutorial <a href=\"https:\/\/developer.github.com\/var\/www\/htmls\/building-oauth-apps\/creating-an-oauth-app\/\">here<\/a> and create your OAuth Apps.<\/p>\n<h3>Ready-to-Use Docker Image<\/h3>\n<p>Environment Issues are annoying and you do not want to configure them again from your MAC laptop to another Centos or Ubuntu server. You may also want to be lazy and configure things by one command.<\/p>\n<p>Here comes the Docker. Use my images <a href=\"https:\/\/cloud.docker.com\/u\/nanzhoumails\/repository\/docker\/nanzhoumails\/auth_wiki\">here<\/a>. The arguments are set by passing the environment variables .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary In this post, I will introduce how to set up a personal Wiki system with the following features, Github-Synchronized: All pages are synchronized on Github; Markdown-based: All pages can be written in Markdown; Auth-Enabled: Visitors can view and admins can view\/edit. Conclusion I provide a ready-to-use Docker image. sudo docker run \\ -v ${PWD}:\/home\/wiki_repo&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,13],"tags":[],"class_list":["post-544","post","type-post","status-publish","format-standard","hentry","category-backend","category-web"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/comments?post=544"}],"version-history":[{"count":5,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/544\/revisions"}],"predecessor-version":[{"id":1588,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/544\/revisions\/1588"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=544"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/categories?post=544"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/tags?post=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}