module ProjectsHelper def project_or_projects_path(project, current_project) if project == current_project projects_path else project_path(project.public_id) end end def format_content(file) content = file.content case file.type when ".md" content_tag(:div, Kramdown::Document.new(content).to_html.html_safe, class: "reading-font") when ".exe", ".dll", ".gz", ".zip", ".ttf", ".woff2", ".br" content_tag(:p, "Sorry, this file is not available for viewing", class: "reading-font") when ".jpg", ".png" data = {content: content.unpack("C*"), type: file.mime_type, name: file.relative_path} content_tag(:span, id: "image-viewer", data:) do content_tag(:img, nil, alt: "Loading...", class: "img-fluid mx-auto d-block") end else content_tag(:pre, content, class: "mb-0", id: "code-viewer", data: {language: file.type[1..]}) end end end