Compare commits

...

130 Commits

Author SHA1 Message Date
benjamin wil 5b3fb5fa87 Change GitHub Actions workflow Ruby matrix
We can drop Ruby 2.4 from our test run matrix. It is beyond EOL.
Let's add 2.7 instead.
2021-12-30 14:16:00 -08:00
benjamin wil 5f7c17b900 Remove twitter_cldr development dependency
This is no longer being used.
2021-12-30 14:14:52 -08:00
benjamin wil 9ade6d983e Simplify GitHub Action workflow steps
Judging by the output in the GitHub Actions workflow UI, the `echo`
steps were not providing much value to us.

We can get rid of them to slightly increase run performance.

I've also named the other steps to make it easier to skim the Actions
workflow output.
2021-12-29 15:43:54 -08:00
benjamin wil f464b6dc11 Use latest Ruby patch versions during CI runs 2021-12-29 15:43:54 -08:00
benjamin wil 8c811d5638 Split JRuby CI runs from MRI CI runs
We can improve the performance of our MRI test runs by not installing
Java as part of their run. (Java is only required for JRuby.)
2021-12-29 15:43:54 -08:00
benjamin wil 4229164197 Use an older version of Nokogiri in our test env
This is a temporary fix. See the commit diff for more information.
2021-12-29 15:33:22 -08:00
benjamin wil b6a063152f Simplify test
I came across this test because it was failing JRuby CI runs. I should
emphasize, though, that this test was only failing due do an upstream
bug in Nokogiri v1.12.5.

