bit of form cleanup

This commit is contained in:
2023-01-12 14:34:00 +02:00
parent f74077ce6d
commit 621efd8a9c
3 changed files with 24 additions and 10 deletions

View File

@ -7,8 +7,8 @@ module ApplicationHelper
return "" unless story
text_length = story.text.length
template = "text"
template = "half" if text_length < 200
template = "pic" if text_length < 100
template = "half" if text_length < 400
template = "pic" if text_length < 200
render partial: "stories/#{template}" , locals: {story: story}
end
@ -33,6 +33,10 @@ module ApplicationHelper
self.renderer.render(text).html_safe
end
def shorten(text , to = 100)
return "" if text.blank?
"#{text[0..to]} . . . ".html_safe
end
def main_app
Rails.application.routes.url_helpers
end
@ -41,4 +45,13 @@ module ApplicationHelper
"mr-3 inline-block rounded-lg px-3 py-2 text-md font-medium border border-gray-500"
end
def rows( text )
return 5 if text.blank?
text = text.text unless text.is_a?(String)
return 5 if text.blank?
rows = (text.length / 60).to_i
return 5 if rows < 5
rows
end
end