summaryrefslogtreecommitdiff
path: root/lib/banzai
Commit message (Collapse)AuthorAgeFilesLines
* Removed puts code :see_no_evil:code-blocks-vue-prePhil Hughes2016-10-041-1/+0
|
* Adds v-pre to code blocks in commentsPhil Hughes2016-10-042-2/+3
| | | | Closes #22911
* Replace talk_list patch with a patched forkJared Deckard2016-09-301-22/+0
|
* Use `Module#prepend` instead of `alias_method_chain`Andre Guedes2016-09-301-5/+7
|
* AbstractReferenceFilter caches current project_ref on RequestStore when active22679-avoid-abstract-reference-filter-project-requestsPaco Guzman2016-09-282-5/+21
| | | | | | Before we weren’t caching current_project_ref because normally the reference to the current project doesn’t include the path with namespace. But now we store the current project in the projects reference cache to be used for the same filter when accessing using path with namespace of for subsequent filters executed on the cache.
* Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes ↵22681-avoid-empty-queries-on-reference-parsersPaco Guzman2016-09-281-1/+5
| | | | without references
* Fix the leak mentioned in 504a3b5 by another wayAhmad Sherif2016-09-231-29/+31
| | | | | | | | The previous fix introduced another leak; as it made Banzai::Filter::SanitizationFiler#customized? always return false, so we were always appending two elements to HTML::Pipeline::SanitizationFilter::WHITELIST[:elements]. This growth in the elements array would slow the sanitization process over time.
* Revert "Fix a memory leak caused by Banzai::Filter::SanitizationFilter"Ahmad Sherif2016-09-231-3/+1
| | | | This reverts commit 504a3b5e6f0b2e2957cf1e4d9d8eebbf32234bdb.
* Fix URLs with anchors in wikiQingping Hou2016-09-131-0/+1
|
* Merge branch 'js-tooltips-for-mentions' into 'master' Robert Speicher2016-09-016-15/+12
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use JavaScript tooltips for mentions ## What does this MR do? - use JavaScript tooltips instead of plain title for mentions (issue, merge request, snippet, user, group, commit, commit range, milestone) ## Why was this MR needed? JavaScript tooltips look nicer and can wrap. ## What are the relevant issue numbers? https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5261#note_13106713, fixes #21500 See merge request !5301
| * Use JavaScript tooltips for mentions (!5301)winniehell2016-09-016-15/+12
| |
* | remove Ability.abilitieshttp://jneen.net/2016-08-301-1/+1
|/
* Fix a memory leak caused by Banzai::Filter::SanitizationFilterfix/sanitization-filter-leakAhmad Sherif2016-08-141-1/+3
| | | | | | | | | | | | | In Banzai::Filter::SanitizationFilter#customize_whitelist, we append three lambdas that has reference to the SanitizationFilter instance, which in turn (potentially) has a reference to the following chain: context hash -> Project instance -> Repository instance -> lookup hash -> various Rugged instances -> various mmap-ed git pack files. All of the above is not garbage collected because the array we append the lambdas to is the constant HTML::Pipeline::SanitizationFilter::WHITELIST.
* Merge branch 'relative-link-filter-ref' into 'master' Robert Speicher2016-08-091-3/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not look up commit again when it is passed to RelativeLinkFilter ## What does this MR do? Use `context[:commit]` in RelativeLinkFilter instead of looking up commit using `context[:ref]`. ## Why was this MR needed? Even though the commit object was already passed, unnecessary I/O is done to retrieve the commit object. ## What are the relevant issue numbers? Fixes #20026 See merge request !5455
| * Do not look up commit again when it is passed to RelativeLinkFilter (!5455)winniehell2016-08-021-3/+3
| |
* | Enable Style/EmptyLinesAroundClassBody coprubocop/EmptyLinesAroundModuleBodyGabriel Mazetto2016-08-061-1/+0
| |
* | Enable Style/EmptyLinesAroundModuleBody copGabriel Mazetto2016-08-061-2/+0
| |
* | Ignore URLs starting with // (!5677)winniehell2016-08-051-1/+2
| |
* | Merge branch 'syntax-highlight-filter-performance' into 'master' Rémy Coutable2016-08-041-8/+18
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve performance of SyntaxHighlightFilter ## What does this MR do? This MR improves the performance of `Banzai::Filter::SyntaxHighlightFilter`. See e9bacc6575d0002c6cab620075dea3dc7f93f100 for more information. ## Are there points in the code the reviewer needs to double check? Styling mostly. ## Why was this MR needed? Syntax highlighting is rather slow. ## What are the relevant issue numbers? #18592 ## 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)~~ - [x] ~~API support added~~ - Tests - [x] ~~Added for this feature/bug~~ - [ ] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [ ] 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 !5643
| * | Improve performance of SyntaxHighlightFiltersyntax-highlight-filter-performanceYorick Peterse2016-08-031-8/+18
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By using Rouge::Lexer.find instead of find_fancy() and memoizing the HTML formatter we can speed up the highlighting process by between 1.7 and 1.8 times (at least when measured using synthetic benchmarks). To measure this I used the following benchmark: require 'benchmark/ips' input = '' Dir['./app/controllers/**/*.rb'].each do |controller| input << <<-EOF <pre><code class="ruby">#{File.read(controller).strip}</code></pre> EOF end document = Nokogiri::HTML.fragment(input) filter = Banzai::Filter::SyntaxHighlightFilter.new(document) puts "Input size: #{(input.bytesize.to_f / 1024).round(2)} KB" Benchmark.ips do |bench| bench.report 'call' do filter.call end end This benchmark produces 250 KB of input. Before these changes the timing output would be as follows: Calculating ------------------------------------- call 1.000 i/100ms ------------------------------------------------- call 22.439 (±35.7%) i/s - 93.000 After these changes the output instead is as follows: Calculating ------------------------------------- call 1.000 i/100ms ------------------------------------------------- call 41.283 (±38.8%) i/s - 148.000 Note that due to the fairly high standard deviation and this being a synthetic benchmark it's entirely possible the real-world improvements are smaller.
* | Improve AutolinkFilter#text_parse performanceautolink-filter-text-parseYorick Peterse2016-08-031-6/+9
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By using clever XPath queries we can quite significantly improve the performance of this method. The actual improvement depends a bit on the amount of links used but in my tests the new implementation is usually around 8 times faster than the old one. This was measured using the following benchmark: require 'benchmark/ips' text = '<p>' + Note.select("string_agg(note, '') AS note").limit(50).take[:note] + '</p>' document = Nokogiri::HTML.fragment(text) filter = Banzai::Filter::AutolinkFilter.new(document, autolink: true) puts "Input size: #{(text.bytesize.to_f / 1024 / 1024).round(2)} MB" filter.rinku_parse Benchmark.ips(time: 15) do |bench| bench.report 'text_parse' do filter.text_parse end bench.report 'text_parse_fast' do filter.text_parse_fast end bench.compare! end Here the "text_parse_fast" method is the new implementation and "text_parse" the old one. The input size was around 180 MB. Running this benchmark outputs the following: Input size: 181.16 MB Calculating ------------------------------------- text_parse 1.000 i/100ms text_parse_fast 9.000 i/100ms ------------------------------------------------- text_parse 13.021 (±15.4%) i/s - 188.000 text_parse_fast 112.741 (± 3.5%) i/s - 1.692k Comparison: text_parse_fast: 112.7 i/s text_parse: 13.0 i/s - 8.66x slower Again the production timings may (and most likely will) vary depending on the input being processed.
* Add support for relative links starting with ./ or / to RelativeLinkFilter ↵winniehell2016-08-021-0/+3
| | | | (!5586)
* Merge branch 'ability-batch-issue-checking' into 'master' Robert Speicher2016-07-291-3/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optimize checking if a user can read multiple issues ## What does this MR do? This optimizes various parts of the code so it can more efficiently check if a user can read a list of issues. ## Are there points in the code the reviewer needs to double check? Yes, in particular `Ability.issues_readable_by_user` should be checked to make sure it correctly allows/restricts access to issues. ## Why was this MR needed? Currently the general approach to checking if one can read an issue is to iterate over the issues to check and call `can?(user, :read_issue, issue)` for every issue. This is not efficient as the same work has to be done for every issue. ## What are the relevant issue numbers? * #15607 * #17463 See merge request !5370
| * 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.
* | Merge branch 'rubocop/enable-access-modifiers-cops' into 'master' Robert Speicher2016-07-293-19/+21
|\ \ | |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable Rubocop cops that check access modifiers ## What does this MR do? This MR enables Rubocop cops that detect methods that should be restricted but are the part of public API because of access modifiers used improperly. This also fixes existing offenses. ## Why was this MR needed? Some method in our codebase are public instead of being private because it is sometimes difficult to get it right without static analysis. ## What are the relevant issue numbers? See #17478 Closes #17372 See merge request !5014
| * Fix method visiblity in emoji filter classGrzegorz Bizon2016-07-191-5/+5
| |
| * Fix methods visibility in markdown filter classGrzegorz Bizon2016-07-191-7/+7
| |
| * Make banzai module that handles markdown singletonGrzegorz Bizon2016-07-191-7/+9
| |
* | 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