When I was reviewing the test, to understand why it was failing at all,
I noticed that the assertion was rather obfuscated.  Specifically, we
were post-processing the entire `response.body` and using that as an
expectation.
2021-12-29 15:33:22 -08:00
Dawa Ometto 46c22a8b87 Take account of possible https referer in upload route (#1787) 2021-12-23 12:18:30 +01:00
Ryan Govostes 7e379cfab1 Reduce size of container image (#1777)
* Reduce size of container image
* Add deprecation message for automatic --mathjax
2021-12-22 20:54:29 +01:00
Dawa Ometto 93d3d10453 Update gollum (#1786)
Exit with code 1 (error) when invalid option is given
2021-12-22 18:08:20 +01:00
fhchl 98a0006c86 Fix mathjax on edit and create pages (#1773)
* Fix mathjax on edit and create pages
2021-12-22 17:00:31 +01:00
Dawa Ometto d97721f38b Update test.yaml
Update JDK
2021-11-06 13:32:13 +01:00
Aaron Wallentine 8d3ec8605e Small grammar fix in README.md (#1776) 2021-10-28 13:55:32 +02:00
Brian Porter 7517389072 Allow for overriding only specific Mustache templates/partials. (#1719)
* Allow for overriding only specific templates/partials. Resolves  #1450.
2021-09-07 17:32:46 +02:00
Dawa Ometto b7011139cf Create release.yml (#1760) 2021-09-06 11:30:56 +02:00
Dawa Ometto 6e8a68dd0d Delete .travis.yml 2021-09-02 21:04:30 +02:00
Dawa Ometto 4e8309d3e4 Load template page as utf-8 (#1758) 2021-08-30 11:09:29 +02:00
Dawa Ometto 371ab21d16 Add SauceLab attribution 2021-08-28 17:36:06 +02:00
yy0931 cbcbc4bc3f unescape page names in the preview tab (#1739)
* Unescape page names in the preview tab

* Execute rake precompile
2021-08-28 17:24:00 +02:00
Dawa Ometto dc9b2e1766 Update gollum.gemspec (#1749) 2021-08-28 17:21:44 +02:00
Darless 334df62651 Docker support within the repository (#1732)
- Adds a Dockerfile within this repository
- GitHub actions to build and test the image
2021-08-03 12:52:47 +02:00
yy0931 046353cf7e Fix an IME rendering issue (#1735)
* Fix an IME rendering issue

* Execute rake precompile
2021-07-09 07:52:38 -07:00
benjamin wil 51f2f032d7 Add I18n interface for use in Mustache templates (#1679)
* Add `i18n` dependency

We will use `i18n` to provide localization for Gollum's frontend. I
chose this because it's a well-supported, pretty normal Ruby library.

* Configure I18n

- Locale files will be kept in `lib/gollum/locales/[lang].yml`
- The available locales, to start, will be English (`en`).

* Add I18n interface for mustache templates

This commit adds an interface that allows mustache templates to get I18n
translation strings, transform any arguments that may be present in
them, and then render them on the frontend.

This is our first real step to getting internationalizing the Gollum
frontend.
2021-06-27 09:26:45 -07:00
Dawa Ometto 70360edb96 Update test.yaml (#1734) 2021-06-26 22:06:34 +02:00
benjamin wil 2b12ab9206 Explicitly set encoding for Precious::App (#1731)
An issue was reported (see #1721) where, in docker containers where the
`LANG` was not being set, `Precious::App` would serve Mustache templates
in an ASCII encoding. This caused templates to error out.

In the past, this would have happened in environments where `LANG` was
not set and the Gollum applciation configuration had enabled MathJax.
Now, it happens even if MathJax is disabled because of a UTF-8 character
I added to the mobile navigation menu.

Basically, we should enforce a UTF-8 encoding from now on to avoid
runtime errors related to ASCII encoding.
2021-06-14 21:28:12 +02:00
Darless 87a01e04ce fixes #1723: Github Actions Supported (#1729)
* fixes #1723: Github Actions Supported

- This is to switch from Travis CI which is shutting down the org version,
  and the .com version, a free account is limited.
- Switch test environment variable from TRAVIS to CI to be more generic.

* Adding jruby-9.2.18.0 to matrix for github actions
2021-06-14 21:21:40 +02:00
Sam 5f04200bd0 README.md: Clarify that Gollum should run against an already-initialized Git repository. (#1722) 2021-06-13 14:34:28 -07:00
benjamin wil aa823b5a2d Use recent JRuby release for Travis CI (#1730)
Our JRuby CI runs have been errorring due to what I think is an issue
with an older `jruby-openssl` version.
2021-06-13 14:17:18 -07:00
Dawa Ometto 9012dee888 Release 5.2.3 2021-04-18 13:43:00 +02:00
benjamin wil 81d5f1a8bb Ensure <title> is rendered for pages (#1710)
I made a mistake when I made `#title` a private method. I did not see
that it was being called from `layout.mustache` to generate the
`<title></title>` tag in the `<head></head>` of each page.

This fixes my error, and adds tests so the behaviour is more explicit.
2021-04-05 09:26:50 -07:00
Dawa Ometto d2b0a22a8f Release 5.2.2 2021-03-27 19:43:38 +01:00
Dawa Ometto 355e6b1f18 Fix query ? in mathjax script path (#1706) 2021-03-27 19:40:35 +01:00
Nikita Ivanov 7a2c9107c3 Delete dublicate error (#1700) 2021-03-27 14:05:03 +01:00
benjamin wil 127473fff8 Fix tab navigation styles (#1696)
* Fix tabnav styles on #create and #edit views

The Primer CSS-provided `tabnav` styles were not being used on the Edit
and Preview tabs on the create and edit pages.

After following Primer's documentation [1], it looks like we were using
the `aria-current` attribute incorrectly. Dynamically adding/removing
this attribute on the selected tab fixes the issue.

[1]: https://primer-css-git-next-inputs.primer.now.sh/css/components/navigation#tabnav

* Recompile static assets
2021-03-23 09:13:23 -07:00
benjamin wil 9a79b0a800 Merge pull request #1701 from ViChyavIn/fix-focused-button
Fix focused button border shown wrong in dialogs
2021-03-23 07:49:52 -07:00
ViChyavIn ca13298d00 Update static assets 2021-03-23 13:43:26 +05:00
ViChyavIn eaf82e6367 Overflow is set to visible by default so declaration is removed 2021-03-23 13:39:44 +05:00
benjamin wil cae290ded7 Merge pull request #1697 from gollum/benjaminwil/fix-nav-outline
Fix nav outline styles
2021-03-22 10:21:29 -07:00
Benjamin Willems a22208a0be Use <button> instead of <a> without href
It is more semantic to use a `<button>` tag in the place of an `<a>`
when there is no other page being linked to. In this circumstance, we're
using JavaScript to present a modal to the user on click.

This change makes the "Upload" and "Rename" buttons appear in the
browser's tab index.
2021-03-21 14:21:07 -07:00
Benjamin Willems bc877dc9dc Fix indentation due to DOM simplification
We removed one of the parent elements of the `<nav>`, so we must
re-indent the entire file.
2021-03-21 14:19:32 -07:00
Benjamin Willems 40b1775d42 Make the main <nav> element a TableObject
There was a display issue, where navbar items's outline styles were
being cut off due to the parent `<nav>` element's margin and padding.

Fortunately, we can do away with the navbar wrapper div entirely. It was
not doing anything important except defining its children as
`TableObject` items. But we can just do this on the `<nav>` itself.
2021-03-21 14:18:45 -07:00
ViChyavIn c2dc605adb Fix focused button border shown wrong 2021-03-20 21:43:53 +05:00
benjamin wil a1e1af07a4 Merge pull request #1676 from gollum/benjaminwil/button-labels
Move "Page History" into button group
2021-03-15 08:24:04 -07:00
benjamin wil 76948130f6 Display button groups using Primer flex utilities
This small improvement just uses Primer `d-flex` utilities to `display:
flex;` instead of using style tags. It's preferable.
2021-03-06 16:19:01 -08:00
Benjamin Willems f71ba31bfe Move "Page History" into button group
If the user has edit permissions, the "History" button is shown in a
button group with "Edit" and "Rename". If the user does not have edit
permissions, it's shown by itself.

This commit also renames the label from "Page History" to "History".
2021-03-06 16:19:01 -08:00
Dawa Ometto b7caa228e6 Add webrick dependency (#1695)
* Remove webrick as dev dependency
2021-03-06 15:39:21 +01:00
Dawa Ometto 0101dd2f65 Update .travis.yml (#1690) 2021-03-06 10:06:11 +01:00
Dawa Ometto c8baa61fe3 Update image icon in editor (#1687) 2021-02-26 15:30:02 +01:00
Dawa Ometto 104335706a Faster tests (#1686) 2021-02-26 11:34:41 +01:00
Dawa Ometto 7c60841bad Release 5.2.1 2021-02-25 13:35:02 +01:00
benjamin wil f6a7c57175 Don't include primer.css separate from app.css (#1685)
* Recompile static assets
2021-02-25 09:39:41 +01:00
Dawa Ometto 730acee609 Release 5.2 2021-02-24 12:06:54 +01:00
Dawa Ometto b7295df662 Fix Compare view for renames on JRuby (#1682) 2021-02-24 11:53:48 +01:00
Dawa Ometto aba3ec37d9 Fix styling for Latest Changes flexbox (#1683) 2021-02-24 09:28:34 +01:00
Dawa Ometto 020c98bfad Update README.md (#1670) 2021-02-23 12:47:30 +01:00
Dawa Ometto d33d11e086 Make Keybinding and Markup selects smaller (#1681) 2021-02-23 12:47:03 +01:00
benjamin wil 2e41751cf6 Fix sidebar and footer padding (#1677)
* Change footer and footer container spacing

This commit:

  1. Removes the Primer `my-md-0` spacing from the `#wiki-footer`
     container.

     This gives it margins along the Y axis, spacing it out from
     the sidebar and main wiki content containers on `md` and larger
     screens.

  2. Adds `px-4` padding to the `#footer-content`. which makes the

     This makes the footer content inset the same way that sidebar
     content is. This makes the content look more uniform on mobile
     devices, when the sidebar and footer are presented one before
     the other.

* Change spacing behaviour of `#wiki-sidebar`

To make `#wiki-sidebar` and `#wiki-footer` more similar, we can make
sure `px-4` padding is applied to the `-content` container, rather than
the outer container.
2021-02-22 09:32:02 +01:00
benjamin wil f493150825 Fix heading counters and anchor icon presentation. Resolves #1642 (#1673)
* Reset h2 counters
* Reformat .header-enum scoped SCSS
* Show overflow .wiki-body content
* Re-scope and re-style heading `.anchor` elements
* Remove unused SCSS
* Recompile static assets

Co-authored-by: Dawa Ometto <dawa.ometto@uni-leipzig.de>
2021-02-20 11:10:52 +01:00
benjamin wil 68d0dd0cd5 Add mobile navigation menu (#1671)
* If navbar is too wide, use overflow-x: scroll
* Add initial mobile nav menu
* Use CSS classes instead of IDs for jQuery events
* Change content x-axis padding for mobile devices
* Recompile assets for mobile menu feature
2021-02-18 09:33:33 +01:00
benjamin wil 38fc7e69c1 Update Primer CSS to v15.2.0 (#1659) 2021-02-14 01:05:10 +01:00
benjamin wil 5b7b9f40ae Only escape HTML from breadcrumbs. Resolves #1658 (#1663) 2021-02-14 01:04:42 +01:00
benjamin wil 17162aa091 Make sidebar layout mobile-friendly (#1660) 2021-02-13 18:29:33 +01:00
benjamin wil 0c89aa2b3e Update reference to test git bare repositories (#1662)
The CONTRIBUTING document referenced a file that has since been moved.
2021-02-13 17:50:27 +01:00
benjamin wil 1980e39876 Remove unused _layout.scss file (#1661) 2021-02-13 17:25:54 +01:00
Garet Robertson 2b949014b8 Add JS polyfill for IE compatibility (#1664). (#1667) 2021-02-13 17:11:40 +01:00
Dawa Ometto b399496ec2 Update gems (#1637) 2021-02-13 16:48:28 +01:00
Sam 8433327926 contrib/automation/gollum-post: A script to post files to Gollum in an automated way. (#1608) 2021-02-13 16:48:11 +01:00
Nikita Ivanov bb207f43d0 Fix binary diffs unable to be viewed in history. Resolves #1650 (#1649)
* Fix binary diffs cause error when viewed
* Change color of git lines to #000000a0
* Update assets
2021-01-10 13:54:30 +01:00
Nikita Ivanov 333af9b76c Add redirect to rename commit (#1648)
This PR ensures that changes to `REDIRECTS_FILE` are committed with the commit responsible for the corresponding git rename.
2021-01-08 14:36:54 +01:00
Dawa Ometto 18a16665cc Don't add base path to file url for deletion. Resolves https://github.com/gollum/gollum/pull/1620 (#1639)
* Add regression test
2021-01-04 11:29:45 +01:00
Bart Kamphorst 6c0796733d Filter _Template content. Resolves #1603 and #1640. (#1612)
* Filter _Template content. Resolves #1603 and #1640.

* Introduces a Gollum::TemplateFilter class with methods to easily add _Template Filters.

* Adds support for relative _Template pages with fallback to _Template in root.
2020-12-26 14:10:02 +01:00
Nikita Ivanov 97ed5a7c57 Add tests to the ? in page name fix (#1641) 2020-12-14 11:24:50 +01:00
Nikita Ivanov c87c8c446e Fix bug when link to a page doesn't work if it has ? in its title (#1634) 2020-12-13 13:42:19 +01:00
Dawa Ometto bfbfb21c17 Release 5.1.2 2020-12-01 22:22:22 +01:00
Dawa Ometto 137728cdab Guard against malicious file names 2020-12-01 22:21:54 +01:00
Dawa Ometto 3f7fd21d4a Update kramdown-parse-gfm (#1623) 2020-11-19 17:10:37 +01:00
Dawa Ometto 2204cef0ef Fix dependency status badge 2020-11-02 22:14:51 +01:00
Dawa Ometto 29ad7127d1 Add dependency status badge 2020-11-02 22:14:11 +01:00
Dawa Ometto 123518b940 Don't escape page path. Resolves #1615 (#1618) 2020-09-21 15:50:58 +02:00
Dawa Ometto dbe849707a Update GPG key 2020-09-13 16:21:43 +02:00
Dawa Ometto 986a76cf8e Release 5.1.1 2020-08-11 12:57:42 +02:00
Dawa Ometto 42439033c8 Release 5.1 2020-08-03 19:07:32 +02:00
Dawa Ometto 421ff18788 Updating assets for bugfix release. 2020-08-03 19:01:29 +02:00
Dawa Ometto 519a275ff0 Fix mathjax config path (#1605)
Related to #1602
2020-08-03 19:00:49 +02:00
Watal M. Iwasaki 5a95f79b32 Ensure page_route starts with a leading slash (#1604)
* Ensure page_route starts with a leading slash

* Handle base_url = nil in page_route()

* Refactor page_route()
2020-08-03 18:09:57 +02:00
Dawa Ometto 627ee5bbbe Merge pull request #1595 from heavywatal/upload-whitespaced-file
Address the uploads issue. Resolves #1584
2020-08-03 18:05:27 +02:00
Dawa Ometto a9d300341c Merge pull request #1594 from heavywatal/empty-search
Show search page even when no parameters are given
2020-07-15 12:46:18 +02:00
Dawa Ometto 6b7e912010 Merge pull request #1593 from heavywatal/fix-home-button
Address home button issue #1590
2020-07-15 12:44:13 +02:00
Watal M. Iwasaki 4feae80814 Update assets 2020-07-12 17:39:18 +09:00
Watal M. Iwasaki 5f5730fe2e Address the uploads issue #1584
'%20' in filenames are translated back to ' ' in both editor and file creation.
2020-07-12 17:37:20 +09:00
Watal M. Iwasaki 5f784f5e10 Show search page even when no parameters are given
This PR addresses the issue #1586
2020-07-12 15:22:18 +09:00
Watal M. Iwasaki 35a44efafd Address home button issue #1590
A trailing slash is added.
This fixes the behavior when base_url is nil.
2020-07-12 13:41:41 +09:00
Dawa Ometto b32dcfa8dd Merge pull request #1580 from heavywatal/reduce-direct-base_url
Reduce direct use of base_url
2020-06-17 10:37:15 +02:00
Watal M. Iwasaki 38fc32bbdd Return nil if url.empty? right after url.comact! 2020-06-16 17:55:01 +09:00
Watal M. Iwasaki 6c7b12ae5e Restore base_url for baseUrl in JavaScript 2020-06-16 17:29:32 +09:00
Dawa Ometto 649e19bdb1 Merge pull request #1578 from tpoliaw/no-edit-compare
Let compare versions be used in no-edit mode
2020-06-15 12:13:34 +02:00
Watal M. Iwasaki a4266170ea Address the issue #1572 (#1581)
* Add double-quote to data-file-path={{url}}
2020-06-15 12:02:32 +02:00
Watal M. Iwasaki 6e6d9d8c1f Use page_route() for custom.css, custom.js, and MathJax 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki e49758334f Replace base_url with page_route() 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki 580068212d Remove base_url from search.mustache 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki 504278d9ba Move full_url_path from HasPage to Page
so that page_route() is accessible via Layout
2020-06-14 23:11:07 +09:00
Watal M. Iwasaki 214056a88a Refactor regex in clean_url() 2020-06-14 23:11:07 +09:00
Watal M. Iwasaki e310f76030 Enhance RouteHelpers
- page_route() accepts nil and return base_url
- clean_url() accepts multiple args and join them
2020-06-14 23:11:07 +09:00
Peter Holloway 83abe62125 Use GET for compare methods
POST requests are blocked when running in --no-edit mode so using POST
prevents compare being available (see #1546).

Change the history view form to use "get" as the form method and change
the routing in app to accept get requests for both forms of compare. The
order of the compare routes is switched to make the more specific form
checked first to prevent all requests being handled by the less specific
form.
2020-06-10 23:27:48 +01:00
Bart Kamphorst 8e7a714991 Merge pull request #1577 from gollum/fix_1571
Remove superfluous closing div tag. Add ids to all navigation buttons.
2020-06-09 09:30:27 +02:00
Bart Kamphorst 4f67710ed2 Remove superfluous closing div tag. Add ids to all navigation buttons. 2020-06-08 22:09:04 +02:00
Bart Kamphorst 8ec8be5db3 Merge pull request #1576 from mivok/feature/auto_save
Add auto save functionality
2020-06-08 21:26:54 +02:00
Watal M. Iwasaki 92da563211 Add quick access to diff of each commit in the history (#1555) 2020-06-08 20:49:34 +02:00
Mark Harrison 2eb5a7e4b8 Remove flash-full from the notification class list
It doesn't look right with the banner in the new position.
2020-06-05 22:59:20 -04:00
Mark Harrison 23110d5f05 Add autosave/restore for subpages too 2020-06-05 22:51:14 -04:00
Mark Harrison 18de3272e3 Move autosave message elements into the template 2020-06-05 21:34:07 -04:00
Mark Harrison 1e81c42818 Add auto save functionality
Fixes #527

This adds auto saving to gollum using local storage.
2020-06-04 22:30:40 -04:00
Dawa Ometto ef6e0e8a07 Fix gollum link tag highlighting (#1566) 2020-05-15 10:29:38 +02:00
Watal M. Iwasaki ba575b886d Simulate 'git show' when a single version is posted from /history/ (#1543) 2020-04-16 12:50:45 +02:00
Dawa Ometto c8f856109d Set environment to production when precompiling (#1554) 2020-04-14 11:50:29 +02:00
Sven Schwyn 4035c579c7 Don't uglify JS in development env (#1551) 2020-04-14 11:22:48 +02:00
Bart Kamphorst 8bab3de510 Merge pull request #1549 from yuttie/yuttie-patch-fix-data-file-path
Fix `data-file-path` in overview pages
2020-04-10 13:02:13 +02:00
Yuta Taniguchi 9ab4bbb17c Fix data-file-path
This correct the `data-file-path` attribute's value so that the value includes the ancestor directories to a file.
2020-04-09 23:51:02 +09:00
Bart Kamphorst ae024eb3b3 Merge pull request #1547 from heavywatal/flash-notice-h1
Fix a selector in flashNotice()
2020-04-08 20:16:04 +02:00
Watal M. Iwasaki db84653bf2 Fix a selector in flashNotice()
The original selector "#wiki-content h1" matches multiple times
when the page content has h1 headers, resulting in multiple notice
in a page, and what is worse, "$('#gollum-flash').fadeOut()" works
only for the first one.
2020-04-08 22:45:49 +09:00
Dawa Ometto d8ebba114f Release 5.0.1 2020-04-04 13:44:00 +02:00
Dawa Ometto b9d7375dba Fix migration script when using page-file-dir (#1542) 2020-04-04 13:43:29 +02:00
Dawa Ometto 676811206d Add tests for base_path (#1540) 2020-04-03 17:12:09 +02:00
Watal M. Iwasaki ff1baf0036 Replace redirect_to() with 'redirect to()` (#1536) 2020-04-03 15:32:51 +02:00
Sam 3d12aeb8b2 Update layout.mustache (#1539)
Fix loading of MathJax when run with a base path.
2020-04-03 15:28:00 +02:00
Dawa Ometto 5a8750a975 Fix migrate script path argument. Fix gollum --version (#1538) 2020-04-02 14:08:17 +02:00
Watal M. Iwasaki 0cb303f09f Check page.nil? before page.wiki (#1535) 2020-04-02 11:07:33 +02:00
Dawa Ometto edc7d0b50b Merge pull request #1531 from repotag/check_empty_repo
Add regression test against #1530
2020-03-31 16:51:19 +02:00
Dawa Ometto 2c268a9f8c Add regression test against #1530 2020-03-31 11:56:42 +02:00
Dawa Ometto d61a09d421 Update README.md 2020-03-30 12:33:57 +02:00
94 changed files with 1895 additions and 587 deletions
+39
View File
@@ -0,0 +1,39 @@
name: Deploy docker
on: [push]
env:
DEPLOY_NAME: gollumwiki/gollum:latest
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Check Out Repo
uses: actions/checkout@v2
- name: Login
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: true
tags: ${{ env.DEPLOY_NAME }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
+38
View File
@@ -0,0 +1,38 @@
name: Build and Test Docker
on: [push, pull_request]
env:
CI_IMAGE: gollum-ci-img
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build
id: docker_build
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
builder: ${{ steps.buildx.outputs.name }}
push: false
tags: ${{ env.CI_IMAGE }}
outputs: type=docker
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: docker state
run: docker image ls
- name: Run gollum as test
run: docker run -e CI=true ${{ env.CI_IMAGE }} --irb
+25
View File
@@ -0,0 +1,25 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Create Release
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
+46
View File
@@ -0,0 +1,46 @@
name: Ruby Build
on: [push, pull_request]
jobs:
jruby_build:
name: JRuby (${{ matrix.ruby }})
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [jruby-9.2.18]
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Set up Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake
mri_build:
name: Ruby (${{ matrix.ruby }})
runs-on: ubuntu-latest
strategy:
matrix:
ruby: [2.6, 2.7, 3.0]
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run tests
run: bundle exec rake
+1
View File
@@ -8,3 +8,4 @@ Gemfile.lock
.*
!.sprockets*
!lib/gollum/public/gollum/stylesheets/_styles.css
!.github*
-9
View File
@@ -1,9 +0,0 @@
rvm:
- 2.4.0
- 2.6.0
- jruby-9.2.9.0
jdk:
- oraclejdk9
before_install:
- sudo apt-get update
- sudo apt-get install libicu-dev
+4 -2
View File
@@ -21,7 +21,7 @@ Before submitting an issue, **please carefully look through the following places
Security vulnerabilities can be reported directly to the maintainers using these GPG keys:
* [@dometto](https://pgp.mit.edu/pks/lookup?op=vindex&search=0xD637E455CD3E27BF)
* [@dometto](https://keys.openpgp.org/vks/v1/by-fingerprint/02354CC9F820B52CC2791979BB8CCC95FD83B795)
Lastly, please **consider helping out** by opening a Pull Request!
@@ -62,6 +62,8 @@ Pull Requests fixing bugs, implementing new features, or updating documentation
```
bundle exec rake test
```
To profile slow tests, you can use `bundle exec rake test TESTOPTS="--verbose"`.
### Working with test repositories
@@ -70,7 +72,7 @@ An example of how to add a test file to the bare repository lotr.git.
```
mkdir tmp
cd tmp
git clone ../lotr.git/
git clone ../test/examples/lotr.git/
git log
echo "test" > test.md
git add .
+40
View File
@@ -0,0 +1,40 @@
FROM ruby:2.7-alpine AS builder
RUN apk add \
build-base \
cmake \
git \
icu-dev \
openssl-dev
COPY Gemfile* /tmp/
COPY gollum.gemspec* /tmp/
WORKDIR /tmp
RUN bundle install
RUN gem install \
asciidoctor \
creole \
wikicloth \
org-ruby \
RedCloth \
bibtex-ruby \
&& echo "gem-extra complete"
WORKDIR /app
COPY . /app
RUN bundle exec rake install
FROM ruby:2.7-alpine
COPY --from=builder /usr/local/bundle/ /usr/local/bundle/
RUN apk add \
bash \
git
VOLUME /wiki
WORKDIR /wiki
COPY docker-run.sh /docker-run.sh
ENTRYPOINT ["/docker-run.sh"]
+21 -5
View File
@@ -1,10 +1,26 @@
source 'https://rubygems.org'
if RUBY_PLATFORM == 'java'
gem 'warbler'
end
gem 'warbler', platforms: :jruby
# FIXME:
#
# There's an issue in 1.12.5 that causes XHTML elements to be generated badly,
# causing Gollum's test suite to fail.[1] The issue has been fixed upstream,
# but we're still waiting for a new Nokogiri point release.
#
# However, 1.12.5 is a security patch, so we don't want end users to use an
# older version of Nokogiri. But this is safe to do in our CI environment.
#
# Once there's a new Nokogiri release, we can remove this dependency and JRuby
# CI should pass normally again.
#
# Note that Nokogiri 1.11+ does not support Ruby v2.4.x anymore. So to make our
# current CI workflows pass, we should only try to install this version of
# Nokogiri for newer Ruby versions.
#
# [1]: https://github.com/gollum/gollum/issues/1779
gem 'nokogiri', '1.12.4' unless RUBY_VERSION.include? '2.4'
gemspec
gem "rake", '~> 12.3', '>= 12.3.3'
gem 'rake', '~> 13.0'
+25
View File
@@ -1,3 +1,28 @@
# 5.2.3 2021-04-18
* Fix bug preventing page titles from being displayed
# 5.2.1 2021-02-25
* Fix include call to a missing asset (@benjaminwil). This caused slow first page loads on JRuby.
# 5.2 2021-02-24
* Improved styling and Primer upgrade (@benjaminwil)
* Add redirect to rename commit (@ViChyavIn)
* Updated dependencies
* Bugfixes
# 5.1.2
* Guard against malicious filenames in breadcrumbs
# 5.1
* Bugfixes
* Add autosave feature (#1576)
* Add Add quick access to diff of each commit in the history
# 5.0 / 2020-03-17
This is a major new release that introduces many new features, bugfixes, and removes major limitations. See [here](https://github.com/gollum/gollum/wiki/5.0-release-notes) for a list of changes.
+16 -10
View File
@@ -2,8 +2,10 @@ gollum -- A git-based Wiki
====================================
[![Gem Version](https://badge.fury.io/rb/gollum.svg)](http://badge.fury.io/rb/gollum)
[![Build Status](https://travis-ci.org/gollum/gollum.svg?branch=master)](https://travis-ci.org/gollum/gollum)
![Build Status](https://github.com/gollum/gollum/actions/workflows/test.yaml/badge.svg)
[![Open Source Helpers](https://www.codetriage.com/gollum/gollum/badges/users.svg)](https://www.codetriage.com/gollum/gollum)
[![Cutting Edge Dependency Status](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/svg 'Cutting Edge Dependency Status')](https://dometto-cuttingedge.herokuapp.com/github/gollum/gollum/info)
**Gollum version 5.0 is out!** See [here](https://github.com/gollum/gollum/wiki/5.0-release-notes) for a list of changes and new features compared to Gollum version 4.x, and see some [Screenshots](https://github.com/gollum/gollum/wiki/Screenshots) of Gollum's features.
@@ -17,7 +19,7 @@ Gollum is a simple wiki system built on top of Git. A Gollum Wiki is simply a gi
* May be written in a variety of [markups](#markups).
* Can be edited with your favourite system editor or IDE (changes will be visible after committing) or with the built-in web interface.
* Can be displayed in all versions, reverted, etc.
* Gollum strives to be compatible with GitHub wikis (see `--hyphened-tag-lookup`)
* Gollum strives to be compatible with GitHub wikis (see `--lenient-tag-lookup`)
* Gollum supports advanced functionality like:
* [UML diagrams](https://github.com/gollum/gollum/wiki#plantuml-diagrams)
* [BibTeX and Citation support](https://github.com/gollum/gollum/wiki/BibTeX-and-Citations)
@@ -35,16 +37,16 @@ Gollum runs on Unix-like systems using its [adapter](https://github.com/gollum/r
## INSTALLATION
1. Ruby is best installed either via [RVM](https://rvm.io/) or a package manager of choice.
2. Gollum is best installed via RubyGems:
2. Gollum is best installed via RubyGems:
```
[sudo] gem install gollum
```
Installation examples for individual systems can be seen [here](https://github.com/gollum/gollum/wiki/Installation).
To run, simply:
1. Run: `gollum /path/to/wiki`.
1. Run: `gollum /path/to/wiki` where `/path/to/wiki` is an initialized Git repository.
2. Open `http://localhost:4567` in your browser.
See [below](#running-from-source) for information on running Gollum from source, as a Rack app, and more.
@@ -82,19 +84,19 @@ See [here](https://github.com/gollum/gollum/wiki/Custom-rendering-gems) for inst
### Rack
Gollum can also be ran with any [rack-compatible web server](https://github.com/rack/rack#supported-web-servers). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack).
Gollum can also be run with any [rack-compatible web server](https://github.com/rack/rack#supported-web-servers). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack).
### Rack, with an authentication server
Gollum can also be ran alongside a CAS (Central Authentication Service) SSO (single sign-on) server. With a bit of tweaking, this adds basic user-support to Gollum. To see an example and an explanation, navigate [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack-and-CAS-SSO).
Gollum can also be run alongside a CAS (Central Authentication Service) SSO (single sign-on) server. With a bit of tweaking, this adds basic user-support to Gollum. To see an example and an explanation, navigate [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Rack-and-CAS-SSO).
### Docker
Gollum can also be ran via [Docker](https://www.docker.com/). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Docker).
Gollum can also be run via [Docker](https://www.docker.com/). More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-via-Docker).
### Service
Gollum can also be ran as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service).
Gollum can also be run as a service. More on that [over here](https://github.com/gollum/gollum/wiki/Gollum-as-a-service).
## CONFIGURATION
@@ -124,7 +126,7 @@ Gollum comes with the following command line options:
| --no-display-metadata | none | Do not render metadata tables in pages. |
| --user-icons | [MODE] | Tell Gollum to use specific user icons for history view. Can be set to `gravatar`, `identicon` or `none`. Default: `none`. |
| --mathjax-config | [FILE] | Specify path to a custom MathJax configuration. If not specified, uses the `mathjax.config.js` file from repository root. |
| --template-dir | [PATH] | Specify custom mustache template directory. |
| --template-dir | [PATH] | Specify custom mustache template directory. Only overrides templates that exist in this directory. |
| --template-page | none | Use _Template in root as a template for new pages. Must be committed. |
| --emoji | none | Parse and interpret emoji tags (e.g. `:heart:`) except when the leading colon is backslashed (e.g. `\:heart:`). |
| --lenient-tag-lookup | none | Internal links resolve case-insensitively, will treat spaces as hyphens, and will match the first page found with a certain filename, anywhere in the repository. Provides compatibility with Gollum 4.x. |
@@ -148,3 +150,7 @@ When `--config` option is used, certain inner parts of Gollum can be customized.
## CONTRIBUTING
Please consider helping out! See [CONTRIBUTING](CONTRIBUTING.md) for information on how to submit issues, and how to start hacking on gollum.
## THANKS TO
[![Testing Powered By SauceLabs](https://opensource.saucelabs.com/images/opensauce/powered-by-saucelabs-badge-gray.png?sanitize=true "Testing Powered By SauceLabs")](https://saucelabs.com)
+2 -5
View File
@@ -181,11 +181,8 @@ end
desc 'Precompile assets'
task :precompile do
require './lib/gollum/views/helpers.rb'
require './lib/gollum/assets.rb'
require 'sprockets'
require 'sprockets-helpers'
require 'sass'
require './lib/gollum/app.rb'
Precious::App.set(:environment, :production)
env = Precious::Assets.sprockets
path = ENV.fetch('GOLLUM_ASSETS_PATH', ::File.join(File.dirname(__FILE__), 'lib/gollum/public/assets'))
manifest = Sprockets::Manifest.new(env, path)
+5 -27
View File
@@ -149,10 +149,10 @@ MSG
'Can be set to \'gravatar\' or \'identicon\'. Default: standard avatar.') do |mode|
wiki_options[:user_icons] = mode.to_s
end
opts.on('--template-dir [PATH]', 'Specify custom mustache template directory.') do |path|
opts.on('--template-dir [PATH]', 'Specify custom mustache template directory. Only overrides templates that exist in this directory.') do |path|
wiki_options[:template_dir] = path
end
opts.on('--template-page', 'Use _Template in root as a template for new pages.') do
opts.on('--template-page', 'Use _Template.{ext} as a template for new pages.') do
wiki_options[:template_page] = true
end
opts.on('--lenient-tag-lookup', 'Internal links resolve case-insensitively, will treat spaces as hyphens, and will match the first page found with a certain filename, anywhere in the repository. Provides compatibility with Gollum 4.x.') do
@@ -172,6 +172,7 @@ MSG
end
opts.on('--version', 'Display the current version of Gollum.') do
puts 'Gollum ' + Gollum::VERSION
exit 0
end
opts.on('--versions', 'Display the current version of Gollum and auxiliary gems.') do
require 'gollum-lib'
@@ -205,7 +206,7 @@ begin
rescue OptionParser::InvalidOption => e
puts "gollum: #{e.message}"
puts 'gollum: try \'gollum --help\' for more information'
exit
exit 1
end
# --gollum-path wins over ARGV[0]
@@ -270,7 +271,6 @@ else
Precious::App.set(:environment, ENV.fetch('RACK_ENV', :production).to_sym)
Precious::App.set(:gollum_path, gollum_path)
Precious::App.set(:wiki_options, wiki_options)
Precious::App.settings.mustache[:templates] = wiki_options[:template_dir] if wiki_options[:template_dir]
if cfg = options[:config]
# If the path begins with a '/' it will be considered an absolute path,
@@ -286,29 +286,7 @@ else
else
require 'rack'
class MapGollum
def initialize(base_path)
@mg = Rack::Builder.new do
map "/#{base_path}" do
run Precious::App
end
map '/' do
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
end
map '/*' do
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
end
end
end
def call(env)
@mg.call(env)
end
end
# Rack::Handler does not work with Ctrl + C. Use Rack::Server instead.
Rack::Server.new(:app => MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start
Rack::Server.new(:app => Precious::MapGollum.new(base_path), :Port => options[:port], :Host => options[:bind]).start
end
end
+4 -3
View File
@@ -4,8 +4,6 @@ require 'optparse'
require 'pathname'
require 'rubygems'
REPO = ARGV[0] || Dir.pwd
wiki_options = {}
options = {}
@@ -83,12 +81,15 @@ begin
const = setting.to_s.upcase
Object.const_set(const, value) unless Object.const_defined?(const)
end
wiki_options[:page_file_dir] = setting(:page_file_dir) ? setting(:page_file_dir) : wiki_options[:page_file_dir] # Allow settings :page_file_dir through PAGE_FILE_DIR constant.
rescue OptionParser::InvalidOption
puts "gollum-migrate-tags: #{$!.message}"
puts "gollum-migrate-tags: try 'gollum-migrate-tags --help' for more information"
exit
end
REPO = ARGV[0] || Dir.pwd
require 'gollum-lib'
if cfg = options[:config]
@@ -261,7 +262,7 @@ wiki.pages.each do |page|
log(:info,"Page #{page.path}")
new_data = page.formatted_data
if setting(:no_dry_run)
path = ::File.join([wiki.path, wiki.page_file_dir, page.path].compact)
path = ::File.join(wiki.path, page.path)
f = File.new(path, 'w')
f.write(new_data)
f.close
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/env ruby
#
# Distributed under the terms of the MIT License.
#
# Author: Sam Baskinger <basking2@yahoo.com>
#
# Description: gollum-post is an example script that shows how
# to post a file to Gollum. This may be used
# to build scripts around CI/CD pipelines that
# publish their documentation to Gollum.
#
require 'uri'
require 'mechanize'
require 'digest'
GOLLUM=URI('https://mygollum.server')
m = Mechanize.new()
page="TestPage"
path="/automated/docs"
format="asciidoc"
content="""
= This is #{page}
This page is automatically generated.
"""
message='Posting current documentation.'
# Check if the page exists.
p = m.get("#{GOLLUM}#{path}/#{page}")
# If we were redirected to the creat page...
if p.uri.to_s =~ /\/gollum\/create/
# ... then create the page.
p = m.post("#{GOLLUM}/gollum/create",
'keybinding' => 'default',
'page' => page,
'path' => path,
'format' => 'asciidoc',
'message' => 'Publish bot.',
'content' => content)
else
# ... else, get the previous content and update it.
p = m.get("#{GOLLUM}/gollum/edit#{path}/#{page}")
# Get the previous content. You _could_ check if this is unchanged at this
# step and post nothing.
previous_content = p.xpath('//textarea[@id="gollum-editor-body"]')[0].text
# The previous ETag is the Git SHA-1. We need this to replace the previous contents.
prev_etag = Digest::SHA1.hexdigest("blob #{previous_content.length}\0#{previous_content}")
# Post the updated document using the ETag of the previous document to avoid collisions.
p = m.post("#{GOLLUM}/gollum/edit#{path}/#{page}",
'keybinding' => 'default',
'page' => page,
'path' => path,
'format' => 'asciidoc',
'message' => message,
'etag' => prev_etag,
'content' => content)
end
Executable
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# Initialize the wiki
if [ ! -d .git ]; then
git init
fi
# Start gollum service
[[ "$@" != *--mathjax* ]] && echo "WARNING: Mathjax will soon be disabled by default. To explicitly enable it, use --mathjax" >&2
exec gollum $@ --mathjax
+23 -19
View File
@@ -5,8 +5,8 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9'
s.name = 'gollum'
s.version = '5.0.0'
s.date = '2020-03-30'
s.version = '5.2.3'
s.date = '2021-04-18'
s.license = 'MIT'
s.summary = 'A simple, Git-powered wiki.'
@@ -23,29 +23,29 @@ Gem::Specification.new do |s|
s.rdoc_options = ['--charset=UTF-8']
s.extra_rdoc_files = %w[README.md LICENSE]
s.add_dependency 'gollum-lib', '~> 5.0'
s.add_dependency 'kramdown', '~> 2.1.0'
s.add_dependency 'kramdown-parser-gfm', '~> 1.0.0'
s.add_dependency 'gollum-lib', '~> 5.1'
s.add_dependency 'kramdown', '~> 2.3'
s.add_dependency 'kramdown-parser-gfm', '~> 1.1.0'
s.add_dependency 'sinatra', '~> 2.0'
s.add_dependency 'sinatra-contrib', '~> 2.0'
s.add_dependency 'mustache', ['>= 0.99.5', '< 1.0.0']
s.add_dependency 'mustache-sinatra', '>= 1.0.1', '< 2'
s.add_dependency 'useragent', '~> 0.16.2'
s.add_dependency 'gemojione', '~> 4.1'
s.add_dependency 'octicons', '~> 8.5'
s.add_dependency 'octicons', '~> 12.0'
s.add_dependency 'sprockets', '~> 3.7'
s.add_dependency 'sass', '~> 3.5'
s.add_dependency 'uglifier', '~> 3.2'
s.add_dependency 'uglifier', '~> 4.2'
s.add_dependency 'sprockets-helpers', '~> 1.2'
s.add_dependency 'rss', '~> 0.2.9'
s.add_dependency 'therubyrhino', '~> 2.1.0'
s.add_dependency 'webrick', '~> 1.7'
s.add_dependency 'i18n', '~> 1.8'
s.add_development_dependency 'rack-test', '~> 0.6.3'
s.add_development_dependency 'shoulda', '~> 3.6.0'
s.add_development_dependency 'minitest-reporters', '~> 1.3.6'
s.add_development_dependency 'twitter_cldr', '~> 3.2.0'
s.add_development_dependency 'mocha', '~> 1.8.0'
s.add_development_dependency 'test-unit', '~> 3.3.0'
s.add_development_dependency 'webrick', '~> 1.4.2'
# = MANIFEST =
s.files = %w[
@@ -59,6 +59,7 @@ Gem::Specification.new do |s|
bin/gollum-migrate-tags
config.rb
config.ru
contrib/automation/gollum-post
contrib/openrc/conf.d/gollum
contrib/openrc/init.d/gollum
contrib/systemd/gollum@.service
@@ -68,15 +69,15 @@ Gem::Specification.new do |s|
lib/gollum/app.rb
lib/gollum/assets.rb
lib/gollum/helpers.rb
lib/gollum/public/assets/.sprockets-manifest-3edc7e21737459b21fbf150f5dccd15c.json
lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js
lib/gollum/public/assets/app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js.gz
lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css
lib/gollum/public/assets/app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css.gz
lib/gollum/public/assets/.sprockets-manifest-de7bb79aec424e55af1acdcc4237b301.json
lib/gollum/public/assets/app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js
lib/gollum/public/assets/app-0fd228e26bfbe6fe31a2da268eb0e98e780c1191c1a918adf383377946e9c838.js.gz
lib/gollum/public/assets/app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css
lib/gollum/public/assets/app-ad43ca64b295d8444b10f22ee868f18429268af498f1bc515434878b690e37a2.css.gz
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css
lib/gollum/public/assets/criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css.gz
lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js
lib/gollum/public/assets/editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js.gz
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js
lib/gollum/public/assets/editor-db10c8351306e92f1926ba225d0cd9c8e886482b3b9820a85825ec3abab5f1cf.js.gz
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css
lib/gollum/public/assets/print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css.gz
lib/gollum/public/gollum/javascript/HOWTO_UPDATE_ACE.md
@@ -1174,22 +1175,23 @@ Gem::Specification.new do |s|
lib/gollum/public/gollum/javascript/jquery-1.7.2.min.js
lib/gollum/public/gollum/javascript/jquery.resize.js
lib/gollum/public/gollum/javascript/mousetrap.min.js
lib/gollum/public/gollum/javascript/polyfills.js
lib/gollum/public/gollum/stylesheets/_base.scss
lib/gollum/public/gollum/stylesheets/_breakpoint.scss
lib/gollum/public/gollum/stylesheets/_component.scss
lib/gollum/public/gollum/stylesheets/_features.scss
lib/gollum/public/gollum/stylesheets/_layout.scss
lib/gollum/public/gollum/stylesheets/_spinners.scss
lib/gollum/public/gollum/stylesheets/app.scss
lib/gollum/public/gollum/stylesheets/criticmarkup.scss
lib/gollum/public/gollum/stylesheets/dialog.scss
lib/gollum/public/gollum/stylesheets/editor.scss
lib/gollum/public/gollum/stylesheets/emoji.scss
lib/gollum/public/gollum/stylesheets/primer.scss
lib/gollum/public/gollum/stylesheets/primer.css
lib/gollum/public/gollum/stylesheets/print.scss
lib/gollum/public/gollum/stylesheets/spinner.scss
lib/gollum/public/gollum/stylesheets/tables.scss
lib/gollum/public/gollum/stylesheets/template.scss.erb
lib/gollum/templates/commit.mustache
lib/gollum/templates/compare.mustache
lib/gollum/templates/create.mustache
lib/gollum/templates/edit.mustache
@@ -1201,6 +1203,7 @@ Gem::Specification.new do |s|
lib/gollum/templates/history_authors/none.mustache
lib/gollum/templates/latest_changes.mustache
lib/gollum/templates/layout.mustache
lib/gollum/templates/mobilenav.mustache
lib/gollum/templates/navbar.mustache
lib/gollum/templates/overview.mustache
lib/gollum/templates/page.mustache
@@ -1209,6 +1212,7 @@ Gem::Specification.new do |s|
lib/gollum/templates/searchbar.mustache
lib/gollum/templates/wiki_content.mustache
lib/gollum/uri_encode_component.rb
lib/gollum/views/commit.rb
lib/gollum/views/compare.rb
lib/gollum/views/create.rb
lib/gollum/views/edit.rb
+16 -13
View File
@@ -5,32 +5,35 @@ require 'digest/sha1'
require 'ostruct'
# external
require 'i18n'
require 'github/markup'
require 'rhino' if RUBY_PLATFORM == 'java'
# internal
require File.expand_path('../gollum/uri_encode_component', __FILE__)
require ::File.expand_path('../gollum/uri_encode_component', __FILE__)
module Gollum
VERSION = '5.0.0'
VERSION = '5.2.3'
::I18n.available_locales = [:en]
::I18n.load_path = Dir[::File.expand_path("lib/gollum/locales") + "/*.yml"]
def self.assets_path
::File.expand_path('gollum/public', ::File.dirname(__FILE__))
end
class Error < StandardError;
end
class TemplateFilter
@@filters = {}
class DuplicatePageError < Error
attr_accessor :dir
attr_accessor :existing_path
attr_accessor :attempted_path
def self.add_filter(pattern, &replacement)
@@filters[pattern] = replacement
end
def initialize(dir, existing, attempted, message = nil)
@dir = dir
@existing_path = existing
@attempted_path = attempted
super(message || "Cannot write #{@dir}/#{@attempted_path}, found #{@dir}/#{@existing_path}.")
def self.apply_filters(data)
@@filters.each do |pattern, replacement|
data.gsub!(pattern, replacement.call)
end
data
end
end
end
+114 -48
View File
@@ -1,4 +1,5 @@
# ~*~ encoding: utf-8 ~*~
# encoding: UTF-8
require 'cgi'
require 'sinatra'
require 'sinatra/namespace'
@@ -14,12 +15,15 @@ require 'pathname'
require 'gollum'
require 'gollum/assets'
require 'gollum/views/helpers'
require 'gollum/views/helpers/locale_helpers'
require 'gollum/views/layout'
require 'gollum/views/editable'
require 'gollum/views/has_page'
require 'gollum/views/has_user_icons'
require 'gollum/views/has_math'
require 'gollum/views/pagination'
require 'gollum/views/rss.rb'
require 'gollum/views/template_cascade'
require File.expand_path '../helpers', __FILE__
@@ -40,11 +44,37 @@ Gollum::set_git_max_filesize(190 * 10**6)
# See the wiki.rb file for more details on wiki options
module Precious
# For use with the --base-path option.
class MapGollum
def initialize(base_path)
@mg = Rack::Builder.new do
map "/#{base_path}" do
run Precious::App
end
map '/' do
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
end
map '/*' do
run Proc.new { [302, { 'Location' => "/#{base_path}" }, []] }
end
end
end
def call(env)
@mg.call(env)
end
end
class App < Sinatra::Base
register Mustache::Sinatra
register Sinatra::Namespace
include Precious::Helpers
Encoding.default_external = "UTF-8"
dir = File.dirname(File.expand_path(__FILE__))
set :sprockets, ::Precious::Assets.sprockets(dir)
@@ -78,11 +108,15 @@ module Precious
@critic_markup = settings.wiki_options[:critic_markup]
@redirects_enabled = settings.wiki_options.fetch(:redirects_enabled, true)
@per_page_uploads = settings.wiki_options[:per_page_uploads]
@wiki_title = settings.wiki_options.fetch(:title, 'Gollum Wiki')
forbid unless @allow_editing || request.request_method == 'GET'
Precious::App.set(:mustache, {:templates => settings.wiki_options[:template_dir]}) if settings.wiki_options[:template_dir]
if settings.wiki_options[:template_dir]
Precious::Views::Layout.extend Precious::Views::TemplateCascade
Precious::Views::Layout.template_priority_path = settings.wiki_options[:template_dir]
end
@base_url = url('/', false).chomp('/').force_encoding('utf-8')
@page_dir = settings.wiki_options[:page_file_dir].to_s
@@ -92,11 +126,12 @@ module Precious
@css = settings.wiki_options[:css]
@js = settings.wiki_options[:js]
@mathjax_config = settings.wiki_options[:mathjax_config]
@mathjax = settings.wiki_options[:mathjax]
@use_static_assets = settings.wiki_options.fetch(:static, settings.environment == :production || settings.environment == :staging)
@use_static_assets = settings.wiki_options.fetch(:static, settings.environment != :development)
@static_assets_path = settings.wiki_options.fetch(:static_assets_path, ::File.join(File.dirname(__FILE__), 'public/assets'))
@mathjax_path = ::File.join(File.dirname(__FILE__), 'public/gollum/javascript/MathJax')
Sprockets::Helpers.configure do |config|
config.environment = settings.sprockets
config.environment.context_class.class_variable_set(:@@base_url, @base_url)
@@ -184,17 +219,17 @@ module Precious
if page = wikip.page
@page = page
@content = page.text_data
@mathjax = wiki.mathjax
@etag = page.sha
mustache :edit
else
redirect_to("/create/#{encodeURIComponent(@name)}")
path = ::File.join('gollum/create', @path, @name)
redirect to(clean_url(encodeURIComponent(path)))
end
end
# AJAX calls only
post '/upload_file' do
wiki = wiki_new
halt 405 unless wiki.allow_uploads
@@ -205,14 +240,15 @@ module Precious
halt 500 unless tempfile.is_a? Tempfile
if wiki.per_page_uploads
# remove base_url and gollum/* subpath if necessary
dir = request.referer.
sub(request.base_url, '').
sub(/.*gollum\/[-\w]+\//, '')
dir = request.referer.match(/^https?:\/\/#{request.host_with_port}\/(.*)/)[1]
# remove base path if it is set
dir = dir.sub(wiki.base_path, '') if wiki.base_path
# remove file extension
dir = dir.sub(::File.extname(dir), '')
dir.sub!(/^#{wiki.base_path}/, '') if wiki.base_path
# remove base_url and gollum/* subpath if necessary
dir.sub!(/^\/gollum\/[-\w]+\//, '')
# remove file extension
dir.sub!(/#{::File.extname(dir)}$/, '')
# revert escaped whitespaces
dir.gsub!(/%20/, ' ')
dir = ::File.join('uploads', dir)
else
# store all uploads together
@@ -277,12 +313,13 @@ module Precious
redirect to("/#{page.escaped_url_path}")
return
end
committer.commit
# Renaming preserves format, so add the page's format to the renamed path to retrieve the renamed page
new_path = "#{rename}.#{Gollum::Page.format_to_ext(page.format)}"
# Add a redirect from the old page to the new
wiki.add_redirect(page.url_path, clean_url(new_path)) if @redirects_enabled
wiki.add_redirect(page.url_path, clean_url(new_path), commit) if @redirects_enabled
committer.commit
page = wiki_page(new_path).page
return if page.nil?
@@ -290,18 +327,17 @@ module Precious
end
post '/edit/*' do
etag = params[:etag]
etag = params[:etag]
path = "/#{clean_url(sanitize_empty_params(params[:path]))}"
page_name = CGI.unescape(params[:page])
wiki = wiki_new
page = wiki.page(::File.join(path, page_name))
page = wiki.page(::File.join(path, params[:page]))
return if page.nil?
if etag != page.sha
# Signal edit collision and return the page's most recent version
halt 412, {etag: page.sha, text_data: page.text_data}.to_json
end
committer = Gollum::Committer.new(wiki, commit_message)
commit = { :committer => committer }
@@ -322,18 +358,15 @@ module Precious
commit[:message] = "Deleted #{filepath}"
wiki.delete_file(filepath, commit)
end
end
end
get '/create/*' do
forbid unless @allow_editing
if settings.wiki_options[:template_page] then
temppage = wiki_page('/_Template')
@template_page = (temppage.page != nil) ? temppage.page.raw_data : 'Template page option is set, but no /_Template page is present or committed.'
end
wikip = wiki_page(params[:splat].first)
@name = wikip.name
@ext = wikip.ext
@path = wikip.path
@template_page = load_template(@path) if settings.wiki_options[:template_page]
@allow_uploads = wikip.wiki.allow_uploads
@upload_dest = find_upload_dest(wikip.fullpath)
@@ -391,7 +424,7 @@ module Precious
post '/preview' do
wiki = wiki_new
@name = params[:page] ? strip_page_name(CGI.unescape(params[:page])) : 'Preview'
@name = params[:page] ? strip_page_name(params[:page]) : 'Preview'
@page = wiki.preview_page(@name, params[:content], params[:format])
['sidebar', 'header', 'footer'].each do |subpage|
@page.send("set_#{subpage}".to_sym, params[subpage]) if params[subpage]
@@ -413,8 +446,8 @@ module Precious
@page = wikip.page
@page_num = [params[:page_num].to_i, 1].max
@max_count = settings.wiki_options.fetch(:pagination_count, 10)
@wiki = @page.wiki
unless @page.nil?
@wiki = @page.wiki
@versions = @page.versions(
per_page: @max_count,
page_num: @page_num,
@@ -434,20 +467,6 @@ module Precious
mustache :latest_changes
end
post '/compare/*' do
@file = encodeURIComponent(params[:splat].first)
@versions = params[:versions] || []
if @versions.size < 2
redirect_to("/history/#{@file}")
else
redirect_to("/compare/%s/%s...%s" % [
@file,
@versions.last,
@versions.first]
)
end
end
get %r{
/compare/ # match any URL beginning with /compare/
(.+) # extract the full path (including any directories)
@@ -471,8 +490,51 @@ module Precious
end
end
get '/compare/*' do
@file = clean_url(encodeURIComponent(params[:splat].first))
@versions = params[:versions] || []
if @versions.size == 1
wikip = wiki_page(params[:splat].first)
commit = wikip.wiki.repo.commit(@versions.first)
parent = commit.parent
if parent.nil?
redirect to("#{@file}/#{@commit.id}")
else
@versions.push(parent.id)
end
end
if @versions.empty?
redirect to("gollum/history/#{@file}")
else
redirect to("gollum/compare/%s/%s...%s" % [
@file,
@versions.last,
@versions.first]
)
end
end
get %r{
/commit/ # match any URL beginning with /show/
(\w+) # match the SHA1
}x do |version|
@version = version
wiki = wiki_new
begin
@commit = wiki.repo.commit(version)
parent = @commit.parent
parent_id = parent.nil? ? nil : parent.id
@diff = wiki.repo.diff(parent_id, version)
mustache :commit
rescue Gollum::Git::NoSuchShaFound
@message = "Invalid commit: #{@version}"
mustache :error
end
end
get '/search' do
@query = params[:q]
@query = params[:q] || ''
@name = @query
if @query.empty?
@results = []
@@ -552,7 +614,6 @@ module Precious
# Extensions and layout data
@editable = true
@toc_content = wiki.universal_toc ? @page.toc_data : nil
@mathjax = wiki.mathjax
@h1_title = wiki.h1_title
@bar_side = wiki.bar_side
@allow_uploads = wiki.allow_uploads
@@ -573,7 +634,7 @@ module Precious
end
end
end
def show_file(file)
return unless file
if file.on_disk?
@@ -584,6 +645,11 @@ module Precious
end
end
def load_template(path)
template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page
template_page ? Gollum::TemplateFilter.apply_filters(template_page.text_data) : nil
end
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
return if !page ||
((!content || page.raw_data == content) && page.format == format)
@@ -626,4 +692,4 @@ module Precious
end
end
end
end
+3 -3
View File
@@ -4,7 +4,7 @@ module Precious
module Assets
MANIFEST = %w(app.js editor.js app.css criticmarkup.css fileview.css ie7.css print.css *.png *.jpg *.svg *.eot *.ttf)
ASSET_URL = 'gollum/assets'
def self.sprockets(dir = File.dirname(File.expand_path(__FILE__)))
env = Sprockets::Environment.new
env.append_path ::File.join(dir, 'public/gollum/stylesheets/')
@@ -12,7 +12,7 @@ module Precious
env.append_path ::File.join(dir, 'public/gollum/images')
env.append_path ::File.join(dir, 'public/gollum/fonts')
env.js_compressor = :uglify
env.js_compressor = :uglify unless Precious::App.development?
env.css_compressor = :scss
env.context_class.class_eval do
@@ -26,4 +26,4 @@ module Precious
env
end
end
end
end
+1 -1
View File
@@ -19,7 +19,7 @@ module Precious
# Remove all double slashes
def clean_url(url)
return url if url.nil?
url.gsub('%2F', '/').gsub(/^\/+/, '').gsub('//', '/')
url.gsub('%2F', '/').gsub(%r{/{2,}}, '/').gsub(%r{^/}, '')
end
def forbid(msg = "Forbidden. This wiki is set to no-edit mode.")
@@ -1 +0,0 @@
{"files":{"app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js":{"logical_path":"app.js","mtime":"2020-03-30T11:12:22+02:00","size":136039,"digest":"982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5","integrity":"sha256-mCx/yhgycyok6SR0yicprrVvLQwFu3qP+RPp9YplANU="},"editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js":{"logical_path":"editor.js","mtime":"2020-03-29T22:28:50+02:00","size":746117,"digest":"0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1","integrity":"sha256-DbrijFPbWnPWZtMFBJRmcesJlI/9rx/dnRyNhW1MC6E="},"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css":{"logical_path":"app.css","mtime":"2020-03-30T11:12:22+02:00","size":298111,"digest":"b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7","integrity":"sha256-sgXlk6MPHMAFTi6e2fyK82WNjvSmK5cIwg8gRWDe77c="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2020-03-29T22:28:51+02:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2020-03-30T11:12:22+02:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-982c7fca1832732a24e92474ca2729aeb56f2d0c05bb7a8ff913e9f58a6500d5.js","editor.js":"editor-0dbae28c53db5a73d666d30504946671eb09948ffdaf1fdd9d1c8d856d4c0ba1.js","app.css":"app-b205e593a30f1cc0054e2e9ed9fc8af3658d8ef4a62b9708c20f204560deefb7.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
@@ -0,0 +1 @@
{"files":{"app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js":{"logical_path":"app.js","mtime":"2021-07-10T00:40:20+09:00","size":136040,"digest":"f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5","integrity":"sha256-8FQB7jdPDH9I/CvAjjC09NtwWGH9WJXtcJmGg7ODv7U="},"editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js":{"logical_path":"editor.js","mtime":"2021-07-10T00:42:29+09:00","size":744886,"digest":"9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a","integrity":"sha256-mIHQx65mMpPw46fnJynux+lA+mExhcB2cJt20pL1cDo="},"app-cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694.css":{"logical_path":"app.css","mtime":"2021-07-10T00:39:36+09:00","size":396625,"digest":"cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694","integrity":"sha256-yxIrTBdQD6peATy0MzT6/PLdfXL2lLBtlhb4sz/vtpQ="},"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css":{"logical_path":"criticmarkup.css","mtime":"2021-07-08T05:19:03+09:00","size":646,"digest":"31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4","integrity":"sha256-Ma5dMoK7uOe3w8mRfp+2jjMVprSnXabOxI0huIRpBcQ="},"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css":{"logical_path":"print.css","mtime":"2021-07-08T05:19:03+09:00","size":75,"digest":"512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb","integrity":"sha256-USSYw2i+DT+xuhBd+oQomuSDgOyfy++Ui9TiOwsJW/s="}},"assets":{"app.js":"app-f05401ee374f0c7f48fc2bc08e30b4f4db705861fd5895ed70998683b383bfb5.js","editor.js":"editor-9881d0c7ae663293f0e3a7e72729eec7e940fa613185c076709b76d292f5703a.js","app.css":"app-cb122b4c17500faa5e013cb43334fafcf2dd7d72f694b06d9616f8b33fefb694.css","criticmarkup.css":"criticmarkup-31ae5d3282bbb8e7b7c3c9917e9fb68e3315a6b4a75da6cec48d21b8846905c4.css","print.css":"print-512498c368be0d3fb1ba105dfa84289ae48380ec9fcbef948bd4e23b0b095bfb.css"}}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -7,3 +7,4 @@
//= require gollum.placeholder
//= require editor/sections
//= require jquery.resize
//= require polyfills
@@ -17,6 +17,8 @@
NoDefinitionsFor: []
};
var ActiveOptions = {};
var autoSaveTimer = null;
var storageKey = 'gollum_autorecover_' + window.location;
function isRTL(s){
var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF'+'\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
@@ -32,6 +34,27 @@
window.ace_editor.renderer.updateFull();
}
function autoSaveHandler() {
// Autosave
if (autoSaveTimer) {
// Reset the timer because we just changed the text
clearTimeout(autoSaveTimer);
}
$('#gollum-saved-msg').text('Saving...');
// Wait 2 seconds, then actualy save the text to local storage
autoSaveTimer = setTimeout(function() {
localStorage.setItem(storageKey, window.ace_editor.getSession().getValue());
// Save any subpage editor text that might exist
$('#gollum-editor-header, #gollum-editor-footer, #gollum-editor-sidebar').each(function(_, el) {
var spStorageKey = storageKey + el.id.replace('gollum-editor-', '_');
localStorage.setItem(spStorageKey, el.value);
});
$('#gollum-saved-msg').text('Saved recovery text');
}, 2000);
}
/**
* $.GollumEditor
*
@@ -55,6 +78,26 @@
var editor = ace.edit(editDiv[0], {rtlText: true});
window.ace_editor = editor;
// Check to see if we have any autosaved text and show a message to
// restore it if present.
var savedText = localStorage.getItem(storageKey);
if (savedText) {
$('#gollum-autorecover-button').click(function(e) {
editor.getSession().setValue(savedText);
// Restore subpage editor values too, if they exist
['header', 'footer', 'sidebar'].forEach(function(i) {
var sbSavedText = localStorage.getItem(storageKey + '_' + i);
if (sbSavedText) {
$('#gollum-editor-' + i).val(sbSavedText);
}
});
$('#gollum-autorecover-msg')[0].hidden = true;
e.preventDefault();
});
$('#gollum-autorecover-msg')[0].hidden = false;
}
editor.setTheme("ace/theme/tomorrow");
editor.setKeyboardHandler();
editor.renderer.setShowGutter(false);
@@ -64,8 +107,13 @@
editor.getSession().on('change', function(){
textarea.val(editor.getSession().getValue());
autoSaveHandler();
});
// Autosave for the header, footer and sidebar
$('#gollum-editor-header, #gollum-editor-footer, #gollum-editor-sidebar')
.on('change keyup paste', autoSaveHandler);
if (isRTL(editor.getSession().getLine(0))) {
switchRtl(true);
}
@@ -114,6 +162,16 @@
editor.focus();
});
// Remove any autosaved text when we hit save or cancel
$("#gollum-editor-submit, #gollum-editor-cancel").click(function() {
var storageKey = 'gollum_autorecover_' + window.location;
localStorage.removeItem(storageKey);
// Clear subpage editor values too, if they exist
['header', 'footer', 'sidebar'].forEach(function(i) {
localStorage.removeItem(storageKey + '_' + i);
});
});
debug('GollumEditor loading');
if ( EditorHas.baseEditorMarkup() ) {
@@ -160,7 +218,7 @@
$form.attr('action', this.href || routePath('preview'));
$form.attr('target', '_blank');
var paths = window.location.pathname.split('/');
$form.attr('page', paths[ paths.length - 1 ] || '')
$form.attr('page', decodeURIComponent(paths[ paths.length - 1 ]) || '')
$form.submit();
@@ -241,6 +299,7 @@
var ext = file.name.split('.').pop().toLowerCase()
var image_ext = ['jpg', 'jpeg', 'tif', 'tiff', 'png', 'gif', 'svg', 'bmp']
// Link directly to image files
uploadDest = uploadDest.replace(/%20/g, ' ');
if ((image_ext.indexOf(ext) > -1)) {
var text = '[[/' + uploadDest + '/' + file.name + ']]';
} else {
@@ -23,7 +23,7 @@
// For Gollum link tags
var GollumTagStart = {
token: "support.function",
regex: "\\[\\[.*\\]\\]",
regex: "\\[\\[[^\\]]*\\]\\]",
next: 'start'
};
@@ -105,7 +105,7 @@ function flashNotice(type, notice, button_label, button_function, button_type) {
}
html = '<p><div id="gollum-flash" class="flash flash-' + type +'"><button class="flash-close js-flash-close" type="button" onclick="parentNode.remove()"><%=rocticon('x')%></button>' + notice + nested_button_html + '</div></p>';
$('#gollum-flash').remove();
$('#wiki-content h1').before(html);
$('#wiki-content').before(html);
if (type == 'success') { setTimeout(function() {$('#gollum-flash').fadeOut();}, 5000); }
}
@@ -156,12 +156,12 @@ $(document).ready(function() {
}
if ($('#minibutton-upload-page').length) {
if ($('.minibutton-upload-page').length) {
new ClipboardJS('#ClipboardJSlink');
$('#minibutton-upload-page').parent().removeClass('jaws');
$('#minibutton-upload-page').click(function(e) {
$('.minibutton-upload-page').parent().removeClass('jaws');
$('.minibutton-upload-page').click(function(e) {
e.preventDefault();
$.GollumDialog.init({
title: 'Upload File',
fields: [
@@ -213,9 +213,9 @@ $(document).ready(function() {
});
}
if ($('#minibutton-rename-page').length) {
$('#minibutton-rename-page').parent().removeClass('jaws');
$('#minibutton-rename-page').click(function(e) {
if ($('.minibutton-rename-page').length) {
$('.minibutton-rename-page').parent().removeClass('jaws');
$('.minibutton-rename-page').click(function(e) {
e.preventDefault();
var path = decodeURI(pagePath());
@@ -257,9 +257,9 @@ $(document).ready(function() {
});
}
if ($('#minibutton-new-page').length) {
$('#minibutton-new-page').parent().removeClass('jaws');
$('#minibutton-new-page').click(function(e) {
if ($('.minibutton-new-page').length) {
$('.minibutton-new-page').parent().removeClass('jaws');
$('.minibutton-new-page').click(function(e) {
e.preventDefault();
var path = pagePath();
if( path === undefined && $('#file-browser').length != 0 ){
@@ -345,7 +345,7 @@ $(document).ready(function() {
var formData = new FormData($('#gollum-editor-form').get(0));
var paths = window.location.pathname.split('/');
var sectionAnchor = window.location.hash.substr(1);
formData.append('page', paths[ paths.length - 1 ] || '')
formData.append('page', decodeURIComponent(paths[ paths.length - 1 ]) || '')
$.ajax({
url: routePath('preview'),
data: formData,
@@ -380,8 +380,12 @@ $(document).ready(function() {
active_tab = '#edit.tabnav-tab';
}
$('.tabnav-tab.selected').removeAttr('aria-current');
$('.tabnav-tab.selected').removeClass('selected');
$(active_tab).attr('aria-current', 'page');
$(active_tab).addClass('selected');
$('.tabnav-div').hide();
$(active_div).show();
}
@@ -486,12 +490,13 @@ $(document).ready(function() {
}
numSelected = numSelected + 1;
});
if (numSelected == maxSelected) {
$('#version-form input:not(:checked)').prop('disabled', true);
$('.history button.action-compare-revision').prop('disabled', false);
} else if (numSelected < maxSelected) {
$('#version-form input').prop('disabled', false);
if (numSelected < 1) {
$('.history button.action-compare-revision').prop('disabled', true);
} else if (numSelected < maxSelected) {
$('.history button.action-compare-revision').prop('disabled', false);
$('#version-form input').prop('disabled', false);
} else {
$('#version-form input:not(:checked)').prop('disabled', true);
}
};
@@ -0,0 +1,6 @@
// Polyfill to support Internet Explorer
if (!Array.prototype.includes) {
Array.prototype.includes = function (x) {
return 0 <= this.indexOf(x)
};
}
@@ -1,83 +0,0 @@
// Describes base page layout
/* @section wrapper */
#wiki-wrapper {
margin: 0 auto;
overflow: visible;
width: 100%;
@include desktop-breakpoint {
@include desktop-page-layout;
}
}
/* @section content */
#wiki-content {
height: 1%;
overflow: visible;
.wrap {
height: 1%;
overflow: auto;
}
&.uploading {
opacity: 0.5;
}
p, li {
code {
white-space:pre-wrap;
word-wrap:break-word;
}
}
}
/* @section body */
#wiki-body {
display: block;
width: 100%;
margin-right: 3%;
@include largemobile-breakpoint {
float: left;
clear: left;
.has-sidebar & {
width: $layout-with-sidebar - $layout-with-sidebar-leeway;
}
.has-leftbar & {
float: right;
clear: right;
}
}
}
/* @section sidebar */
#wiki-sidebar {
@include largemobile-breakpoint {
width: $layout-sidebar;
.has-leftbar & {
float: left;
}
.has-rightbar & {
float: right;
}
}
}
/* @section footer */
#wiki-footer {
clear: both;
@include largemobile-breakpoint {
.has-sidebar & {
width: $layout-with-sidebar;
}
}
}
@@ -147,7 +147,3 @@
}
}
}
#gollum-dialog-dialog-buttons {
overflow: hidden;
}
@@ -29,6 +29,7 @@ a.tabnav-tab:focus {
overflow: hidden;
font-family: Consolas, "Liberation Mono", Courier, monospace;
font-size: 1em;
padding: 0;
}
#gollum-editor {
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -53,19 +53,85 @@ a {
/* Markdown body */
.header-enum {
h2 {counter-reset: h3}
h3 {counter-reset: h4}
h4 {counter-reset: h5}
h5 {counter-reset: h6}
--header-enum-style: decimal;
h1:before {counter-increment: h1; content: counter(h1, var(--header-enum-style)) ". ";}
h2:before {counter-increment: h2; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) ". ";}
h3:before {counter-increment: h3; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) ". ";}
h4:before {counter-increment: h4; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) "." counter(h4, var(--header-enum-style)) ". ";}
h5:before {counter-increment: h5; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) "." counter(h4, var(--header-enum-style)) "." counter(h5, var(--header-enum-style)) ". ";}
h6:before {counter-increment: h6; content: counter(h1, var(--header-enum-style)) "." counter(h2, var(--header-enum-style)) "." counter(h3, var(--header-enum-style)) "." counter(h4, var(--header-enum-style)) "." counter(h5, var(--header-enum-style)) "." counter(h6, var(--header-enum-style)) ". ";}
h1 {
counter-increment: h1;
counter-reset: h2;
&:before {
content: counter(h1, var(--header-enum-style)) ". ";
}
}
h2 {
counter-increment: h2;
counter-reset: h3;
&:before {
content:
counter(h1, var(--header-enum-style))
"." counter(h2, var(--header-enum-style))
". ";
}
}
h3 {
counter-reset: h4;
counter-increment: h3;
&:before {
content:
counter(h1, var(--header-enum-style))
"." counter(h2, var(--header-enum-style))
"." counter(h3, var(--header-enum-style))
". ";
}
}
h4 {
counter-increment: h4;
counter-reset: h5;
&:before {
content:
counter(h1, var(--header-enum-style))
"." counter(h2, var(--header-enum-style))
"." counter(h3, var(--header-enum-style))
"." counter(h4, var(--header-enum-style))
". ";
}
}
h5 {
counter-increment: h5;
counter-reset: h6;
&:before {
content:
counter(h1, var(--header-enum-style))
"." counter(h2, var(--header-enum-style))
"." counter(h3, var(--header-enum-style))
"." counter(h4, var(--header-enum-style))
"." counter(h5, var(--header-enum-style))
". ";
}
}
h6 {
counter-increment: h6;
&:before {
content:
counter(h1, var(--header-enum-style))
"." counter(h2, var(--header-enum-style))
"." counter(h3, var(--header-enum-style))
"." counter(h4, var(--header-enum-style))
"." counter(h5, var(--header-enum-style))
"." counter(h6, var(--header-enum-style))
". ";
}
}
}
#footer {
@@ -77,43 +143,58 @@ a {
padding: 1em 1em 1em 0;
font-size: 15px;
line-height: 1.7;
overflow: hidden;
word-wrap: break-word;
/* MediaWiki's TOC table -- this does not pertain to gollum's own TOC functionality */
table.toc {
width: auto;
display: inline-table;
.anchor {
display: none;
}
}
.anchor {
display: inline-block;
position: absolute;
opacity: 0;
background: url('data:image/svg+xml;utf8,<%= rocticon_css(:link) %>') no-repeat;
background-size: 0.6em 1.35em;
padding-right: 0.5em;
padding-top: 0.4em;
margin-left: -0.8em;
width: 1em;
height: 1em;
text-decoration: none;
transition-property: opacity;
transition: 0.1s;
}
h1,
h2,
h3,
h4,
h5,
h6 {
$anchor-icon-size: 20px;
*:hover > .anchor, .anchor:focus{
opacity: 1;
}
position: relative;
.anchor.edit {
margin-left: 2em !important;
margin-top: 0.5em;
height: 0.5em;
background: url('data:image/svg+xml;utf8,<%= rocticon_css(:pencil) %>') no-repeat;
.anchor {
display: inline-block;
position: absolute;
margin-top: 0.1em;
width: $anchor-icon-size;
text-decoration: none;
opacity: 0;
transition: opacity 0.1s ease-in-out;
&:before {
content: url('data:image/svg+xml;utf8,<%= rocticon_css(:link) %>');
}
&:not(.edit) {
left: -($anchor-icon-size/2);
}
&.edit {
margin-left: ($anchor-icon-size/2);
&:before {
content: url('data:image/svg+xml;utf8,<%= rocticon_css(:pencil) %>');
}
}
}
&:hover > .anchor,
.anchor:focus {
opacity: 1;
}
}
a {
@@ -125,13 +206,6 @@ a {
color: inherit;
text-decoration: none;
}
&:first-child {
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
padding-top: 0;
}
}
}
> *:first-child {
@@ -166,18 +240,6 @@ a {
border-bottom: 1px solid #eee;
}
h3 {
}
h4 {
}
h5 {
}
h6 {
}
p, blockquote, ul, ol, dl, table, pre {
margin: 15px 0;
}
@@ -615,6 +677,10 @@ a {
color: #999;
background-color: #EAF2F5;
}
.gg {
color: #000000a0;
}
}
.type-csharp {
@@ -639,15 +705,24 @@ a {
.s, .sc {
color: #A31515;
}
}
}
}
div.pagination a.disabled {
pointer-events: none;
}
nav.actions {
scrollbar-width: none;
-ms-overflow-style: -ms-autohiding-scrollbar;
::webkit-scrollbar {
display: none;
}
}
.search-results {
.search-context li:nth-child(n+4) {
display: none;
}
}
}
+26
View File
@@ -0,0 +1,26 @@
<div id="wiki-wrapper" class="compare">
<div id="head">
<h1 class="py-4">{{message}}</h1>
{{author}} commited {{authored_date}}
<span class="px-2 float-right">commit <code>{{version}}</code></span>
</div>
<div id="compare-content">
{{#files}}
<div class="Box data highlight my-3">
<div class="Box-header Box--condensed Box-header--gray">
<code>{{path}}</code>
</div>
<table>
{{#lines}}
<tr>
<td class="line_numbers">{{ldln}}</td>
<td class="line_numbers">{{rdln}}</td>
<td><div class="{{class}} pl-2">{{line}}</div></td>
</tr>
{{/lines}}
</table>
</div>
{{/files}}
</div>
</div>
+9 -7
View File
@@ -4,13 +4,15 @@
<h1 class="py-4">Create New Page</h1>
</div>
<div id="wiki-content" class="create edit">
<div class="tabnav">
<nav class="tabnav-tabs" aria-label="Foo bar">
<a href="#" id="edit" class="tabnav-tab selected" aria-current="edit">Edit</a>
<a href="#" id="preview" class="tabnav-tab" aria-current="preview">Preview</a>
</nav>
</div>
<div class="tabnav">
<nav class="tabnav-tabs" aria-label="Toggle edit or preview mode">
<a href="#" id="edit" class="tabnav-tab selected" aria-current="page">
Edit
</a>
<a href="#" id="preview" class="tabnav-tab">Preview</a>
</nav>
</div>
<div class="has-sidebar tabnav-div" id="edit-content">
{{>editor}}
</div>
+4 -2
View File
@@ -5,8 +5,10 @@
</div>
<div class="tabnav">
<nav class="tabnav-tabs">
<a href="#" id="edit" class="tabnav-tab selected" aria-current="edit">Edit</a>
<a href="#" id="preview" class="tabnav-tab" aria-current="preview">Preview</a>
<a href="#" id="edit" class="tabnav-tab selected" aria-current="page">
Edit
</a>
<a href="#" id="preview" class="tabnav-tab">Preview</a>
</nav>
</div>
<div class="tabnav-div" id="edit-content">{{>editor}}</div>
+8 -3
View File
@@ -37,7 +37,7 @@
<button class="btn btn-sm function-button" id="function-h3" title="Heading 3">h3</button>
<span class="pr-2"></span>
<button class="btn btn-sm function-button" id="function-link" title="Link">{{#octicon}}link{{/octicon}}</button>
<button class="btn btn-sm function-button" id="function-image" title="Image">{{#octicon}}file-media{{/octicon}}</button>
<button class="btn btn-sm function-button" id="function-image" title="Image">{{#octicon}}image{{/octicon}}</button>
<span class="pr-2"></span>
{{#critic_markup}}
<button class="btn btn-sm function-button" id="function-critic-accept" title="Accept Selected CriticMarkup">{{#octicon}}plus{{/octicon}}</button>
@@ -50,13 +50,13 @@
<div id="gollum-editor-format-selector">
<label for="format">Keybinding</label>
<select id="keybinding" name="keybinding" class="form-select">
<select id="keybinding" name="keybinding" class="form-select input-sm">
<option selected="selected">default</option>
<option>vim</option>
<option>emacs</option>
</select>
<label for="format">Markup</label>
<select id="wiki_format" name="format" class="form-select">
<select id="wiki_format" name="format" class="form-select input-sm">
{{#formats}}
{{#enabled}}
<option {{#selected}}selected="selected" {{/selected}}value="{{id}}" data-ext="{{ext}}">
@@ -96,6 +96,10 @@
</p>
</div>
</div>
</div>
<div id="gollum-autorecover-msg" class="flash" hidden>
Autosaved text is available. Click the button to restore it.
<button id="gollum-autorecover-button" class="btn btn-sm primary flash-action">Restore Text</button>
</div>
<textarea id="gollum-editor-body" class="form-control"
data-markup-lang="{{format}}" name="content" class="mousetrap">{{content}}</textarea>
@@ -147,3 +151,4 @@
</fieldset>
</form>
</div>
<div id="gollum-saved-msg" class="position-fixed bottom-0 left-0"></div>
+5 -2
View File
@@ -7,7 +7,7 @@
{{>pagination}}
<form name="selection-form" id="selection-form" method="post" action="{{compare_path}}/{{escaped_url_path}}"></form>
<form name="selection-form" id="selection-form" method="get" action="{{compare_path}}/{{escaped_url_path}}"></form>
<div id="page-history-list" class="Box Box--condensed flex-auto">
<form id="version-form">
@@ -18,7 +18,10 @@
<span class="float-left col-2" id="user-icons">{{>author_template}}</span>
<span class="flex-auto col-1 text-gray-light">{{date}}</span>
<span class="flex-auto col-5">{{message}}</span>
<span class="pl-4 float-right">[<a href="{{base_url}}/{{filename}}/{{id}}" title="View commit">{{id7}}</a>]</span>
<span class="pl-4 float-right">
<a href="{{href}}" class="btn btn-outline text-mono">{{id7}}</a>
<a href="{{href_page}}" title="Browse the page at this point in the history" class="btn btn-outline">{{#octicon}}code{{/octicon}}</a>
</span>
</li>
{{/versions}}
</ul>
+8 -6
View File
@@ -8,20 +8,22 @@
<div id="wiki-history">
<div class="Box flex-auto">
<ul class="Box flex-auto">
{{#versions}}
<div class="Box-row Box-row--hover-gray border-top d-flex flex-items-center">
<li class="Box-row Box-row--hover-gray border-top d-flex flex-items-center">
<span class="float-left col-2" id="user-icons">{{>author_template}}</span>
<span class="flex-auto col-1 text-gray-light">{{date}}</span>
<span class="flex-auto col-7">{{message}}<br/>
<span class="flex-auto col-5">{{message}}<br/>
{{#files}}
<span class="flex-auto col-2">{{#renamed}}{{renamed}} -> {{/renamed}}<a href="{{link}}">{{file}}</a></span><br/>
{{/files}}
</span>
<span class="pl-4 float-right">[{{id7}}]</span>
</div>
<span class="pl-4 float-right">
<a href="{{href}}" class="btn btn-outline text-mono">{{id7}}</a>
</span>
</li>
{{/versions}}
</div>
</ul>
</div>
+4 -5
View File
@@ -8,10 +8,9 @@
{{#sprockets_stylesheet_tag}}app{{/sprockets_stylesheet_tag}}
{{#sprockets_stylesheet_tag}}print print{{/sprockets_stylesheet_tag}}
{{#css}}<link rel="stylesheet" type="text/css" href="{{custom_path}}/custom.css" media="all">{{/css}}
{{#css}}<link rel="stylesheet" type="text/css" href="{{custom_css}}" media="all">{{/css}}
{{#noindex}}<meta name="robots" content="noindex, nofollow" />{{/noindex}}
<script>
var criticMarkup = '{{critic_markup}}';
var baseUrl = '{{base_url}}';
@@ -49,11 +48,11 @@
};
</script>
{{#mathjax_config}}
<script type="text/javascript" src="{{base_url}}/{{mathjax_config}}"></script>
<script type="text/javascript" src="{{mathjax_config_path}}"></script>
{{/mathjax_config}}
<script defer src="{{base_path}}/gollum/assets/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script defer src="{{mathjax_js}}"></script>
{{/mathjax}}
{{#js}}<script type="text/javascript" src="{{custom_path}}/custom.js"></script>{{/js}}
{{#js}}<script type="text/javascript" src="{{custom_js}}"></script>{{/js}}
<title>{{title}}</title>
</head>
+72
View File
@@ -0,0 +1,72 @@
<details class="details-reset details-overlay">
<summary class="btn btn-invisible" aria-haspopup="true">
<span aria-label="Open menu">☰</span>
</summary>
<div class="SelectMenu mx-sm-2">
<div class="SelectMenu-modal">
<div class="SelectMenu-divider py-3">
<h2 class="h6">Current Page</h2>
<div>{{page_header}}</div>
</div>
{{#history}}
<a
class="SelectMenu-item"
href="{{history_path}}/{{escaped_url_path}}"
role="menuitem"
>
<span>History</span>
</a>
{{/history}}
{{#allow_editing}}
{{#allow_uploads}}
<a class="SelectMenu-item minibutton-upload-page" role="menuitem">
<span>Upload</span>
</a>
{{/allow_uploads}}
{{#editable}}
<a class="SelectMenu-item minibutton-rename-page" role="menuitem">
<span>Rename</span>
</a>
<a
class="SelectMenu-item minibutton-edit-page"
href="{{edit_path}}/{{escaped_url_path}}"
role="menuitem"
>
<span>Edit</span>
</a>
{{/editable}}
{{/allow_editing}}
<div class="SelectMenu-divider py-3">
<h2 class="h6">Main Menu</h2>
</div>
<div class="SelectMenu-list">
<a class="SelectMenu-item" role="menuitem" href="{{page_route}}">
Home
</a>
{{#overview}}
<a class="SelectMenu-item" role="menuitem" href="{{overview_path}}">
Overview
</a>
{{/overview}}
{{#latest_changes}}
<a
class="SelectMenu-item"
href="{{latest_changes_path}}"
role="menuitem"
>
Latest Changes
</a>
{{/latest_changes}}
</div>
</div>
</div>
</details>
+101 -41
View File
@@ -1,43 +1,103 @@
<nav class="actions pt-4">
<div class="TableObject">
<div class="TableObject-item">
<a class="btn" href="{{base_url}}/">Home</a>
</div>
<nav class="TableObject actions pt-4 px-2 px-lg-0 overflow-x-scroll">
<div class="TableObject-item hide-lg hide-xl">
{{>mobilenav}}
</div>
<div class="TableObject-item hide-sm hide-md">
<a class="btn btn-sm" id="minibutton-home" href="{{page_route}}">
Home
</a>
</div>
<div class="TableObject-item TableObject-item--primary px-2" {{^search}}style="visibility:hidden"{{/search}}>
{{>searchbar}}
</div>
<div class="TableObject-item">
{{#overview}}<a class="btn" href="{{overview_path}}">Overview</a>{{/overview}}
{{#latest_changes}}<a class="btn" href="{{latest_changes_path}}">Latest Changes</a>{{/latest_changes}}
</div>
{{#history}}
<div class="TableObject-item pl-1">
<a class="btn" href="{{history_path}}/{{escaped_url_path}}">Page History</a>
</div>
{{/history}}
{{#allow_editing}}
<div class="TableObject-item pl-1">
{{#allow_uploads}}
<a class="btn" id="minibutton-upload-page" href="#">Upload</a>
{{/allow_uploads}}
{{#editable}}
<a class="btn" id="minibutton-rename-page" href="#">Rename</a>
<a class="btn" id="minibutton-edit-page" href="{{edit_path}}/{{escaped_url_path}}">Edit</a>
<a class="btn btn-primary" id="minibutton-new-page" href="#">New</a>
{{/editable}}
{{^editable}}
{{#newable}}
<a class="btn btn-primary" id="minibutton-new-page" href="#">New</a>
{{/newable}}
{{/editable}}
</div>
{{/allow_editing}}
</div>
</nav>
<div
class="TableObject-item TableObject-item--primary px-2"
{{^search}}style="visibility:hidden"{{/search}}
>
{{>searchbar}}
</div>
<div class="TableObject-item hide-sm hide-md">
<div class="BtnGroup d-flex">
{{#overview}}
<a
class="btn BtnGroup-item btn-sm"
href="{{overview_path}}"
id="minibutton-overview"
>
Overview
</a>
{{/overview}}
{{#latest_changes}}
<a
class="btn BtnGroup-item btn-sm"
href="{{latest_changes_path}}"
id="minibutton-latest-changes"
>
Latest Changes
</a>
{{/latest_changes}}
</div>
</div>
<div class="TableObject-item px-2">
<div class="BtnGroup d-flex">
{{#history}}
<a
class="btn BtnGroup-item btn-sm hide-sm hide-md"
href="{{history_path}}/{{escaped_url_path}}"
id="minibutton-history"
>
History
</a>
{{/history}}
{{#allow_editing}}
{{#allow_uploads}}
<button
class="btn BtnGroup-item btn-sm hide-sm hide-md
minibutton-upload-page"
>
Upload
</button>
{{/allow_uploads}}
{{#editable}}
<button
class="btn BtnGroup-item btn-sm hide-sm hide-md
minibutton-rename-page"
>
Rename
</button>
<a
class="btn BtnGroup-item btn-sm hide-sm hide-md"
href="{{edit_path}}/{{escaped_url_path}}"
id="minibutton-edit-page"
>
Edit
</a>
{{/editable}}
{{/allow_editing}}
</div>
</div>
{{#allow_editing}}
{{#editable}}
<div class="TableObject-item">
<a class="btn btn-primary btn-sm minibutton-new-page" href="#">
New
</a>
</div>
{{/editable}}
{{^editable}}
{{#newable}}
<div class="TableObject-item">
<a class="btn btn-primary btn-sm minibutton-new-page" href="#">
New
</a>
</div>
{{/newable}}
{{/editable}}
{{/allow_editing}}
</nav>
+2 -2
View File
@@ -16,9 +16,9 @@
{{#files_folders}}
<li class="Box-row">
<span class="pr-2">{{{icon}}}</span>
<span><a href={{url}}>{{name}}</a></span>
<span><a href="{{url}}">{{name}}</a></span>
{{#allow_editing}}
{{#is_file}}<button class="btn btn-sm float-right delete-file" data-file-path={{name}} data-confirm="Are you sure you want to delete {{name}}?">{{#octicon}}trashcan{{/octicon}}</button>{{/is_file}}
{{#is_file}}<button class="btn btn-sm float-right delete-file" data-file-path="{{file_path}}" data-confirm="Are you sure you want to delete {{name}}?">{{#octicon}}trash{{/octicon}}</button>{{/is_file}}
{{/allow_editing}}
</li>
{{/files_folders}}
+2 -3
View File
@@ -13,9 +13,8 @@
<div class="Box-header border-bottom p-0"></div>
{{#results}}
<li class="Box-row Box-row--gray">
<span class="Counter Counter--gray tooltipped tooltipped-w" aria-label="{{filename_count}} hits in filename - {{count}} hits in content">{{filename_count}} - {{count}}</span>&nbsp;
<span class="text-bold"><a href="{{base_url}}/{{name}}">{{name}}</a></span>
<span class="Counter Counter--gray tooltipped tooltipped-w" aria-label="{{filename_count}} hits in filename - {{count}} hits in content">{{filename_count}} - {{count}}</span>&nbsp;
<span class="text-bold"><a href="{{href}}">{{name}}</a></span>
<button class="btn-link tooltipped tooltipped-w float-right toggle-context" aria-label="Show all {{count}} hits in this page">{{#octicon}}search{{/octicon}}</button>
</li>
+18 -17
View File
@@ -1,7 +1,6 @@
<div id="wiki-content">
<div id="wiki-content" class="px-2 px-lg-0">
<h1 class="pt-4">{{page_header}}</h1>
<div class="breadcrumb">{{{breadcrumb}}}</div>
<div class="{{#has_header}}has-header{{/has_header}}{{#has_footer}} has-footer{{/has_footer}}{{#has_sidebar}} has-sidebar has-{{bar_side}}bar{{/has_sidebar}}{{#has_toc}} has-toc{{/has_toc}}">
{{#has_toc}}
@@ -9,14 +8,7 @@
{{{toc_content}}}
</div>
{{/has_toc}}
{{#has_sidebar}}
<div id="wiki-sidebar" class="gollum-{{sidebar_format}}-content">
<div id="sidebar-content" class="Box Box--condensed col-3 markdown-body px-4 float-{{bar_side}}">
{{{sidebar_content}}}
</div>
</div>
{{/has_sidebar}}
<div id="wiki-body" class="gollum-{{format}}-content overflow-hidden {{#left_bar}}pl-4{{/left_bar}}">
<div id="wiki-body" class="gollum-{{format}}-content">
{{#has_header}}
<div id="wiki-header" class="gollum-{{header_format}}-content">
<div id="header-content" class="markdown-body">
@@ -24,19 +16,28 @@
</div>
</div>
{{/has_header}}
<div class="markdown-body {{#header_enum?}}header-enum{{/header_enum?}}" {{#header_enum?}}style="--header-enum-style:{{header_enum_style}};"{{/header_enum?}}>
{{{rendered_metadata}}}
{{{content}}}
<div class="main-content clearfix container-lg">
<div class="markdown-body {{#header_enum?}}header-enum{{/header_enum?}} {{#has_sidebar}}float-md-{{body_side}} col-md-9{{/has_sidebar}}" {{#header_enum?}}style="--header-enum-style:{{header_enum_style}};"{{/header_enum?}}>
{{{rendered_metadata}}}
{{{content}}}
</div>
{{#has_sidebar}}
<div id="wiki-sidebar" class="Box Box--condensed float-md-{{body_side}} col-md-3">
<div id="sidebar-content" class="gollum-{{sidebar_format}}-content markdown-body px-4">
{{{sidebar_content}}}
</div>
</div>
{{/has_sidebar}}
</div>
</div>
{{#has_footer}}
<div id="wiki-footer" class="gollum-{{footer_format}}-content">
<div id="footer-content" class="Box Box-condensed markdown-body pl-2">
<div id="wiki-footer" class="gollum-{{footer_format}}-content my-2">
<div id="footer-content" class="Box Box-condensed markdown-body px-4">
{{{footer_content}}}
</div>
</div>
{{/has_footer}}
</div>
</div>
@@ -57,5 +58,5 @@
{{/historical}}
</div>
</div>
+45
View File
@@ -0,0 +1,45 @@
require_relative 'compare.rb'
module Precious
module Views
class Commit < Compare
attr_reader :version
def title
"Changes in #{@version[0..6]}: #{message}"
end
def author
@commit.author.name
end
def authored_date
@commit.authored_date
end
def message
@commit.message
end
def files
files = @diff.force_encoding(Encoding::UTF_8).scan(%r{
^diff\ --git\ # diff start
.+? # diff body
(?=^diff\ --git|\Z) # scan until next diff or string
}sxmu)
files.map do |diff|
match = diff.match(%r{^diff --git (")?[ab]/(.+)(?(1)") (")?[ab]/(.+)(?(3)")})
path = match[2]
path = match[4] if path.nil?
{
path: path,
lines: lines(diff)
}
end
end
end
end
end
+19 -8
View File
@@ -17,18 +17,23 @@ module Precious
@versions[1][0..6]
end
def lines
def lines(diff = @diff)
lines = []
lines_to_parse = @diff.split("\n")[4..-1]
# If the diff is of a rename, the diff header will be one line longer than normal because it will contain a line starting with '+++' to indicate the 'new' filename.
# Make sure to skip that header line if it is present.
lines_to_parse = lines_to_parse[1..-1] if lines_to_parse[0].start_with?('+++')
lines_to_parse = diff.split("\n")[3..-1]
lines_to_parse = lines_to_parse[2..-1] if lines_to_parse[0] =~ /^(---|rename to )/
if lines_to_parse.nil? || lines_to_parse.empty?
lines_to_parse = [] # File is created without content
else
lines_to_parse = lines_to_parse[1..-1] if lines_to_parse[0].start_with?('+++')
end
lines_to_parse.each_with_index do |line, line_index|
lines << { :line => line,
:class => line_class(line),
:ldln => left_diff_line_number(line),
:rdln => right_diff_line_number(line) }
end if @diff
end
lines
end
@@ -41,6 +46,8 @@ module Precious
def line_class(line)
if line =~ /^@@/
'gc'
elsif git_line?(line)
'gg'
elsif line =~ /^\+/
'gi'
elsif line =~ /^\-/
@@ -53,7 +60,7 @@ module Precious
@left_diff_line_number = nil
def left_diff_line_number(line)
if line =~ /^@@/
if git_line?(line)
m, li = *line.match(/\-(\d+)/)
@left_diff_line_number = li.to_i
@current_line_number = @left_diff_line_number
@@ -75,7 +82,7 @@ module Precious
@right_diff_line_number = nil
def right_diff_line_number(line)
if line =~ /^@@/
if git_line?(line)
m, ri = *line.match(/\+(\d+)/)
@right_diff_line_number = ri.to_i
@current_line_number = @right_diff_line_number
@@ -93,6 +100,10 @@ module Precious
end
ret
end
def git_line?(line)
!!(line =~ /^(\\ No newline|Binary files|@@)/)
end
end
end
end
+3 -2
View File
@@ -2,6 +2,7 @@ module Precious
module Views
class Create < Layout
include Editable
include HasMath
attr_reader :page, :name
@@ -41,9 +42,9 @@ module Precious
def content
@template_page
end
private
def find_format
@found_format ||= (Gollum::Page.format_for("#{@name}#{@ext}") || default_markup)
end
+2 -5
View File
@@ -3,6 +3,7 @@ module Precious
class Edit < Layout
include Editable
include HasPage
include HasMath
attr_reader :page, :content
@@ -18,10 +19,6 @@ module Precious
def page_name
@name
end
def mathjax
@mathjax
end
def header
if @header.nil?
@@ -67,7 +64,7 @@ module Precious
def etag
@etag
end
def allow_uploads
@allow_uploads
end
+11
View File
@@ -0,0 +1,11 @@
module Precious
module HasMath
def mathjax
@mathjax
end
def mathjax_config
@mathjax_config
end
end
end
-4
View File
@@ -15,9 +15,5 @@ module Precious
def id
@page.sha
end
def full_url_path
::File.join(@base_url, escaped_url_path)
end
end
end
+13 -3
View File
@@ -39,7 +39,7 @@ module Precious
route_path = "#{prefix}/#{path}"
@@route_methods[name.to_s] = route_path
define_method :"#{name.to_s}_path" do
"#{base_url}/#{route_path}".gsub(/\/{2,}/, '/') # remove double slashes
page_route(route_path)
end
end
end
@@ -53,8 +53,18 @@ module Precious
end
end
def page_route(page)
"#{base_url}/#{page}".gsub(/\/{2,}/, '/') # remove double slashes
def page_route(page = nil)
clean_url("/#{@base_url}", page)
end
def clean_url(*url)
url.compact!
return nil if url.empty?
_url = ::File.join(*url)
_url.gsub!(%r{/{2,}}, '/')
_url.gsub!(%r{\?}, '%3F')
_url
end
end
@@ -0,0 +1,82 @@
module Precious
module Views
module LocaleHelpers
NO_METHOD_MESSAGE = 'Argument must be a view method'
YAML_VARIABLE_REGEXP = /\%\{[\w]+\}/
# Returns all I18n translation strings for the current view class.
# This method support YAML arguments. For example:
#
# last_edited: This content was last edited at %{date}.
#
# Where the `date` argument must be a method available on the current
# class.
#
# Use this interface within Mustache templates to render any user
# interface strings in the current locale. For example:
#
# {{ t.last_edited }}
#
def t
autofill I18n.t(locale_klass_name)
end
private
# Recursively looks up I18n translation values and autofills any YAML
# arguments with the return value of the current class's matching method.
#
# When a translation value with an argument has no matching method, we
# then return that value transformed to include the `no_method_message`
#
def autofill(yaml)
yaml.map { |i18n_key, i18n_value|
if i18n_value.is_a? Hash
[i18n_key, autofill(i18n_value)]
elsif has_arguments?(i18n_value)
fill_argument_content(i18n_key, i18n_value)
else
[i18n_key, i18n_value]
end
}.to_h
end
def fill_argument_content(i18n_key, i18n_value)
i18n_value.gsub!(YAML_VARIABLE_REGEXP) do |argument|
method_name = argument.gsub(/[^\w]/, '')
next if method_name.nil?
begin
self.public_send(method_name)
rescue NoMethodError => error
no_method_message(method_name)
end
end
[i18n_key, i18n_value]
end
def has_arguments?(i18n_value)
i18n_value.match?(YAML_VARIABLE_REGEXP)
end
# Returns the current class name in a format that is acceptable in YAML.
# To summarize its function:
#
# NameOfConstant => name_of_constant
#
def locale_klass_name
@locale_klass_name ||= self.class.name.gsub(/::/, '/').
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
gsub(/([a-z\d])([A-Z])/,'\1_\2').
tr('-', '_').
downcase
end
def no_method_message(method_name, message = NO_METHOD_MESSAGE)
"[#{message}: #{method_name}]"
end
end
end
end
+4 -1
View File
@@ -17,15 +17,18 @@ module Precious
i = @versions.size + 1
@versions.map do |v|
i -= 1
filename = path_for_version(v.tracked_pathname)
{ :id => v.id,
:id7 => v.id[0..6],
:href => page_route("gollum/commit/#{v.id}"),
:href_page => page_route("#{filename}/#{v.id}"),
:num => i,
:selected => @page.version.id == v.id,
:author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
:message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
:date => v.authored_date.strftime("%B %d, %Y"),
:user_icon => self.user_icon_code(v.author.email),
:filename => path_for_version(v.tracked_pathname),
:filename => filename,
:date_full => v.authored_date,
}
end
+1
View File
@@ -16,6 +16,7 @@ module Precious
i -= 1
{ :id => v.id,
:id7 => v.id[0..6],
:href => page_route("gollum/commit/#{v.id}"),
:num => i,
:author => v.author.name.respond_to?(:force_encoding) ? v.author.name.force_encoding('UTF-8') : v.author.name,
:message => v.message.respond_to?(:force_encoding) ? v.message.force_encoding('UTF-8') : v.message,
+19 -2
View File
@@ -6,10 +6,11 @@ module Precious
include Rack::Utils
include Sprockets::Helpers
include Precious::Views::AppHelpers
include Precious::Views::LocaleHelpers
include Precious::Views::SprocketsHelpers
include Precious::Views::RouteHelpers
include Precious::Views::OcticonHelpers
alias_method :h, :escape_html
attr_reader :name, :path
@@ -31,7 +32,23 @@ module Precious
end
def custom_path
"#{@base_url}"
@base_url
end
def custom_css
clean_url(custom_path, "custom.css")
end
def custom_js
clean_url(custom_path, "custom.js")
end
def mathjax_config_path
page_route(@mathjax_config)
end
def mathjax_js
"#{page_route('gollum/assets/mathjax/MathJax.js')}?config=TeX-AMS-MML_HTMLorMML"
end
def css # custom css
+6 -5
View File
@@ -4,6 +4,7 @@ module Precious
module Views
class Overview < Layout
attr_reader :results, :ref, :allow_editing, :newable
HIDDEN_PATHS = ['.gitkeep']
def title
"Overview of #{@ref}"
@@ -25,9 +26,9 @@ module Precious
title = crumb.basename
if title == path.basename
breadcrumb << %{<li class="breadcrumb-item" aria-current="page">#{title}</li>}
breadcrumb << %{<li class="breadcrumb-item" aria-current="page">#{CGI.escapeHTML(title.to_s)}</li>}
else
breadcrumb << %{<li class="breadcrumb-item"><a href="#{overview_path}/#{crumb}/">#{title}</a></li>}
breadcrumb << %{<li class="breadcrumb-item"><a href="#{overview_path}/#{crumb}/">#{CGI.escapeHTML(title.to_s)}</a></li>}
end
end
breadcrumb << %{</ol></nav>}
@@ -51,9 +52,9 @@ module Precious
folder_path = @path ? "#{@path}/#{folder_name}" : folder_name
folder_url = "#{overview_path}/#{folder_path}/"
files_and_folders << {name: folder_name, icon: rocticon('file-directory'), type: 'dir', url: folder_url, is_file: false}
elsif result_path != '.gitkeep'
file_url = "#{@base_url}/#{result.escaped_url_path}"
files_and_folders << {name: result.filename, icon: rocticon('file'), type: 'file', url: file_url, is_file: true}
elsif !HIDDEN_PATHS.include?(result_path)
file_url = page_route(result.escaped_url_path)
files_and_folders << {name: result.filename, icon: rocticon('file'), type: 'file', url: file_url, file_path: result.escaped_url_path, is_file: true}
end
end
# 1012: Overview should list folders first, followed by files and pages sorted alphabetically
+19 -19
View File
@@ -2,9 +2,10 @@ module Precious
module Views
class Page < Layout
include HasPage
include HasMath
attr_reader :content, :page, :header, :footer, :preview, :historical
VALID_COUNTER_STYLES = ['decimal', 'decimal-leading-zero', 'arabic-indic', 'armenian', 'upper-armenian',
'lower-armenian', 'bengali', 'cambodian', 'khmer', 'cjk-decimal', 'devanagari', 'georgian', 'gujarati', 'gurmukhi',
'hebrew', 'kannada', 'lao', 'malayalam', 'mongolian', 'myanmar', 'oriya', 'persian', 'lower-roman', 'upper-roman',
@@ -24,7 +25,7 @@ module Precious
def page_header
title
end
def breadcrumb
path = Pathname.new(@page.url_path).parent
return '' if path.to_s == '.'
@@ -32,7 +33,7 @@ module Precious
path.descend do |crumb|
element = "#{crumb.basename}"
next if element == @page.title
breadcrumb << %{<li class="breadcrumb-item"><a href="#{overview_path}/#{crumb}/">#{element}</a></li>}
breadcrumb << %{<li class="breadcrumb-item"><a href="#{overview_path}/#{crumb}/">#{CGI.escapeHTML(element.to_s)}</a></li>}
end
breadcrumb << %{</ol></nav>}
breadcrumb.join("\n")
@@ -61,11 +62,11 @@ module Precious
def editable
@editable
end
def search
true
end
def history
true
end
@@ -73,11 +74,11 @@ module Precious
def latest_changes
true
end
def overview
true
true
end
def allow_editing
@allow_editing
end
@@ -123,7 +124,11 @@ module Precious
def bar_side
@bar_side.to_s
end
def body_side
@bar_side == :right ? "left" : "right"
end
def left_bar
@bar_side == :left
end
@@ -153,14 +158,6 @@ module Precious
@toc_content
end
def mathjax
@mathjax
end
def mathjax_config
@mathjax_config
end
def use_identicon
@page.wiki.user_icons == 'identicon'
end
@@ -169,12 +166,16 @@ module Precious
@navbar
end
def full_url_path
page_route(@page.escaped_url_path)
end
# Access to embedded metadata.
#
# Returns Hash.
def metadata
@page.metadata
end
end
# Access to embedded metadata.
#
@@ -260,7 +261,6 @@ module Precious
end
result << "</tr>\n</table>\n"
end
end
end
end
+2 -1
View File
@@ -5,7 +5,7 @@ module Precious
include Pagination
def results
@results.sort do |a, b|
sorted = @results.sort do |a, b|
if b.nil?
b_filename_count = 0
b_count = 0
@@ -15,6 +15,7 @@ module Precious
end
[a[:filename_count], a[:count]] <=> [b_filename_count, b_count]
end.reverse.slice((@page_num - 1) * @max_count, @max_count)
sorted.each {|x| x[:href] = page_route(x[:name])}
end
def query_string
+36
View File
@@ -0,0 +1,36 @@
module Precious
module Views
module TemplateCascade
def template_priority_path
@@template_priority_path
end
def template_priority_path=(path)
@@template_priority_path = File.expand_path(path)
@template = nil
end
def first_path_available(name)
priority = File.join(template_priority_path, "#{name}.#{template_extension}")
default = File.join(template_path, "#{name}.#{template_extension}")
File.exists?(priority) ? priority : default
end
# Method should track lib/mustache/settings.rb from Mustache project.
def template_file
@template_file || first_path_available(template_name)
end
# Method should track lib/mustache.rb from Mustache project.
def partial(name)
path = first_path_available(name)
begin
File.read(path)
rescue
raise if raise_on_context_miss?
""
end
end
end
end
end
+1
View File
@@ -10,3 +10,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc
563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence <charles@charlespence.net> 1363478075 -0400 push
874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe <techwiz96@gmail.com> 1421012322 -0500 push
7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto <dawa.ometto@phil.uu.nl> 1492034760 +0200 push
f803c64d11407b23797325e3843f3f378b78f611 181c757cca395d4da18701d069a6b8123e88e040 ViChyavIn <nikita.vyach.ivanov@gmail.com> 1609841455 +0500 push
@@ -10,3 +10,4 @@ cfea406f5f77afc7fb673a43e97721234385b1bd 629aa678272b017a4d136d35e77ac94d80b08dc
563cc3701db990caf63e4ce9c3697a062890ca48 874f597a5659b4c3b153674ea04e406ff393975e Charles Pence <charles@charlespence.net> 1363478075 -0400 push
874f597a5659b4c3b153674ea04e406ff393975e 7bdfe65face6f7cf9877d8c1d8c1dd974a63745e Nathan Lowe <techwiz96@gmail.com> 1421012322 -0500 push
7bdfe65face6f7cf9877d8c1d8c1dd974a63745e f803c64d11407b23797325e3843f3f378b78f611 Dawa Ometto <dawa.ometto@phil.uu.nl> 1492034760 +0200 push
f803c64d11407b23797325e3843f3f378b78f611 181c757cca395d4da18701d069a6b8123e88e040 ViChyavIn <nikita.vyach.ivanov@gmail.com> 1609841455 +0500 push
+1 -1
View File
@@ -1 +1 @@
f803c64d11407b23797325e3843f3f378b78f611
181c757cca395d4da18701d069a6b8123e88e040
@@ -0,0 +1,8 @@
<nav>
<div style="background-color: red;">NAVBAR_OVERRIDE</div>
<p>Still include an original partial to ensure the fallback works even when nested from an overriden partial:</p>
<div>
{{>mobilenav}}
</div>
</nav>
@@ -0,0 +1,12 @@
<div id="wiki-wrapper" class="page">
<p>Include an overridden partial:</p>
<div id="head">
{{#navbar?}}{{>navbar}}{{/navbar?}}
</div>
<div style="background-color: red;">PAGE_OVERRIDE</div>
{{>wiki_content}}
</div>
+134
View File
@@ -0,0 +1,134 @@
require_relative "../../helper"
require_relative "../../../lib/gollum/views/helpers"
describe Precious::Views::LocaleHelpers do
class TestClass < Mustache
include Precious::Views::LocaleHelpers
def author
"J.R.R."
end
def location
"Bloemfontein"
end
end
def setup
::I18n.available_locales = [:en, :de]
::I18n.load_path = Dir[File.expand_path("test/support/locales" + "/*.yml")]
end
def teardown
I18n.locale = :en
end
let(:dummy_instance) { TestClass.new }
describe "#t" do
describe "mustache usage" do
let(:subject) { dummy_instance.render(mustache_template) }
let(:mustache_template) { "{{ t.hello_world }}" }
describe "in the default locale" do
it "returns the translation string" do
_(subject).must_equal "Hello world"
end
end
describe "in the configured locale" do
it "returns the translation string" do
I18n.locale = :de
_(subject).must_equal "Hallo Welt"
end
end
describe "translations with YAML arguments" do
let(:mustache_template) { "{{ t.author_info.full }}" }
describe "in the default locale" do
it "autofills YAML arguments" do
_(subject).must_equal "Author J.R.R. is from Bloemfontein"
end
end
describe "in the configured locale" do
it "autofills YAML arguments" do
I18n.locale = :de
_(subject).must_equal "Autor J.R.R. ist vom Bloemfontein"
end
end
end
describe "translations with invalid arguments" do
let(:mustache_template) { "{{ t.has_invalid_argument }}" }
it "fails gracefully with embedded error message" do
expected_string = "Welcome to " \
"[#{TestClass::NO_METHOD_MESSAGE}: no_matching_method]"
_(subject).must_equal expected_string
end
end
describe "out of scope translations" do
let(:mustache_template) { "{{ t.never_called }}" }
it "does not include translation keys from other classes" do
_(subject).must_be_empty
end
end
describe "missing translations" do
let(:mustache_template) { "{{ t.nested.nonexistent_key }}" }
it "outputs an empty string" do
_(subject).must_be_empty
end
end
end
describe "usage" do
let(:subject) { dummy_instance.t }
it "returns a hash" do
_(subject).must_be_kind_of Hash
end
it "returns translation keys under 'test_class'" do
i18n_keys = I18n.t("test_class").keys
_(subject.keys).must_equal i18n_keys
end
it "does not return translation keys under other classes" do
other_i18n_keys = I18n.t("nonexistant_test_class").keys
_(subject.keys).wont_include other_i18n_keys
end
it "returns nested keys" do
nested_keys = subject[:author_info].keys
_(nested_keys).must_equal [:full]
end
describe "auto-filled YAML arguments" do
let(:subject) { dummy_instance.t[:author_info][:full] }
it "auto-fills in the default locale" do
_(subject).must_equal "Author J.R.R. is from Bloemfontein"
end
it "auto-fills in a configured locale" do
I18n.locale = :de
_(subject).must_equal "Autor J.R.R. ist vom Bloemfontein"
end
end
end
end
end
+2 -2
View File
@@ -5,7 +5,7 @@ require 'shoulda'
require 'mocha/setup'
require 'fileutils'
require 'minitest/reporters'
require 'twitter_cldr'
require 'minitest/spec'
require 'tmpdir'
# Silence locale validation warning
@@ -93,4 +93,4 @@ def context(*args, &block)
klass.class_eval &block
end
$contexts = []
$contexts = []
+8
View File
@@ -0,0 +1,8 @@
de:
test_class:
author_info:
full: Autor %{author} ist vom %{location}
has_invalid_argument: Willkommen in %{no_matching_method}
hello_world: Hallo Welt
nonexistant_test_class:
never_called: Nie angerufen
+8
View File
@@ -0,0 +1,8 @@
en:
test_class:
author_info:
full: Author %{author} is from %{location}
has_invalid_argument: Welcome to %{no_matching_method}
hello_world: Hello world
nonexistant_test_class:
never_called: Never called
+118 -26
View File
@@ -39,31 +39,29 @@ context "Frontend" do
assert_match /<pre><code>one\ntwo\nthree\nfour\n<\/code><\/pre>\n/m, last_response.body
end
def nfd utf8
TwitterCldr::Normalization.normalize(utf8, using: :nfd)
end
test 'mathjax assets are served' do
get '/gollum/assets/mathjax/MathJax.js'
assert last_response.ok?
end
test "UTF-8 headers href preserved" do
page = 'utfh1'
text = nfd('한글')
page_content = <<~TEXT
## 한글
# don't use h1 or it will be promoted to replace file name
# which doesn't generate a normal header link
@wiki.write_page(page, :markdown, '## ' + text,
{ :name => 'user1', :email => 'user1' });
Test page "utfh1" content.
TEXT
get page
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?#{text}\" (href|id)=\"(#)?#{text}\"></a>#{text}</h2>"
actual = nfd(last_response.body)
@wiki.write_page('utfh1',
:markdown,
page_content,
{name: 'user1', email: 'user1'})
assert_match /#{expected}/, actual
get 'utfh1'
expected = "<h2 class=\"editable\"><a class=\"anchor\" (href|id)=\"(#)?한글\" (href|id)=\"(#)?한글\"></a>한글</h2>"
assert_match /#{expected}/, last_response.body
end
test 'rss feed' do
channel_title = <<EOF
<title>Gollum Wiki Latest Changes</title>
@@ -328,7 +326,7 @@ EOF
test "create with template succeed if template exists" do
Precious::App.set(:wiki_options, { :template_page => true })
page='_Template'
post '/gollum/create', :content => 'fake template', :page => page,
post '/gollum/create', :content => 'fake template with some Utf-8: Ü', :page => page,
:path => '/', :format => 'markdown', :message => ''
follow_redirect!
assert last_response.ok?
@@ -447,6 +445,21 @@ EOF
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
end
test "upload a file with https referer" do
temp_upload_file = Tempfile.new(['https_upload', '.file']) << 'abc'
temp_upload_file.close
Precious::App.set(:wiki_options, {allow_uploads: true, per_page_uploads: true})
post "/gollum/upload_file", {:file => Rack::Test::UploadedFile.new(::File.open(temp_upload_file))}, {'HTTP_REFERER' => 'https://localhost:4567/Home.md', 'HTTP_HOST' => 'localhost:4567'}
assert_equal 302, last_response.status # redirect is expected
@wiki.clear_cache
# Find the file in a page-specific subdir (here: Home), based on referer
file = @wiki.file("uploads/Home/#{::File.basename(temp_upload_file.path)}")
assert_equal 'abc', file.raw_data
Precious::App.set(:wiki_options, {allow_uploads: false, per_page_uploads: false})
end
test "guard against uploading an existing file" do
temp_upload_file = Tempfile.new(['upload', '.file']) << 'abc'
temp_upload_file.close
@@ -474,19 +487,10 @@ EOF
end
test "previews content" do
post "/gollum/preview", :content => 'abc', :format => 'markdown', :page => 'Samewise%20Gamgee.mediawiki'
post "/gollum/preview", :content => 'abc', :format => 'markdown', :page => 'Samewise Gamgee.mediawiki'
assert last_response.ok?
assert last_response.body.include?('Samewise Gamgee</h1>')
end
test "previews content on the first page of an empty wiki" do
@path = cloned_testpath("examples/empty.git")
@wiki = Gollum::Wiki.new(@path)
Precious::App.set(:gollum_path, @path)
Precious::App.set(:wiki_options, {})
post "/gollum/preview", :content => 'abc', :format => 'markdown'
assert last_response.ok?
end
test 'throws an error when comparing two identical revisions for a page' do
get '/gollum/compare/A.md/fc66539528eb96f21b2bbdbf557788fe8a1196ac...fc66539528eb96f21b2bbdbf557788fe8a1196ac'
@@ -656,6 +660,14 @@ EOF
assert_match /meta name="robots" content="noindex, nofollow"/, last_response.body
end
test 'history/NO-EXIST redirects to Home' do
get '/gollum/history/NO-EXIST'
follow_redirect!
assert_equal last_request.fullpath, '/'
# redirect again from / to /Home
assert_equal last_response.status, 302
end
def app
Precious::App
end
@@ -898,3 +910,83 @@ context "Frontend with page-file-dir" do
Precious::App
end
end
context "Frontend with empty repo" do
include Rack::Test::Methods
setup do
@path = cloned_testpath("examples/empty.git")
@wiki = Gollum::Wiki.new(@path)
Precious::App.set(:gollum_path, @path)
Precious::App.set(:wiki_options, {allow_editing: true})
end
teardown do
FileUtils.rm_rf(@path)
end
def app
Precious::App
end
test 'previews content on the first page of an empty wiki' do
post '/gollum/preview', :content => 'abc', :format => 'markdown'
assert last_response.ok?
end
test 'wiki redirects to create page with newly initialized repo' do
get '/Home'
follow_redirect!
assert_equal '/gollum/create/Home', last_request.fullpath
assert last_response.ok?
end
end
context 'Frontend with base path' do
include Rack::Test::Methods
setup do
@path = cloned_testpath("examples/lotr.git")
@wiki = Gollum::Wiki.new(@path)
@base_path = 'wiki'
Precious::App.set(:gollum_path, @path)
Precious::App.set(:wiki_options, {base_path: @base_path, mathjax: true})
end
teardown do
FileUtils.rm_rf(@path)
end
test 'page with base path' do
get '/wiki/Home'
assert last_response.ok?
end
test 'base path mathjax assets' do
get '/wiki/Home'
assert last_response.ok?
assert last_response.body.include?('<script defer src="/wiki/gollum/assets/mathjax/MathJax.js?config=')
end
test 'compare view' do
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d&versions[]=5bc1aaec6149e854078f1d0f8b71933bbc6c2e43'
follow_redirect!
assert last_response.ok?
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/5bc1aaec6149e854078f1d0f8b71933bbc6c2e43...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
get '/wiki/gollum/compare/Bilbo-Baggins.md?versions[]=f25eccd98e9b667f9e22946f3e2f945378b8a72d'
follow_redirect!
assert last_response.ok?
assert_equal '/wiki/gollum/compare/Bilbo-Baggins.md/b0d108328459e44fff4a76cd19b10ddc34adce4b...f25eccd98e9b667f9e22946f3e2f945378b8a72d', last_request.fullpath
get '/wiki/gollum/compare/Bilbo-Baggins.md'
follow_redirect!
assert last_response.ok?
assert_equal '/wiki/gollum/history/Bilbo-Baggins.md', last_request.fullpath
end
def app
Precious::MapGollum.new(@base_path)
end
end
+59
View File
@@ -0,0 +1,59 @@
# ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
require File.expand_path '../../lib/gollum/views/commit', __FILE__
def get_commit_diff(sha1)
commit = @wiki.repo.commit(sha1)
@wiki.repo.diff(commit.parent.id, sha1)
end
context "Precious::Views::Compare" do
setup do
@path = cloned_testpath('examples/lotr.git')
# Precious::App.set(:gollum_path, @path)
@wiki = Gollum::Wiki.new(@path)
end
test 'rename diff' do
# JGit returns differenly formatted diffs for rename commits. Support both kinds of diff.
jgit_diff = "diff --git a/Foo.md b/Bar.md\nsimilarity index 100%\nrename from Foo.md\nrename to Bar.md"
rugged_diff = "diff --git a/Bar.md b/Bar.md\nnew file mode 100644\nindex 0000000..e69de29\n--- /dev/null\n+++ b/Bar.md\n"
[jgit_diff, rugged_diff].each do |diff|
view = Precious::Views::Compare.new
view.instance_variable_set(:@diff, diff)
assert_equal [], view.lines
end
end
test 'file addition diff' do
view = Precious::Views::Compare.new
diff = get_commit_diff 'fbabba862dfa7ac35b39042dd4ad780c9f67b8cb'
view.instance_variable_set(:@diff, diff)
assert_equal [
{:line=>"@@ -0,0 +1 @@", :class=>"gc", :ldln=>"...", :rdln=>"..."},
{:line=>"+# Eye Of Sauron", :class=>"gi", :ldln=>" ", :rdln=>"1"}
], view.lines
end
test 'empty file addition diff' do
view = Precious::Views::Compare.new
diff = get_commit_diff '181c757cca395d4da18701d069a6b8123e88e040'
view.instance_variable_set(:@diff, diff)
assert_equal [], view.lines
end
test 'binary file addition diff' do
view = Precious::Views::Compare.new
diff = get_commit_diff 'afe2034d400ba21e13361f38f74900c51dbc7fde'
view.instance_variable_set(:@diff, diff)
lines = view.lines
line = lines[0].delete :line
assert_match %r{Binary files (/dev/null and b/Mordor/eye.jpg )?differ}, line
assert_equal [{:class=>"gg", :ldln=>"...", :rdln=>"..."}], lines
end
end
+4 -2
View File
@@ -35,9 +35,11 @@ context 'Precious::Views::LatestChanges' do
get(@url)
body = last_response.body
commits_list_elements = body.scan(%r{<li class="Box-row Box-row--hover-gray border-top d-flex flex-items-center">})
assert !commits_list_elements.nil?, "the commits should be listed with this tag"
assert commits_list_elements.length == 10, "/latest_changes should include the :pagination_count commit"
assert body.include?("Charles Pence</span>"), "/latest_changes should include Author Charles Pence"
assert body.include?('1db89eb'), "/latest_changes should include the :pagination_count commit"
assert !body.include?('a8ad3c0'), "/latest_changes should not include more than :pagination_count commits"
assert body.include?('<a href="/Data-Two.csv/874f597a5659b4c3b153674ea04e406ff393975e">Data-Two.csv</a>'), "/latest_changes include links to modified files in #{body}"
assert body.include?('<a href="/Hobbit.md/874f597a5659b4c3b153674ea04e406ff393975e">Hobbit.md</a>'), "/latest_changes should include links to modified pages in #{body}"
end
+34 -19
View File
@@ -23,9 +23,28 @@ waa
[[Subsub/Zaa.md]]
EOF
script_path = File.expand_path(File.join(File.dirname(__FILE__), '../', 'bin', 'gollum-migrate-tags'))
def load_script(**args)
settings = {
:run_silent => true,
:no_dry_run => true,
:prefer_relative => true,
:hyphenate => false,
:page_file_dir => nil,
}.merge(args)
settings.each do |const, val|
const_name = const.to_s.upcase
Object.const_set(const_name, val) unless Object.const_defined?(const_name) && Object.const_get(const_name) == val
end
script_path = File.expand_path(File.join(File.dirname(__FILE__), '../', 'bin', 'gollum-migrate-tags'))
Dir.chdir(@path) do
load script_path
end
end
unless ENV['TRAVIS']
unless ENV['CI']
context '4.x -> 5.x tag migrator' do
include Rack::Test::Methods
@@ -35,33 +54,29 @@ unless ENV['TRAVIS']
end
test 'repair broken links' do
PREFER_RELATIVE = true
RUN_SILENT = true
NO_DRY_RUN = true
HYPHENATE = false
Dir.chdir(@path) do
load script_path
end
load_script
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
assert_equal result, f.read
end
test 'change spaced filenames to hyphenated filenames' do
RUN_SILENT = true
NO_DRY_RUN = true
PREFER_RELATIVE = true
HYPHENATE = true
Dir.chdir(@path) do
load script_path
end
test 'change spaced filenames to hyphenated filenames' do
load_script(hyphenate: true)
f = ::File.new(::File.join(@path, 'Home.textile'), 'r')
output = f.read
assert_equal true, output.include?('[[Bilbo-Baggins.md]]')
assert_equal true, output.include?('[[evil|Mordor/Eye-Of-Sauron.md]]')
end
test 'migration with page file dir' do
load_script(page_file_dir: 'Subdir')
f = ::File.new(::File.join(@path, 'Subdir/Foo.md'), 'r')
output = f.read
assert_equal true, output.include?('[[Subsub/Zaa.md]]')
assert_equal true, output.include?('[[Samwi]]')
end
teardown do
FileUtils.rm_rf(@path)
+30
View File
@@ -44,6 +44,23 @@ context "Precious::Views::Overview" do
assert_equal "<nav aria-label=\"Breadcrumb\"><ol><li class=\"breadcrumb-item\"><a href=\"/gollum/overview\">Home</a></li>\n<li class=\"breadcrumb-item\"><a href=\"/gollum/overview/Mordor/\">Mordor</a></li>\n<li class=\"breadcrumb-item\"><a href=\"/gollum/overview/Mordor/Eye-Of-Sauron/\">Eye-Of-Sauron</a></li>\n<li class=\"breadcrumb-item\" aria-current=\"page\">Saruman</li>\n</ol></nav>", @page.breadcrumb
end
test "breadcrumbs guard against malicious filenames" do
malicious_path = '<script>alert("malicious-content");/Very Bad'
@page.instance_variable_set("@path", malicious_path)
@page.instance_variable_set("@base_url", "")
refute_includes @page.breadcrumb, malicious_path
assert_includes @page.breadcrumb, ">&lt;script&gt;alert(&quot;malicious-content&quot;);</a>"
end
test "breadcrumbs retain unicode and ASCII characters" do
title = "数学 📘"
@page.instance_variable_set("@path", title)
@page.instance_variable_set("@base_url", "")
assert_includes @page.breadcrumb, title
end
test "breadcrumb with no path" do
assert_equal 'Home', @page.breadcrumb
end
@@ -72,6 +89,17 @@ context "Precious::Views::Overview" do
assert_equal result[:name], 'Orc'
end
test "files_folders retain unicode and ASCII characters" do
@page.instance_variable_set("@path", "Mordor")
@page.instance_variable_set("@base_url", "")
@page.instance_variable_set("@results", [
FakePageResult.new("Mordor/Eye-Of-Sauron-👁️-数学.md")
])
result = @page.files_folders.first
assert result[:name], "Eye Of Sauron 👁️ 数学"
end
test "base url" do
# based on test "files_folders"
@page.instance_variable_set("@path", "Mordor")
@@ -79,5 +107,7 @@ context "Precious::Views::Overview" do
results = [FakePageResult.new("Mordor/Eye-Of-Sauron.md"), FakeFileResult.new("Mordor/Aragorn.pdf"), FakePageResult.new("Mordor/Orc/Saruman.md"), FakePageResult.new("Mordor/.gitkeep")]
@page.instance_variable_set("@results", results)
assert_equal @page.files_folders.first[:url], '/wiki/gollum/overview/Mordor/Orc/'
assert_equal @page.files_folders.last[:url], '/wiki/Mordor/Eye-Of-Sauron'
assert_equal @page.files_folders.last[:file_path], 'Mordor/Eye-Of-Sauron'
end
end
+115 -17
View File
@@ -13,6 +13,67 @@ context "Precious::Views::Page" do
FileUtils.rm_rf(@path)
end
test "breadcrumbs guard against malicious input" do
malicious_path = '<script>alert("malicious-content");/Very Bad'
@wiki.write_page(malicious_path, :markdown, 'Is Bilbo a hobbit? Why certainly!')
page = @wiki.page(malicious_path)
@view = Precious::Views::Page.new
@view.instance_variable_set :@page, page
@view.instance_variable_set :@content, page.formatted_data
@view.instance_variable_set :@h1_title, false
refute_includes @view.breadcrumb, malicious_path
assert_includes @view.breadcrumb, ">&lt;script&gt;alert(&quot;malicious-content&quot;);</a>"
end
test "breadcrumbs retain unicode and ASCII characters" do
path = "数学 📘/Age of Bilbo"
@wiki.write_page(path, :markdown, "How old is Bilbo?")
page = @wiki.page(path)
@view = Precious::Views::Page.new
@view.instance_variable_set :@page, page
@view.instance_variable_set :@content, page.formatted_data
@view.instance_variable_set :@h1_title, false
assert_include @view.breadcrumb, "数学 📘"
end
test 'page <title> is the page header from content, if present' do
page_title = 'Page header from content'
@wiki.write_page(page_title, :markdown, 'Contents', commit_details)
@view = Precious::Views::Page.new.tap do |view|
view.instance_variable_set :@page, @wiki.page(page_title)
view.instance_variable_set :@h1_title, true
end
assert_equal @view.title, 'Page header from content'
end
test 'page <title> is URL path title if no h1 present' do
@wiki.write_page('dir/My path title', :markdown, 'Contents', commit_details)
page = @wiki.page('dir/My path title')
@view = Precious::Views::Page.new.tap do |view|
view.instance_variable_set :@page, page
view.instance_variable_set :@h1_title, false
end
assert_equal @view.title, 'My path title'
end
test "page header retains unicode and ASCII characters" do
title = "数学 📘"
@wiki.write_page(title, :markdown, "How old is Bilbo?")
page = @wiki.page(title)
@view = Precious::Views::Page.new
@view.instance_variable_set :@page, page
@view.instance_variable_set :@content, page.formatted_data
@view.instance_variable_set :@h1_title, false
assert @view.page_header, "数学 📘"
end
test "h1 title sanitizes correctly" do
title = 'H1'
@wiki.write_page(title, :markdown, '# 1 & 2 <script>alert("js")</script>' + "\n # 3", commit_details)
@@ -24,10 +85,46 @@ context "Precious::Views::Page" do
@view.instance_variable_set :@h1_title, true
# Test page_header_from_content(@content)
actual = @view.title
assert_equal '1 & 2', actual
assert @view.page_header, "1 & 2"
end
test "page header uses filename when h1_title is false" do
title = "H1"
contents = <<~TEXT
# First H1 header
# Second H1 header
TEXT
@wiki.write_page(title, :markdown, contents, commit_details)
page = @wiki.page(title)
@view = Precious::Views::Page.new
@view.instance_variable_set :@page, page
@view.instance_variable_set :@content, page.formatted_data
@view.instance_variable_set :@h1_title, false
assert_equal @view.page_header, "H1"
end
test "page header uses filename when h1_title is true" do
contents = <<~TEXT
# First H1 header
# Second H1 header
TEXT
@wiki.write_page("H1", :markdown, contents, commit_details)
page = @wiki.page("H1")
@view = Precious::Views::Page.new
@view.instance_variable_set :@page, page
@view.instance_variable_set :@content, page.formatted_data
@view.instance_variable_set :@h1_title, true
assert_equal @view.page_header, "First H1 header"
end
test "metadata is rendered into a table" do
title = 'metadata test'
@wiki.write_page(title, :markdown, "---\nsome: metadata\nhere: for you\n---\n# Some markdown\nIn this doc")
@@ -93,21 +190,6 @@ EOS
assert_equal "594e928cc5dcb6d833dfb86bb36076fd4a84eea7", @view.id
end
test "h1 title can be disabled" do
title = 'H1'
@wiki.write_page(title, :markdown, '# 1 & 2 <script>alert("js")</script>' + "\n # 3", commit_details)
page = @wiki.page(title)
@view = Precious::Views::Page.new
@view.instance_variable_set :@page, page
@view.instance_variable_set :@content, page.formatted_data
@view.instance_variable_set :@h1_title, false
# Title is based on file name when h1_title is false.
actual = @view.title
assert_equal title, actual
end
test "breadcrumbs" do
@wiki.write_page('subdir/BC Test 1', :markdown, 'Test', commit_details)
page = @wiki.page('subdir/BC Test 1')
@@ -127,4 +209,20 @@ EOS
@view.instance_variable_set :@content, page.formatted_data
assert_equal @view.breadcrumb, ''
end
test "body_side is 'right' by default" do
@view = Precious::Views::Page.new
assert_equal @view.body_side, "right"
end
test "body_side is 'left' if bar_side side is 'right'" do
@view = Precious::Views::Page.new
@view.instance_variable_set :@bar_side, :right
assert_equal @view.body_side, "left"
end
test "links to pages containing ?" do
@view = Precious::Views::Page.new
assert_equal @view.page_route("Page?"), '/Page%3F'
end
end
+43
View File
@@ -0,0 +1,43 @@
# ~*~ encoding: utf-8 ~*~
require File.expand_path(File.join(File.dirname(__FILE__), 'helper'))
class TestTemplateCascade < Minitest::Unit::TestCase
include Rack::Test::Methods
def setup
@path = cloned_testpath('examples/lotr.git')
Precious::App.set(:gollum_path, @path)
Precious::App.set(:wiki_options, {template_dir: testpath('examples/template_cascade')})
@wiki = Gollum::Wiki.new(@path)
end
def teardown
FileUtils.rm_rf(@path)
end
def app
Precious::App
end
def test_overridden_page_template_is_used
get '/Home'
assert last_response.body.include?('PAGE_OVERRIDE')
end
def test_overridden_navbar_partial_is_used
get '/Home'
assert last_response.body.include?('NAVBAR_OVERRIDE')
end
def test_overridden_templates_are_ignore_without_template_dir_set
Precious::App.set(:wiki_options, {template_dir: nil})
get '/Home'
assert_equal '/Home', last_request.fullpath
assert last_response.ok?
assert_no_match /PAGE_OVERRIDE/, last_response.body
assert_no_match /NAVBAR_OVERRIDE/, last_response.body
end
end