Commit Graph
83 Commits
Author SHA1 Message Date
Yorick Peterse 935f913165 Instrument Banzai code 2016-04-11 17:43:12 +02:00
Robert Speicher 730625f022 Merge branch 'patch/fix-markdown-preview-wikis' into 'master'
Wiki preview URL converting problem [via Markdown]

Current implementation when rendering the preview, thinks relative links are for project repository files.

We are creating a new preview route that will define correct context data to render for wikis instead.

Fixes #2380, #1184

See merge request !3461
2016-04-07 00:17:21 +00:00
Gabriel Mazetto 1575a95b65 little refactor and improvements on specs 2016-04-06 20:09:15 -03:00
Yorick Peterse 507cbca339 Fix header link rendering when containing numbers
This fixes the problem where Markdown such as:

    ### 31st

Would get rendered as a link tag pointing to issue number 31 inside a
header tag.

See gitlab-org/gitlab-ce#14936 for more information.
2016-04-06 14:24:30 +02:00
Gabriel Mazetto 207b7218aa Ensure correct filter order to validate with our markdown spec 2016-04-06 03:30:56 -03:00
Gabriel Mazetto 22055e1058 Fix a few edited references from WikiLinkFilter and specs 2016-04-06 03:13:46 -03:00
Gabriel Mazetto 61fe0a2397 Fixed WikiPipeline and specs 2016-04-06 03:12:39 -03:00
connorshea b9abf938ed Wrap images in discussions and wikis with a link to the image source using ImageLinkFilter.
Resolves #14411.

See merge request !3464
2016-04-04 19:44:07 -06:00
Yorick Peterse 915fd3f910 Cleaned up caching in AbstractReferenceFilter
Cleaning this up any further is a bit tricky as the caches in question
should only be evaluated if RequestStore is actually enabled.
2016-04-04 11:39:11 +02:00
Yorick Peterse 7f0fd73eeb Cache default_issues_tracker? in Banzai
Every object processed by ExternalIssueReferenceFilter can return a
different Project instance when calling "project". For example, every
note processed will have it's own associated Project. If we were to
cache Project#default_issues_tracker? on Project level this would have
no impact on Markdown rendering timings as the cache would have to be
built for every Project instance without it ever being re-used.

To work around this we cache Project#default_issues_tracker? in
Banzai::Filter::ExternalIssueReferenceFilter using the project's _id_
instead of the whole object. This setup allows re-using of the cached
data even when the Project instances used are different, as long as the
actual project IDs are the same.
2016-04-04 10:44:35 +02:00
Yorick Peterse 9fa94326db Memoize object class titles
For an issue with around 200 notes this cuts down timings by around 150
milliseconds.
2016-04-04 10:44:35 +02:00
Yorick Peterse 8c49eaa937 Cache Banzai class methods returning static data
These methods always return the same data for every class so there's no
point in computing their values on every call.
2016-04-04 10:44:35 +02:00
Yorick Peterse 1411480577 Refactor processing of various Banzai filters
These filters now use a single iteration over all the document nodes
instead of multiple ones. This in turn allows variables to be re-used
(e.g. links only have to be unescaped once). Combined with some other
refactoring this can drastically reduce render timings.
2016-04-04 10:44:35 +02:00
Yorick Peterse 57bde0ce65 Cache Banzai projects/objects using RequestStore
This was originally suggested by @ayufan and modified to be a bit
cleaner and use RequestStore instead of a regular Hash.

