From d060856044655ac76101a8ded51507479b4bc34a Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Mon, 15 Oct 2012 20:56:58 +0200 Subject: [PATCH] Extract out tree/blob/* partials --- app/views/tree/_blob.html.haml | 30 +++---------------------- app/views/tree/blob/_download.html.haml | 8 +++++++ app/views/tree/blob/_image.html.haml | 2 ++ app/views/tree/blob/_text.html.haml | 15 +++++++++++++ 4 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 app/views/tree/blob/_download.html.haml create mode 100644 app/views/tree/blob/_image.html.haml create mode 100644 app/views/tree/blob/_text.html.haml diff --git a/app/views/tree/_blob.html.haml b/app/views/tree/_blob.html.haml index 93271d94..b6913586 100644 --- a/app/views/tree/_blob.html.haml +++ b/app/views/tree/_blob.html.haml @@ -6,32 +6,8 @@ %small #{blob.mode} %span.options= render "tree/blob_actions" - if blob.text? - - if gitlab_markdown?(blob.name) - .file_content.wiki - = preserve do - = markdown(blob.data) - - elsif markup?(blob.name) - .file_content.wiki - = raw GitHub::Markup.render(blob.name, blob.data) - - else - .file_content.code - - unless blob.empty? - %div{class: current_user.dark_scheme ? "black" : "white"} - = preserve do - = raw blob.colorize(options: { linenos: 'True'}) - - else - %h4.nothing_here_message Empty file - + = render "tree/blob/text", blob: blob - elsif blob.image? - .file_content.image_file - %img{ src: "data:#{blob.mime_type};base64,#{Base64.encode64(blob.data)}"} - + = render "tree/blob/image", blob: blob - else - .file_content.blob_file - %center - = link_to project_blob_path(@project, @id) do - %div.padded - %br - = image_tag "download.png", width: 64 - %h3 - Download (#{blob.mb_size}) + = render "tree/blob/download", blob: blob diff --git a/app/views/tree/blob/_download.html.haml b/app/views/tree/blob/_download.html.haml new file mode 100644 index 00000000..7623e6f4 --- /dev/null +++ b/app/views/tree/blob/_download.html.haml @@ -0,0 +1,8 @@ +.file_content.blob_file + %center + = link_to project_blob_path(@project, @id) do + %div.padded + %br + = image_tag "download.png", width: 64 + %h3 + Download (#{blob.mb_size}) diff --git a/app/views/tree/blob/_image.html.haml b/app/views/tree/blob/_image.html.haml new file mode 100644 index 00000000..7b23f0c8 --- /dev/null +++ b/app/views/tree/blob/_image.html.haml @@ -0,0 +1,2 @@ +.file_content.image_file + %img{ src: "data:#{blob.mime_type};base64,#{Base64.encode64(blob.data)}"} diff --git a/app/views/tree/blob/_text.html.haml b/app/views/tree/blob/_text.html.haml new file mode 100644 index 00000000..c506a39f --- /dev/null +++ b/app/views/tree/blob/_text.html.haml @@ -0,0 +1,15 @@ +- if gitlab_markdown?(blob.name) + .file_content.wiki + = preserve do + = markdown(blob.data) +- elsif markup?(blob.name) + .file_content.wiki + = raw GitHub::Markup.render(blob.name, blob.data) +- else + .file_content.code + - unless blob.empty? + %div{class: current_user.dark_scheme ? "black" : "white"} + = preserve do + = raw blob.colorize(options: { linenos: 'True'}) + - else + %h4.nothing_here_message Empty file