Commit Graph

31 Commits

Author SHA1 Message Date
Nick Thomas aac2af5bc4 HTMLEntityFilter -> HtmlEntityFilter 2016-10-10 15:46:26 +01:00
Nick Thomas 9920551536 Enable CacheMarkdownField for the remaining models
This commit alters views for the following models to use the markdown cache if
present:

* AbuseReport
* Appearance
* ApplicationSetting
* BroadcastMessage
* Group
* Issue
* Label
* MergeRequest
* Milestone
* Project

At the same time, calls to `escape_once` have been moved into the `single_line`
Banzai pipeline, so they can't be missed out by accident and the work is done
at save, rather than render, time.
2016-10-07 02:54:26 +01:00
Rémy Coutable 98e540532c Use a more powerful query to match videos in img tags
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>
2016-07-19 18:51:09 +02:00
Eric Hayes c266c7fa18 First support of videos in issues, MRs and notes
* Registered video MIME types
* Currently supporting browser-supported formats with extensions that match the mime type
2016-07-19 18:51:09 +02:00
Douwe Maan 6a477b9bfc Add blockquote fence syntax to Markdown 2016-07-09 21:23:05 -04:00
Grzegorz Bizon 9e211091a8 Enable Style/EmptyLines cop, remove redundant ones 2016-07-01 21:56:17 +02:00
Yorick Peterse d470f3d195
Support for rendering/redacting multiple documents
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.
2016-06-24 11:46:39 +02:00
Sean McGivern 03d2bf141c Fix description and GFM pipelines conflicting
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.
2016-06-13 13:06:40 +01:00
Yorick Peterse 86166d2802
Split Markdown rendering & reference gathering
This splits the Markdown rendering and reference extraction phases into
two distinct code bases. The reference extraction phase no longer relies
on the html-pipeline Gem (and any related code) and allows for
extracting of references from multiple HTML nodes in a single pass. This
means that if you want to extract user references from 200 comments you
no longer need to run 200 times N number of queries, instead only a
handful of queries may be needed.
2016-05-26 17:14:00 +02:00
Adam Butler 8a8b5497c5 Create DiffFilter and change SystemNoteService#change_title to use Gitlab::Diff::InlineDiff 2016-05-18 11:15:10 -05: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 207b7218aa Ensure correct filter order to validate with our markdown spec 2016-04-06 03:30:56 -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
Gabriel Mazetto 28266d9d61 Added WikiLinkFilter 2016-04-01 00:17:37 -03:00
Robert Speicher 8558483417 Remove redundant `require`s from Banzai files
We're trying to avoid circular dependency errors.
2016-03-24 13:23:47 -04: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
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
Robert Speicher bc43ad71ef Replace Gollum `[[_TOC_]]` tag with result of TableOfContentsFilter
Closes #2494
2016-02-23 18:25:40 -05:00
Ben Boeckel 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
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 ca87bb652a Remove GollumTagsPipeline 2016-01-14 12:09:31 -02:00
Douglas Barbosa Alexandre 4872b319c8 Use the WikiPipeline when rendering the wiki markdown content 2016-01-14 12:09:31 -02:00
Douwe Maan 2a20c0e590 Prevent circular reference error in Banzai 2016-01-14 11:30:28 +01:00
Robert Speicher 90510f0037 Merge branch 'milestone-ref' into 'master'
Link to milestone in "Milestone changed" system note

Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/4141

See merge request !2203
2016-01-07 19:22:43 +00:00
Robert Speicher 1e6fc0c6a4 Define a limited set of filters for SingleLinePipeline
Removes the following filters from its parent GfmPipeline:

- SyntaxHighlightFilter
- UploadLinkFilter
- TableOfContentsFilter
- LabelReferenceFilter
- TaskListFilter

Closes #1697
2016-01-05 17:13:21 -05:00
Douwe Maan 989131c530 Render milestone links as references 2015-12-24 14:43:07 +01:00
Douwe Maan 7781bda9bd Move Markdown/reference logic from Gitlab::Markdown to Banzai 2015-12-15 15:51:16 +01:00