summaryrefslogtreecommitdiff
path: root/lib/banzai
Commit message (Collapse)AuthorAgeFilesLines
* Method for returning issues readable by a userability-batch-issue-checkingYorick Peterse2016-07-291-3/+4
| | | | | | | | | | | | | The method Ability.issues_readable_by_user takes a list of users and an optional user and returns an Array of issues readable by said user. This method in turn is used by Banzai::ReferenceParser::IssueParser#nodes_visible_to_user so this method no longer needs to get all the available abilities just to check if a user has the "read_issue" ability. To test this I benchmarked an issue with 222 comments on my development environment. Using these changes the time spent in nodes_visible_to_user was reduced from around 120 ms to around 40 ms.
* Ensure relative paths for video are rewritten as we do for images20189-markdown-video-doesn-t-work-when-the-referenced-video-file-is-in-same-repoRémy Coutable2016-07-261-1/+1
| | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
* Retrieve rendered HTML from cache in one requestfix/get-cached-rendered-html-using-single-redis-requestAhmad Sherif2016-07-211-4/+5
| | | | See #19985
* Merge branch '4142-show-inline-video' into 'master' Rémy Coutable2016-07-212-0/+60
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for inline videos in issue, MR and notes (on issue, commit, MR, and MR diff) ## What does this MR do? It adds support for inline videos in issue, MR and notes (on issue, commit, MR, and MR diff). Most of the work was done by @hayesr in !3508 but a few improvements were still missing. ## Why was this MR needed? To be able to play uploaded videos in GitLab! ## What are the relevant issue numbers? Closes #4142. ## Screenshots ### Video players ![Screen_Shot_2016-07-19_at_18.44.09](/uploads/e85e531b455a41c3e66b26b356abaafd/Screen_Shot_2016-07-19_at_18.44.09.png) ----- ![Screen_Shot_2016-07-19_at_18.44.29](/uploads/05f52a812760210d1eae86a7f8fc48bc/Screen_Shot_2016-07-19_at_18.44.29.png) ----- ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md) - Tests - [x] Test `VideoLinkFilter` - [x] Test in `spec/features/markdown_spec.rb` - [x] Improve `spec/uploaders/file_uploader_spec.rb` - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5215
| * Remove VideoJS and clean the integrationRémy Coutable2016-07-201-9/+6
| | | | | | | | | | | | | | | | | | Handle videos in: - MD preview in notes: commit, issue/MR, MR diff - New notes in: commit, issue/MR, MR diff - Persisted notes in: commit, issue/MR, MR diff Signed-off-by: Rémy Coutable <remy@rymai.me>
| * Use a more powerful query to match videos in img tagsRémy Coutable2016-07-192-10/+35
| | | | | | | | | | | | | | | | Also, always add a link to download videos since video playback is tricky. Also, it solves the issue with email client not supporting videos. Signed-off-by: Rémy Coutable <remy@rymai.me>
| * Remove duplication, useless rescue, and avoid using ActionViewRémy Coutable2016-07-191-14/+9
| | | | | | | | Signed-off-by: Rémy Coutable <remy@rymai.me>
| * First support of videos in issues, MRs and notesEric Hayes2016-07-192-0/+43
| | | | | | | | | | * Registered video MIME types * Currently supporting browser-supported formats with extensions that match the mime type
* | Enable Style/MultilineTernaryOperator rubocop coprubocop/enable-multiline-ternary-operator-copGrzegorz Bizon2016-07-201-2/+1
|/ | | | | | Avoid multi-line ?: (the ternary operator). Use if/unless instead. See #17478
* Don't parse Rinku returned value to DocFragment when it didn't change the ↵18593-avoid-parse_html-when-rinku-didnt-do-anythingPaco Guzman2016-07-181-0/+2
| | | | original html string.
* Merge branch 'syntax-highlight-unknown-language' into 'master' Robert Speicher2016-07-161-7/+8
|\ | | | | | | | | | | | | Don't fail to highlight when Rouge doesn't have a lexer Fixes issue introduced by upgrade to Rouge 2.0 (https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4691) See merge request !5291
| * Don't fail to highlight when Rouge doesn't have a lexerDouwe Maan2016-07-151-7/+8
| |
* | Merge branch 'mentioned-user-tooltip' into 'master' Douwe Maan2016-07-151-5/+5
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Display tooltip for mentioned users and groups ## What does this MR do? Display tooltip for mentioned users and groups in Markdown. ## Are there points in the code the reviewer needs to double check? I don't know. ## Why was this MR needed? No tooltips were displayed. ## What are the relevant issue numbers? fixes #17060 ## Screenshots ![user-tooltip](/uploads/501b7d1b2a5e6adcadefbc56b08422ec/user-tooltip.png) ![group-tooltip](/uploads/0152a452f9a1ed9fc86101b242f7e4c2/group-tooltip.png) See merge request !5261
| * Display tooltip for mentioned users and groups (!5261)winniehell2016-07-141-5/+5
| |
* | use %(...) and %[...] in favor of %<...>feature.rouge-20http://jneen.net/2016-07-141-2/+2
| |
* | bugfix: don't error in css_classeshttp://jneen.net/2016-07-141-5/+8
| |
* | without line anchors, this is just the plain HTML formatterhttp://jneen.net/2016-07-141-1/+1
| |
* | kill the :cssclass optionhttp://jneen.net/2016-07-141-2/+1
| |
* | add the wrapping back in for the banzai filterhttp://jneen.net/2016-07-141-1/+5
|/
* ObjectRenderer doesn't crash when no objects to cache with ↵Paco Guzman2016-07-131-4/+10
| | | | Rails.cache.read_multi
* Object renderer read_multi rendered entries from Cacheread-multi-rendered-objectsPaco Guzman2016-07-122-11/+68
|
* Optimize system note visibility checking by hiding notes thatStan Hu2016-07-112-18/+29
| | | | | | | | | | | | | have been fully redacted and contain cross-project references. The previous implementation relied on Note#cross_reference_not_visible_for?, which essentially tries to render all the Markdown references in a system note and only displays the note if the user can see the referring project. But this duplicated the work that Banzai::NotesRenderer was doing already. Instead, for each note we render, we memoize the number of visible user references and use it later if it is available. Improves #19273
* Merge branch 'blockquote-fence-filter' into 'master' Robert Speicher2016-07-102-1/+73
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add blockquote fence syntax to Markdown Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/16564 Before Markdown rendering happens, this will transform this: ``` Let me quote this here email: >>> Dear friend, How are you? Greetings, Me >>> ``` Into this, saving me from having to prefix all of those lines with `>` manually when I copy some multiline text from another medium: ``` Let me quote this here email: > Dear friend, > > How are you? > > Greetings, > > Me ``` See merge request !3954
| * Add more comments to regexDouwe Maan2016-07-101-11/+32
| |
| * Add blockquote fence syntax to MarkdownDouwe Maan2016-07-092-1/+52
| |
* | Re-use queries in reference parsersreuse-queries-in-reference-parsersYorick Peterse2016-07-082-4/+37
|/ | | | | This caches various queries to ensure that multiple reference extraction runs re-use any objects queried in previous runs.
* Use CGI.unescapeHTML rather than doing the gsub with a mapDouglas Barbosa Alexandre2016-07-051-1/+1
|
* Move `unescape_html_entities` from LabelsHelper to Label modelDouglas Barbosa Alexandre2016-07-051-1/+1
|
* Render references for labels that name contains ?, or &Douglas Barbosa Alexandre2016-07-051-2/+6
|
* Merge branch 'update-gemoji' into 'master' Robert Speicher2016-07-051-2/+2
|\ | | | | | | | | | | | | | | | | | | | | Add lib/gitlab/emoji.rb instead of gitlab_emoji gem and upgrade Gemojione - No reason to split it into a separate gem when the gem barely did anything. We can use gemojione directly, making updating gemojione that much easier. Unless there's a particularly good reason we were using the gem? - Fixes the Rake task since it broke after all the AwardEmoji changes. - Update gemojione to 2.6.1. Spring Update changes! http://emojione.com/releases/#2.2.0 See merge request !4919
| * Add emoji.rb in lib/gitlab instead of using the gitlab_emoji gem.update-gemojiConnor Shea2016-06-291-2/+2
| | | | | | | | | | | | | | | | No reason to split it into a separate gem when the gem barely did anything. We can use gemojione directly, making updating gemojione that much easier. Also fix the Rake task and update gemojione to 2.6.1. This adds the EmojiOne Spring update. Changelog: https://github.com/jonathanwiesel/gemojione/blob/master/CHANGELOG.md
* | Enable Style/EmptyLines cop, remove redundant onesrubocop/enable-cops-for-empty-linesGrzegorz Bizon2016-07-013-3/+0
| |
* | Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab18592-syntaxhighlighter-slowPaco Guzman2016-07-011-2/+7
| |
* | Handle external issues in IssueReferenceFilterYorick Peterse2016-06-303-6/+30
|/ | | | | | | | | | | IssueReferenceFilter will end up processing internal issue references when a project uses an external issues tracker while still using internal issue references (in the form of `#\d+`). This commit ensures that these links are rendered as external issue links, regardless of whether the project one currently views uses an internal or external issues tracker. Fixes gitlab-org/gitlab-ce#19036, gitlab-com/performance#16
* Wrap images in divs with Banzai and limit max-height.image-sizingConnor Shea2016-06-271-1/+9
| | | | | | Add max-height to prevent images from displaying larger than the provided screen size. Also fix a failing test and add a new one.
* Support for rendering/redacting multiple documentsYorick Peterse2016-06-245-28/+188
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes the way certain documents are rendered (currently only Notes) and how documents are redacted. Previously both rendering and redacting would run on a per document basis. The result of this was that for every document we'd have to run countless queries just to figure out if we could display a set of links or not. This commit changes things around so that redacting Markdown documents is no longer tied into the html-pipeline Gem. This in turn allows it to redact multiple documents in a single pass, thus reducing the number of queries needed. In turn rendering issue/merge request notes has been adjusted to take advantage of this new setup. Instead of rendering Markdown somewhere deep down in a view the Markdown is rendered and redacted in the controller (taking the current user and all that into account). This has been done in such a way that the "markdown()" helper method can still be used on its own. This particular commit also paves the way for caching rendered HTML on object level. Right now there's an accessor method Note#note_html which is used for setting/getting the rendered HTML. Once we cache HTML on row level we can simply change this field to be a column and call a "save" whenever needed and we're pretty much done.
* Merge branch 'fix-external-issue-links' into 'master' Robert Speicher2016-06-221-3/+7
|\ | | | | | | | | | | | | | | | | | | Handle external issues in IssueReferenceFilter Handling of external issues was broken when I refactored `IssueReferenceFilter` to use fewer SQL queries. Fixes #18827 See merge request !4789
| * Handle external issues in IssueReferenceFilterfix-external-issue-linksYorick Peterse2016-06-211-3/+7
| | | | | | | | | | | | | | | | | | | | | | In the past this class would use Project#get_issue to retrieve an issue by its ID. This method would automatically determine whether to return an Issue or ExternalIssue. This commit changes IssueReferenceFilter to handle external issues again and in a somewhat more explicit manner than before. Fixes gitlab-org/gitlab-ce#18827
* | Merge branch 'remove-banzai-pre-process' into 'master' Robert Speicher2016-06-211-6/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | Move pre_process into render_result This MR moves `Banzai::Renderer.pre_process` into `Banzai::Renderer.render_result`. The `pre_process` method was called even when its output would be ignored. See 11a5a4f359ee57029dbfcc9185fc6b47243ea2aa for more details. See merge request !4830
| * | Move pre_process into render_resultremove-banzai-pre-processYorick Peterse2016-06-211-6/+2
| |/ | | | | | | | | | | | | | | | | | | | | The method Banzai::Renderer.pre_process would always be called, regardless of whether the Markdown to render was already cached or not. In cache the document _was_ cached the output of the pre-processing pipeline was ignored resulting in it doing nothing but wasting CPU cycles. This commit moves Banzai::Renderer.pre_process into Banzai::Renderer.render_result so that it's _only_ used when needed.
* | Optimize Banzai::Filter::RelativeLinkFilterAlejandro Rodríguez2016-06-211-37/+14
|/ | | | | | | | | | | | A lot of git operations were being repeated, for example, to build a url you would ask if the path was a Tree, which would call a recursive routine in Gitlab::Git::Tree#where, then ask if the path was a Blob, which would call a recursive routine at Gitlab::Git::Blob#find, making reference to the same git objects several times. Now we call Rugged::Tree#path, which allows us to determine the type of the path in one pass. Some other minor improvement added, like saving commonly used references instead of calculating them each time.
* Merge branch 'fix-out-of-bounds-markdown-refs' into 'master' Robert Speicher2016-06-181-1/+2
|\ | | | | | | | | | | | | | | | | Fix RangeError exceptions when referring to issues or merge requests outside of max database values When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method that will throw out out-of-bounds values. Closes #18777 See merge request !4777
| * Fix RangeError exceptions when referring to issues or merge requests outside ↵Stan Hu2016-06-181-1/+2
| | | | | | | | | | | | | | | | | | | | of max database values When using #XYZ in Markdown text, if XYZ exceeds the maximum value of a signed 32-bit integer, we get an exception when the Markdown render attempts to run `where(iids: XYZ)`. Introduce a method that will throw out out-of-bounds values. Closes #18777
* | Fix bug in `WikiLinkFilter`.18819-wiki-link-filter-exceptionTimothy Andrew2016-06-181-1/+1
|/ | | | | | | 1. An exception would be raised if the filter was called with an invalid URI. Mainly because we weren't catching the `Addressable` exception. 2. This commit fixes it and adds a spec for the filter.
* Merge branch 'banzai-issue-filter-queries' into 'master' Douwe Maan2016-06-162-3/+79
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reduce SQL query counts in IssueReferenceFilter ## What does this MR do? This MR adds a preparation phase for reference filters that allows them to prepare/create data structures used while iterating over HTML nodes. In this particular case the preparation phase is used for issue references to greatly cut down the amount of queries executed to get projects/issues for Markdown references. ## Are there points in the code the reviewer needs to double check? No. ## Why was this MR needed? Rendering Markdown containing issue references would run at most two queries for every issue reference: one to get the project and one to get the issue from said project. When rendering Markdown with lots of issue references this would result in _a lot_ of queries being executed. ## What are the relevant issue numbers? #18042 See merge request !4410
| * Reduce queries in IssueReferenceFilterbanzai-issue-filter-queriesYorick Peterse2016-06-162-3/+79
| | | | | | | | | | | | | | | | | | This reduces the number of queries executed in IssueReferenceFilter by retrieving the various projects/issues that may be referenced in batches _before_ iterating over all the HTML nodes. A chunk of the logic resides in AbstractReferenceFilter so it can be re-used by other filters in the future.
* | Banzai::Filter::ExternalLinkFilter use XPath18582-banzai-filter-external-link-filterPaco Guzman2016-06-161-11/+2
| |
* | Banzai::Filter::UploadLinkFilter use XPathPaco Guzman2016-06-161-8/+3
| |
* | Eager load project relations in IssueParserYorick Peterse2016-06-151-1/+15
|/ | | | | | | | | | | | | By eager loading these associations we can greatly cut down the number of SQL queries executed when processing documents with lots of references, especially in cases where there are references belonging to the same project. Since these associations are so specific to the reference parsing process and the permissions checking process that follows it I opted to include them directly in IssueParser instead of using something like a scope. Once we have a need for it we can move this code to a scope or method.
* Fix description and GFM pipelines conflictingfix-markdown-specSean McGivern2016-06-131-12/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Consider this command: bundle exec rails r "include GitlabMarkdownHelper puts markdown('<span>this is a span</span>', pipeline: :description) puts markdown('<span>this is a span</span>')" And the same in the opposite order: bundle exec rails r "include GitlabMarkdownHelper puts markdown('<span>this is a span</span>') puts markdown('<span>this is a span</span>', pipeline: :description)" Before this change, they would both output: <p><span>this is a span</span></p> <p>this is a span</p> That's because `span` is added to the list of whitelisted elements in the `SanitizationFilter`, but this method tries not to make the same changes multiple times. Unfortunately, `HTML::Pipeline::SanitizationFilter::LIMITED`, which is used by the `DescriptionPipeline`, uses the same Ruby objects for all of its hash values _except_ `:elements`. That means that whichever of `DescriptionPipeline` and `GfmPipeline` is called first would have `span` in its whitelisted elements, and the second wouldn't. Fix this by creating an entirely separate hash, before either pipeline is invoked.