By caching the output of the two methods involved the number of queries
is reduced significantly. For example, for an issue with 200 notes (of
which 100 reference a number of merge requests) this cuts down the
amount of queries from around 6300 to around 3300.
2016-04-04 10:44:35 +02:00
Yorick Peterse 84b0ab7766 Added & use Gitlab::Routing for URL helpers
Rails' "url_helpers" method creates an anonymous Module (which a bunch
of methods) on every call. By caching the output of this method in a
dedicated method we can shave off about 10 seconds of loading time for
an issue with around 200 comments.
2016-04-01 11:13:48 +02:00
Gabriel Mazetto 28266d9d61 Added WikiLinkFilter 2016-04-01 00:17:37 -03:00
Gabriel Mazetto 7d56d592cd Fixed Gollum pages link url expansion to render correctly in preview 2016-03-30 15:43:58 -03:00
Robert Speicher 8558483417 Remove redundant requires from Banzai files
We're trying to avoid circular dependency errors.
2016-03-24 13:23:47 -04:00
Grzegorz Bizon 0115ad66d2 Merge branch 'master' into feature/issue-move
* master: (121 commits)
  Dedupe labels in labels selector in Dashboard pages
  Refactor colors and lists
  Add a safeguard in MergeRequest#compute_diverged_commits_count
  Fix an issue when the target branch of a MR had been deleted
  Add avatar to issue and MR pages header
  Cleanup somce css colors
  Re-group scss variables
  Refactor `Todo#target`
  Fixes issue with filter label missing on labels & milestones
  Rename `Todo#to_reference` to `Todo#target_reference`
  Fixed failing tests
  Updated controller with before_action Fixed other issues based on feedback
  Fixes issue on dashboard issues
  Full labels data in JSON
  Fixed issue with labels dropdown getting wrong labels
  Update CHANGELOG
  Use `Note#for_project_snippet?` to skip notes on project snippet
  Use `Commit#short_id` instead of `Commit.truncate_sha`
  Reuse `for_commit?` on conditional validations
  Update schema info comment on todo related files
  ...

Conflicts:
	app/models/issue.rb
	db/schema.rb
	spec/models/issue_spec.rb
2016-03-19 18:50:15 +01:00
Douglas Barbosa Alexandre 43d8bdb4f0 Restrict access to references for confidential issues 2016-03-17 20:55:59 -03:00
Grzegorz Bizon 4354bfaba5 Add implementation of reference unfolder using banzai 2016-03-17 07:39:16 +01:00
Grzegorz Bizon fd8394faae Move reference unfolder for GFM to separate class 2016-03-17 07:39:15 +01:00
Grzegorz Bizon cd0f194508 Do not unfold non-referables when moving an issue 2016-03-17 07:39:15 +01:00
Grzegorz Bizon 9124ebce98 Use internal reference extractor in banzai unfold pipeline 2016-03-17 07:39:15 +01:00
Grzegorz Bizon 3c493c24c7 Add reference unfold pipeline used when moving issue 2016-03-17 07:39:15 +01:00
Robert Speicher 41de7b345b Be more intelligent about sanitizing links with unsafe protocols
This prevents false matches on relative links like
`[database](database.md)`.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/14220
2016-03-14 18:05:01 -04:00
Douwe Maan 99f08b3f72 Merge branch 'feature/cross-project-labels' into 'master'
Add support for cross project references for labels

## Summary

Support for cross project references for labels.

## Rationale

1.   Cross project label references are currently not supported in GitLab
1.   `to_reference` method signature in `Label` model breaks the abstraction introduced in `Referable`.

      `concerns/referable.rb:  def to_reference(_from_project = nil)`

      Signatures:

      ```
      label.rb:           def to_reference(format = :id)

      commit_range.rb:    def to_reference(from_project = nil)
      commit.rb:          def to_reference(from_project = nil)
      external_issue.rb:  def to_reference(_from_project = nil)
      group.rb:           def to_reference(_from_project = nil)
      issue.rb:           def to_reference(from_project = nil)
      merge_request.rb:   def to_reference(from_project = nil)
      milestone.rb:       def to_reference(from_project = nil)
      project.rb:         def to_reference(_from_project = nil)
      snippet.rb:         def to_reference(from_project = nil)
      user.rb:            def to_reference(_from_project = nil)
      ```

     This MR suggests using `def to_reference(from_project = nil, format: :id)` which makes use of keyword arguments and preserves abstract interface.

1.   We need support for cross project label references when we want to move issue to another project

     It may happen that issue description, system notes or comments contain reference to label and this reference will be invalid after moving issue to another project and will not be displayed correctly unless we have support for cross project references.

     Merge request that needs this feature: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2831


I think that cross project label references may be useful, (example: `Hey, see our issues for CI in GitLab CE! - gitab-org/gitlab-ce~"CI"`).

cc @JobV @DouweM @rspeicher 

See merge request !2966
2016-03-07 09:16:22 +00:00
Robert Speicher 0c7626f3a5 Merge branch 'rs-frontmatter-pre' into 'master'
Properly display YAML front matter in Markdown

See merge request !3072
2016-03-05 00:17:58 +00:00
Robert Speicher 8eaeda0816 Add YamlFrontMatterFilter to the PreProcessPipeline
This filter will detect YAML Front Matter and convert it to an HTML
table for prettier formatting.
2016-03-04 18:05:48 -05:00
Douwe Maan 925da3fdf8 Merge branch 'rs-wiki-pipeline-spec' into 'master'
Add a spec for WikiPipeline

