From 8dc2514852341bcc216138b4fe6f3f96aca21eee Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Wed, 29 Jun 2016 21:49:32 +0200 Subject: [PATCH] Added partial to display long description properly --- app/assets/stylesheets/_settings.scss | 6 ++++++ app/views/packages/_long_description.slim | 19 +++++++++++++++++++ app/views/packages/details.slim | 3 ++- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/views/packages/_long_description.slim diff --git a/app/assets/stylesheets/_settings.scss b/app/assets/stylesheets/_settings.scss index b5fdc5e..8dbd208 100644 --- a/app/assets/stylesheets/_settings.scss +++ b/app/assets/stylesheets/_settings.scss @@ -952,3 +952,9 @@ a.black margin-left: 2em; margin-bottom: 0.5em; } + +.description-verbatim-lines +{ + line-height: 120%; + // white-space: pre-line; +} diff --git a/app/views/packages/_long_description.slim b/app/views/packages/_long_description.slim new file mode 100644 index 0000000..c957fb9 --- /dev/null +++ b/app/views/packages/_long_description.slim @@ -0,0 +1,19 @@ +/ Converts long descriptions from Debian control files into +/ proper HTML. +/ See: https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description + +- text.lines.each do |line| + / pre +++#{line}--- + - case line.rstrip + - when '.' + / Empty line + / TODO: Technically wrong because this creates an empty paragraph: + p + - when /^(\s+)(.+)/ + / Verbatim text + div.description-verbatim-lines + = (' ' * $1.to_s.length).html_safe + = $2 + - else + / Normal text + = line diff --git a/app/views/packages/details.slim b/app/views/packages/details.slim index ee3725f..0a0bd89 100644 --- a/app/views/packages/details.slim +++ b/app/views/packages/details.slim @@ -44,7 +44,8 @@ p.subtitle Description // TODO: split long_description by

tags - if @package.long_description.present? - p =@package.long_description + = render(partial: 'long_description', locals: {text: @package.long_description}) + / p =@package.long_description - else p Sorry - no more information available. - if @package.homepage.present?