From 55e2f353d412537a58ff19a63a8cc3d5651d881f Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 17 Mar 2014 10:41:39 +0100 Subject: Link to blob instead of linking to wiki. --- app/helpers/gitlab_markdown_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 7f72ab54838..685ef752d84 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -134,12 +134,12 @@ module GitlabMarkdownHelper end # Checks if the path exists in the repo - # eg. checks if doc/README.md exists, if it doesn't then it is a wiki link + # eg. checks if doc/README.md exists, if not then link to blob def path_with_ref(path, ref) if file_exists?(path) "#{local_path(path)}/#{correct_ref(ref)}" else - "wikis" + "blob/#{correct_ref(ref)}" end end -- cgit v1.2.1 From f04d5bfaf6afcdbc4e91a2fa3069a5438b7fa569 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 17 Mar 2014 11:27:59 +0100 Subject: Wiki will show relative links related to the wiki gollum repository. --- app/helpers/gitlab_markdown_helper.rb | 3 +-- lib/redcarpet/render/gitlab_html.rb | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 685ef752d84..69425bc171d 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -63,8 +63,7 @@ module GitlabMarkdownHelper # project_path_with_namespace - namespace/projectname, eg. gitlabhq/gitlabhq # ref - name of the branch or reference, eg. stable # requested_path - path of request, eg. doc/api/README.md, used in special case when path is pointing to the .md file were the original request is coming from - # wiki - whether the markdown is from wiki or not - def create_relative_links(text, project, ref, requested_path, wiki = false) + def create_relative_links(text, project, ref, requested_path) @path_to_satellite = project.satellite.path project_path_with_namespace = project.path_with_namespace paths = extract_paths(text) diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index 2e18b0592b5..86d8b69b0ef 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -46,8 +46,10 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML end def preprocess(full_document) - if @project - h.create_relative_links(full_document, @project, @ref, @request_path, is_wiki?) + if is_wiki? + full_document + elsif @project + h.create_relative_links(full_document, @project, @ref, @request_path) else full_document end -- cgit v1.2.1 From 3f818a3d58bbfcd009e9985abb835fb4de56cadf Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 17 Mar 2014 12:16:26 +0100 Subject: Update wiki tests. --- features/steps/project/markdown_render.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/features/steps/project/markdown_render.rb b/features/steps/project/markdown_render.rb index 8fbf2753aa7..c94de283069 100644 --- a/features/steps/project/markdown_render.rb +++ b/features/steps/project/markdown_render.rb @@ -203,7 +203,7 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps end And 'I add various links to the wiki page' do - fill_in "wiki[content]", with: "[test](test)\n[GitLab API doc](doc/api/README.md)\n[Rake tasks](doc/raketasks)\n" + fill_in "wiki[content]", with: "[test](test)\n[GitLab API doc](api)\n[Rake tasks](raketasks)\n" fill_in "wiki[message]", with: "Adding links to wiki" click_button "Create page" end @@ -242,8 +242,8 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps end Then 'I see Gitlab API document' do - current_path.should == project_blob_path(@project, "master/doc/api/README.md") - page.should have_content "Status codes" + current_path.should == project_wiki_path(@project, "api") + page.should have_content "Editing" end And 'I click on Rake tasks link' do @@ -251,9 +251,8 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps end Then 'I see Rake tasks directory' do - current_path.should == project_tree_path(@project, "master/doc/raketasks") - page.should have_content "backup_restore.md" - page.should have_content "maintenance.md" + current_path.should == project_wiki_path(@project, "raketasks") + page.should have_content "Editing" end Given 'I go directory which contains README file' do -- cgit v1.2.1 From 656d9548bcfa315751fc01b3afb0ec14104e15a8 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 17 Mar 2014 13:04:18 +0100 Subject: Update markdown documentation, fix wiki spec. --- doc/markdown/markdown.md | 47 +++++++++++++++++++++++------ spec/helpers/gitlab_markdown_helper_spec.rb | 6 ---- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/doc/markdown/markdown.md b/doc/markdown/markdown.md index f49f09756ab..e7ebc613431 100644 --- a/doc/markdown/markdown.md +++ b/doc/markdown/markdown.md @@ -8,23 +8,38 @@ Table of Contents **[GitLab Flavored Markdown](#gitlab-flavored-markdown-gfm)** [Newlines](#newlines) + [Multiple underscores in words](#multiple-underscores-in-words) + [URL autolinking](#url-autolinking) + [Code and Syntax Highlighting](#code-and-syntax-highlighting) + [Emoji](#emoji) + [Special GitLab references](#special-gitlab-references) + **[Standard Markdown](#standard-markdown)** [Headers](#headers) + [Emphasis](#emphasis) + [Lists](#lists) + [Links](#links) + [Images](#images) + [Blockquotes](#blockquotes) + [Inline HTML](#inline-html) + [Horizontal Rule](#horizontal-rule) + [Line Breaks](#line-breaks) + [Tables](#tables) **[References](#references)** @@ -33,7 +48,8 @@ Table of Contents GitLab Flavored Markdown (GFM) ============================== -For GitLab we developed something we call "GitLab Flavored Markdown" (GFM). It extends the standard Markdown in a few significant ways to add some useful functionality. +For GitLab we developed something we call "GitLab Flavored Markdown" (GFM). +It extends the standard Markdown in a few significant ways to add some useful functionality. You can use GFM in @@ -51,16 +67,20 @@ Please see the [github-markup gem readme](https://github.com/gitlabhq/markup#mar Newlines -------- -The biggest difference that GFM introduces is in the handling of linebreaks. With traditional Markdown you can hard wrap paragraphs of text and they will be combined into a single paragraph. We find this to be the cause of a huge number of unintentional formatting errors. GFM treats newlines in paragraph-like content as real line breaks, which is probably what you intended. +GFM honors the markdown specification in how [paragraphs and line breaks are handled](http://daringfireball.net/projects/markdown/syntax#p). -The next paragraph contains two phrases separated by a single newline character: +A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines.: Roses are red Violets are blue + Sugar is sweet + Roses are red Violets are blue +Sugar is sweet + Multiple underscores in words ----------------------------- It is not reasonable to italicize just _part_ of a word, especially when you're dealing with code and names that often appear with multiple underscores. Therefore, GFM ignores multiple underscores in words. @@ -319,13 +339,13 @@ Strikethrough uses two tildes. ~~Scratch this.~~ ## Links -There are two ways to create links. +There are two ways to create links, inline-style and reference-style. [I'm an inline-style link](https://www.google.com) [I'm a reference-style link][Arbitrary case-insensitive reference text] - [I'm a relative reference to a repository file](../blob/master/LICENSE) + [I'm a relative reference to a repository file](LICENSE) [You can use numbers for reference-style link definitions][1] @@ -341,7 +361,7 @@ There are two ways to create links. [I'm a reference-style link][Arbitrary case-insensitive reference text] -[I'm a relative reference to a repository file](../blob/master/LICENSE) +[I'm a relative reference to a repository file](LICENSE) [You can use numbers for reference-style link definitions][1] @@ -353,6 +373,15 @@ Some text to show that the reference links can follow later. [1]: http://slashdot.org [link text itself]: http://www.reddit.com +**Note** + +Relative links do not allow referencing project files in a wiki page or wiki page in a project file. +The reason for this is that, in GitLab, wiki is always a separate git repository. For example: + +`[I'm a reference-style link][style]` + +will point the link to `wikis/style` when the link is inside of a wiki markdown file. + ## Images Here's our logo (hover to see the title text): @@ -365,15 +394,15 @@ Some text to show that the reference links can follow later. [logo]: assets/logo-white.png -Here's our logo (hover to see the title text): +Here's our logo: Inline-style: -![alt text](/assets/logo-white.png "Logo Title Text 1") +![alt text](/assets/logo-white.png) Reference-style: ![alt text][logo] -[logo]: /assets/logo-white.png "Logo Title Text 2" +[logo]: /assets/logo-white.png ## Blockquotes diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 7e98b7944f1..5bd16d1c16c 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -440,12 +440,6 @@ describe GitlabMarkdownHelper do markdown(actual).should match(expected) end - it "should handle wiki urls" do - actual = "[Link](test/link)\n" - expected = "

Link

\n" - markdown(actual).should match(expected) - end - it "should handle relative urls in reference links for a file in master" do actual = "[GitLab API doc][GitLab readme]\n [GitLab readme]: doc/api/README.md\n" expected = "

GitLab API doc

\n" -- cgit v1.2.1