jeromegn / DocumentUp

Pretty documentation generator for Github projects with proper Readme.
http://documentup.com
884 stars 90 forks source link

Installing documentup on own server #103

Closed pun-private closed 4 years ago

pun-private commented 7 years ago

Hi !

I tried installing documentup on my own server so I can modify the source code to handle custom README.md from other services than github.

So far, I just installed documentup without any modification to the source code. I created the database and disabled newrelic. But when I try to generate a documentation, I have the following error:

documentup@documentup:~/DocumentUp$

 ./bin/rails server -b 10.0.3.3 -p 3232
=> Booting Puma
=> Rails 4.2.1 application starting in development on http://10.0.3.3:3232
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
Puma 2.11.3 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://10.0.3.3:3232

Started GET "/jeromegn/documentup/" for 10.0.3.1 at 2017-04-11 04:05:04 +0800
Started GET "/jeromegn/documentup/" for 10.0.3.1 at 2017-04-11 04:05:04 +0800
  ActiveRecord::SchemaMigration Load (0.9ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  ActiveRecord::SchemaMigration Load (0.9ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by RepositoriesController#show as HTML
Processing by RepositoriesController#show as HTML
  Parameters: {"user_login"=>"jeromegn", "name"=>"documentup"}
  Parameters: {"user_login"=>"jeromegn", "name"=>"documentup"}
  Repository Load (2.5ms)  SELECT  "repositories".* FROM "repositories" WHERE (LOWER(full_name) = 'jeromegn/documentup')  ORDER BY "repositories"."id" ASC LIMIT 1
  Repository Load (2.5ms)  SELECT  "repositories".* FROM "repositories" WHERE (LOWER(full_name) = 'jeromegn/documentup')  ORDER BY "repositories"."id" ASC LIMIT 1
  Page Load (0.8ms)  SELECT  "pages".* FROM "pages" WHERE "pages"."path" = $1 AND "pages"."repository_id" = 1 LIMIT 1  [["path", ""]]
  Page Load (0.8ms)  SELECT  "pages".* FROM "pages" WHERE "pages"."path" = $1 AND "pages"."repository_id" = 1 LIMIT 1  [["path", ""]]
   (0.3ms)  BEGIN
   (0.3ms)  BEGIN
  SQL (2.1ms)  INSERT INTO "pages" ("repository_id", "created_at", "updated_at", "source") VALUES ($1, $2, $3, $4) RETURNING "id"  [["repository_id", 1], ["created_at", "2017-04-10 20:05:05.053331"], ["updated_at", "2017-04-10 20:05:05.053331"], ["source", "![DocumentUp](app/assets/images/logo.png)\n\n**This site has been generated with DocumentUp** (eat your own dog food, people)\n\nAutomatically generated documentation sites for your markdown files! There are various ways of getting your documentation going:\n\n* [Hosted](#hosted)\n* [gh-pages](#gh-pages)\n\n## Hosted\n\nDocumentUp hosts your documentation sites. Just visit `http://documentup.com/username/repository` to generate a site from your `README.md`.\n\nRecommended if you have a public Github repository.\n\n### CNAME\n\nYou can point a CNAME to `project.username.documentup.com`.\n\n### Post-Receive Hook\n\nIf you want your readme to be recompiled, please add a [Post-Receive Hook](http://help.github.com/post-receive-hooks/) to your Github repository pointing to: `http://documentup.com/recompile`\n\n### Manual Recompile\n\nVisit `http://documentup.com/username/repository/__recompile` to manually tell the server to recompile your readme.\n\nUseful when changes are made to the stylesheets on the server but the compilation hasn't been triggered for a while.\n\n### Configuration\n\nAdd a `.documentup.yml` dotfile file to the root of your repository. Refer to the [options](#options) section below for its contents. Feel free to consult this repository's [`.documentup.yml`](.documentup.yml)\n\n### JSONP example with jQuery\n\n```javascript\n$.ajax({\n  url: \"http://documentup.com/compiled\",\n  dataType: \"jsonp\",\n  data: {\n    content: \"# test\",\n    name: \"Test JSONP!\"\n  },\n  success: function(resp){\n    // `status` is always provided\n    if (resp.status == 200) {\n      // Write to your document\n      document.open();\n      document.write(resp.html);\n      document.close();\n    }\n  }\n});\n```\n\n## gh-pages\n\nFor those wanting to stay within the comfort of their gh-pages branch, it's still possible by using an `index.html` file similar to this:\n\n```html\n<!DOCTYPE html>\n<html>\n  <head>\n    <script src=\"documentup.min.js\"></script>\n    <script>\n      DocumentUp.document(\"username/repository\");\n    </script>\n  </head>\n  <body></body>\n</html>\n```\n\nMake sure to change the `\"username/repository\"` to the repository's name and user's username.\n\nUse the [`documentup.min.js`](public/documentup.min.js) file in this repository, not the one what used to be on cdnjs.com, it's deprecated.\n\n### Configuration\n\n`DocumentUp.document` accepts either a String or an Object representing your desired configuration. If an object is used, remember to add a `repo` option containing the path `\"username/repository\"` to your github repository.\n\nAll options detailed in the [options](#options) section are available.\n\nIn addition to those, one special option is available to \"gh-pages version\" of DocumentUp:\n\n**afterRender** (Function)  \nA function to be executed after the document has been replaced with the compiled HTML.\n\n### Example\n\n```javascript\nDocumentUp.document({\n  repo:  \"jeromegn/documentup\",\n  name: \"DocumentUp\",\n  twitter: [\n    \"jeromegn\",\n    \"DocumentUp\"\n  ],\n  afterRender: function(){\n    alert(\"rendered\");\n  }\n});\n```\n\n### What this script does\n\nIt does what's written in the JSONP section, without the jQuery dependency. It uses a endpoint like: `http://documentup.com/username/repository?callback=` to fetch the cached copy of the repository and then replaces the page's html with the generated documentation.\n\n## Formatting guide\n\nJust like you normally would. DocumentUp also supports \"Github Flavored Markdown\" and we recommend you use it for syntax highlighting.\n\nIt doesn't support tables as it is supported on Github, but you can use inline HTML.\n\nh1's (# in markdown) will appear as first level navigation in the sidebar while h2's (##) will appear under them as sub-navigation.\n\nExample:\n\n```markdown\n# Project name / Title (won't appear in the sidebar)\n\nSome intro text if you want.\n\n## Top level-navigation\n\n### Sub-navigation\n\n#### This wouldn't show up in the sidebar\n```\n\n## Options\n\n### name\n\n*String, default: repository name*\n\nName of your project. It'll appear in the header of the sidebar. Defaults to the `repository` substring of the `repo` option.\n\n### color\n\n*String, default: \"#336699\"*\n\nCSS-like color representing the color for the links both in the sidebar and the content.\n\n### theme\n\n*String, default: null*\n\nName of the theme to use. Refer to the [themes](#themes) sections.\n\n### issues\n\n*Boolean, default: true*\n\nAdds a link to the sidebar for the issues tab of the repository if `true`. Also accepts a string if your issues are managed elsewhere.\n\n### travis\n\n*Boolean, default: false*\n\nIndicate if the project is being tested by [Travis-CI](http://travis-ci.org/). If `true`, it'll add the small travis badge in the sidebar.\n\n### twitter\n\n*String / Array of strings, default: null*\n\nAdd follow buttons for one or more Twitter accounts to your sidebar. Useful to gather followers.\n\n### google_analytics\n\n*String default: null*\n\nThis is your Google Analytics \"UA\" unique ID. Adds GA tracking to your generated documentation.  \ne.g.: \"UA-5201171-14\"\n\n## Themes\n\n### Default\n\nThe one you're looking at now.\n\n### V1\n\nFor the nostalgic. Use `v1` in your `theme` config option.\n\n![V1](app/assets/images/v1.png)\n\n## Roadmap\n\n* Private repositories\n* Multi-page aggregation\n\n## Thank you\n\n* Thanks to [Jean-Marc Denis](http://jeanmarcdenis.me/) for the freely downloadable bow tie I used in the logo.\n\n## Changelog\n\n#### 2.0 (June 15, 2015)\n\nFull rewrite of the app:\n- Deprecated on-demand `/compiled` endpoint\n- Renamed manual recompile endpoint to `username/repo/__recompile`\n- Uses Ruby on Rails\n- Uses SASS\n- Laid the foundation for multiple pages (it works right now, just not linked or explained, needs some work)\n- Uses PostgreSQL\n\n#### Hosted version (Feb 2, 2012)\n\nVersioning is going to be difficult now since this is now a service. Deployment will be continuous.\n\n#### 0.1.1 (Jan 26, 2012)\n\n* Files now parsed in UTF-8\n* Namespaced repositories in localStorage (thanks to [tbranyen](https://github.com/tbranyen))\n* A few README fixes\n\n#### 0.1.0 (Jan 25, 2012)\n\n* Initial release\n\n## License\n\nCopyright (c) 2015 Jerome Gravel-Niquet\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"]]
  SQL (2.1ms)  INSERT INTO "pages" ("repository_id", "created_at", "updated_at", "source") VALUES ($1, $2, $3, $4) RETURNING "id"  [["repository_id", 1], ["created_at", "2017-04-10 20:05:05.053331"], ["updated_at", "2017-04-10 20:05:05.053331"], ["source", "![DocumentUp](app/assets/images/logo.png)\n\n**This site has been generated with DocumentUp** (eat your own dog food, people)\n\nAutomatically generated documentation sites for your markdown files! There are various ways of getting your documentation going:\n\n* [Hosted](#hosted)\n* [gh-pages](#gh-pages)\n\n## Hosted\n\nDocumentUp hosts your documentation sites. Just visit `http://documentup.com/username/repository` to generate a site from your `README.md`.\n\nRecommended if you have a public Github repository.\n\n### CNAME\n\nYou can point a CNAME to `project.username.documentup.com`.\n\n### Post-Receive Hook\n\nIf you want your readme to be recompiled, please add a [Post-Receive Hook](http://help.github.com/post-receive-hooks/) to your Github repository pointing to: `http://documentup.com/recompile`\n\n### Manual Recompile\n\nVisit `http://documentup.com/username/repository/__recompile` to manually tell the server to recompile your readme.\n\nUseful when changes are made to the stylesheets on the server but the compilation hasn't been triggered for a while.\n\n### Configuration\n\nAdd a `.documentup.yml` dotfile file to the root of your repository. Refer to the [options](#options) section below for its contents. Feel free to consult this repository's [`.documentup.yml`](.documentup.yml)\n\n### JSONP example with jQuery\n\n```javascript\n$.ajax({\n  url: \"http://documentup.com/compiled\",\n  dataType: \"jsonp\",\n  data: {\n    content: \"# test\",\n    name: \"Test JSONP!\"\n  },\n  success: function(resp){\n    // `status` is always provided\n    if (resp.status == 200) {\n      // Write to your document\n      document.open();\n      document.write(resp.html);\n      document.close();\n    }\n  }\n});\n```\n\n## gh-pages\n\nFor those wanting to stay within the comfort of their gh-pages branch, it's still possible by using an `index.html` file similar to this:\n\n```html\n<!DOCTYPE html>\n<html>\n  <head>\n    <script src=\"documentup.min.js\"></script>\n    <script>\n      DocumentUp.document(\"username/repository\");\n    </script>\n  </head>\n  <body></body>\n</html>\n```\n\nMake sure to change the `\"username/repository\"` to the repository's name and user's username.\n\nUse the [`documentup.min.js`](public/documentup.min.js) file in this repository, not the one what used to be on cdnjs.com, it's deprecated.\n\n### Configuration\n\n`DocumentUp.document` accepts either a String or an Object representing your desired configuration. If an object is used, remember to add a `repo` option containing the path `\"username/repository\"` to your github repository.\n\nAll options detailed in the [options](#options) section are available.\n\nIn addition to those, one special option is available to \"gh-pages version\" of DocumentUp:\n\n**afterRender** (Function)  \nA function to be executed after the document has been replaced with the compiled HTML.\n\n### Example\n\n```javascript\nDocumentUp.document({\n  repo:  \"jeromegn/documentup\",\n  name: \"DocumentUp\",\n  twitter: [\n    \"jeromegn\",\n    \"DocumentUp\"\n  ],\n  afterRender: function(){\n    alert(\"rendered\");\n  }\n});\n```\n\n### What this script does\n\nIt does what's written in the JSONP section, without the jQuery dependency. It uses a endpoint like: `http://documentup.com/username/repository?callback=` to fetch the cached copy of the repository and then replaces the page's html with the generated documentation.\n\n## Formatting guide\n\nJust like you normally would. DocumentUp also supports \"Github Flavored Markdown\" and we recommend you use it for syntax highlighting.\n\nIt doesn't support tables as it is supported on Github, but you can use inline HTML.\n\nh1's (# in markdown) will appear as first level navigation in the sidebar while h2's (##) will appear under them as sub-navigation.\n\nExample:\n\n```markdown\n# Project name / Title (won't appear in the sidebar)\n\nSome intro text if you want.\n\n## Top level-navigation\n\n### Sub-navigation\n\n#### This wouldn't show up in the sidebar\n```\n\n## Options\n\n### name\n\n*String, default: repository name*\n\nName of your project. It'll appear in the header of the sidebar. Defaults to the `repository` substring of the `repo` option.\n\n### color\n\n*String, default: \"#336699\"*\n\nCSS-like color representing the color for the links both in the sidebar and the content.\n\n### theme\n\n*String, default: null*\n\nName of the theme to use. Refer to the [themes](#themes) sections.\n\n### issues\n\n*Boolean, default: true*\n\nAdds a link to the sidebar for the issues tab of the repository if `true`. Also accepts a string if your issues are managed elsewhere.\n\n### travis\n\n*Boolean, default: false*\n\nIndicate if the project is being tested by [Travis-CI](http://travis-ci.org/). If `true`, it'll add the small travis badge in the sidebar.\n\n### twitter\n\n*String / Array of strings, default: null*\n\nAdd follow buttons for one or more Twitter accounts to your sidebar. Useful to gather followers.\n\n### google_analytics\n\n*String default: null*\n\nThis is your Google Analytics \"UA\" unique ID. Adds GA tracking to your generated documentation.  \ne.g.: \"UA-5201171-14\"\n\n## Themes\n\n### Default\n\nThe one you're looking at now.\n\n### V1\n\nFor the nostalgic. Use `v1` in your `theme` config option.\n\n![V1](app/assets/images/v1.png)\n\n## Roadmap\n\n* Private repositories\n* Multi-page aggregation\n\n## Thank you\n\n* Thanks to [Jean-Marc Denis](http://jeanmarcdenis.me/) for the freely downloadable bow tie I used in the logo.\n\n## Changelog\n\n#### 2.0 (June 15, 2015)\n\nFull rewrite of the app:\n- Deprecated on-demand `/compiled` endpoint\n- Renamed manual recompile endpoint to `username/repo/__recompile`\n- Uses Ruby on Rails\n- Uses SASS\n- Laid the foundation for multiple pages (it works right now, just not linked or explained, needs some work)\n- Uses PostgreSQL\n\n#### Hosted version (Feb 2, 2012)\n\nVersioning is going to be difficult now since this is now a service. Deployment will be continuous.\n\n#### 0.1.1 (Jan 26, 2012)\n\n* Files now parsed in UTF-8\n* Namespaced repositories in localStorage (thanks to [tbranyen](https://github.com/tbranyen))\n* A few README fixes\n\n#### 0.1.0 (Jan 25, 2012)\n\n* Initial release\n\n## License\n\nCopyright (c) 2015 Jerome Gravel-Niquet\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n\"Software\"), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"]]
   (0.5ms)  ROLLBACK
   (0.5ms)  ROLLBACK
Completed 500 Internal Server Error in 2595ms (ActiveRecord: 14.8ms)
Completed 500 Internal Server Error in 2595ms (ActiveRecord: 14.8ms)

MentosError (EPIPE):
  app/models/page.rb:25:in `parsed'
  app/models/page.rb:11:in `parse'
  app/controllers/application_controller.rb:33:in `current_page'
  app/controllers/application_controller.rb:40:in `ensure_page!'

MentosError (EPIPE):
  app/models/page.rb:25:in `parsed'
  app/models/page.rb:11:in `parse'
  app/controllers/application_controller.rb:33:in `current_page'
  app/controllers/application_controller.rb:40:in `ensure_page!'

  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (29.8ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (29.8ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (10.6ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (10.6ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (21.4ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (21.4ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (134.9ms)
  Rendered /usr/local/rvm/gems/ruby-2.1.6/gems/actionpack-4.2.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (134.9ms)

Any idea why ?

Thanks

pun-private commented 7 years ago

Hello again !

I have narrowed the problem. It seems that the problem comes from HTML::Pipeline::SyntaxHighlightFilter that doesn't like triple backquote ```.

To trigger the error manually, I have updated the method parsed with the following code:

  def parsed(source = self.source)
    @parsed ||= html_pipeline.call("```python\nfoo = 'bar'\n```")    
    #@parsed ||= html_pipeline.call(source)
  end

And if I comment HTML::Pipeline::SyntaxHighlightFilter, no more errors...

def html_pipeline
    @pipeline ||= HTML::Pipeline.new [
      HTML::Pipeline::MarkdownFilter,
      TaskList::Filter,
      HTML::Pipeline::SanitizationFilter,
      DocumentUp::Filters::TableOfContents,
      HTML::Pipeline::ImageMaxWidthFilter,
      #HTML::Pipeline::SyntaxHighlightFilter,                                                                                                                         
      HTML::Pipeline::EmojiFilter,
      HTML::Pipeline::AbsoluteSourceFilter,
      DocumentUp::Filters::AbsoluteLinks,
      HTML::Pipeline::MentionFilter,
      HTML::Pipeline::AutolinkFilter
    ], {
      base_url: "https://github.com/",
      asset_root: "https://assets-cdn.github.com/images/icons",
      image_base_url: "https://cdn.rawgit.com/#{repository.full_name}/#{repository.branch}/",
      image_subpage_url: "https://cdn.rawgit.com/#{repository.full_name}/#{repository.branch}/",
      link_subpage_url: "https://github.com/#{repository.full_name}/blob/#{repository.branch}/"
    }
  end
jeromegn commented 7 years ago

That is odd, that syntax filter should handle triple backticks fine. It handles other ways of "specifying" code?

The gem that handles that was built by Github themselves. I'm surprised it would break.

Could it be due to a more recent Ruby version? What are you running this on (OS, Ruby version, etc.)?

Thanks!

pun-private commented 7 years ago

Hi !

Here are my specs:

root@documentup:/home/documentup/DocumentUp# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty

root@documentup:/home/documentup/DocumentUp# ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-linux]

Thx