Removes the specs from GollumTagsFilter that were more like integration
tests for the pipeline than unit tests of the filter.

See merge request !3054
2016-03-04 21:19:11 +00:00
Robert Speicher def6446dad Replace [[_TOC_]] tag even if toc result is blank 2016-03-03 12:41:40 -05:00
Grzegorz Bizon fa639df5c7 Remove redundant code in cross project labels implementation 2016-03-03 10:41:11 +01:00
Grzegorz Bizon 7183a7da6d Add additional text prefix in cross project labels 2016-03-03 10:41:11 +01:00
Grzegorz Bizon a472c1bfd0 Add support for cross project references for labels 2016-03-03 10:41:11 +01:00
Grzegorz Bizon dbc7bf7fe1 Fix bug with return value in abstract reference filter
When `object_class.link_reference_pattern` was `nil` because object
being processed do not implemement link references `call` method
returned `nil` instead of returning document, even if document has been
processed in for basic reference pattern.
2016-03-03 10:41:11 +01:00
Robert Speicher 74751791a8 Add a PreProcessPipeline 2016-03-02 22:19:36 -05:00
Robert Speicher c9b1132217 Add FilterArray class to Banzai 2016-03-01 15:54:35 -05:00
Douwe Maan 3d1de5ba35 Merge branch 'rs-wiki-toc' into 'master'
Replace Gollum `[[_TOC_]]` tag with result of TableOfContentsFilter

Closes #2494

See merge request !2952
2016-03-01 16:06:40 +00:00
Robert Speicher 989946f337 Sanitize vbscript: links
Closes https://dev.gitlab.org/gitlab/gitlabhq/issues/2660
2016-02-23 20:42:03 -05:00
Robert Speicher bc43ad71ef Replace Gollum [[_TOC_]] tag with result of TableOfContentsFilter
Closes #2494
2016-02-23 18:25:40 -05:00
Robert Speicher 4225fd229f Sanitize data: links
Closes #13625
2016-02-21 17:33:35 -05:00
Douwe Maan ad12f11f3e Merge branch 'rs-emoji' into 'master'
Update Gemojione for new hotness 

Before | After
------ | -----
![Screen_Shot_2016-02-12_at_3.38.43_PM](/uploads/299e5ffe38c91657085741261a678f81/Screen_Shot_2016-02-12_at_3.38.43_PM.png) | ![Screen_Shot_2016-02-12_at_3.38.09_PM](/uploads/ccee29719a6445a9efd2498391a7eea0/Screen_Shot_2016-02-12_at_3.38.09_PM.png)

See merge request !2800
2016-02-19 08:11:02 +00:00
Robert Speicher fe13f58f3e Update Emoji asset path
Now that we're serving assets directly from the Gemojione gem's path,
the images are not in an `emoji/` sub-folder.
2016-02-12 15:34:20 -05:00
Ben BoeckelandRémy Coutable e919b5a4e9 Fix relative links in other markup formats
- Apply the RelativeLinkFilter filter to other formats, e.g.,
  reStructuredText so links from the Files view or the Project view work
- Remove the AsciidocPipeline pipeline

Fixes #3533.
2016-02-12 17:20:59 +01:00
Robert Speicher 89b3ddd609 Allow limited Markdown in Broadcast Messages
Closes #11853
2016-02-06 14:30:07 -05:00
Robert Speicher 47982e50c4 Make Pipelines responsible for defining their custom whitelist
This allows for future pipelines to more easily define a custom
whitelist.
2016-02-03 17:24:08 -05:00
Benedict Etzel 6435f78a8c Whitelist raw "abbr" elements when parsing Markdown
Closes #12517
2016-01-23 20:38:06 +01:00
Stan Hu a10ab94b06 Gracefully handle invalid UTF-8 sequences in Markdown links
Closes #6077
2016-01-20 07:07:53 -08:00
Robert Speicher 65eae647a6 Merge branch 'backport-ee' into 'master'
Backport two commits from EE

Backport part of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/110

See merge request !2424
2016-01-14 18:39:49 +00:00
Douglas Barbosa Alexandre ac2c86055e Update documentation on Banzai::Filter::GollumTagsFilter 2016-01-14 12:09:31 -02:00