Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Make livingstyleguide somewhat working again

Oliver Güntherc0e3516b5007
diff --git a/Gemfile b/Gemfile
index 495a012829e..33c28806d6b 100644
--- a/Gemfile
+++ b/Gemfile
@@ -98,6 +98,9 @@ gem 'svg-graph', '~> 2.1.0'
gem 'date_validator', '~> 0.9.0'
gem 'ruby-duration', '~> 3.2.0'
+gem 'sassc-rails'
+gem 'livingstyleguide', '~> 2.1.0'
+
# provide compatible filesystem information for available storage
gem 'sys-filesystem', '~> 1.3.3', require: false
diff --git a/Gemfile.lock b/Gemfile.lock
index b330ba79a2c..e25aec7d6b3 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -577,6 +577,12 @@ GEM
listen (3.2.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
+ livingstyleguide (2.1.0)
+ minisyntax (>= 0.2.5)
+ redcarpet
+ sassc
+ thor
+ tilt
lobby_boy (0.1.3)
omniauth (~> 1.1)
omniauth-openid-connect (>= 0.2.1)
@@ -603,6 +609,7 @@ GEM
mimemagic (0.3.5)
mini_mime (1.0.2)
mini_portile2 (2.4.0)
+ minisyntax (0.2.5)
minitest (5.14.1)
mixlib-shellout (2.1.0)
msgpack (1.3.3)
@@ -770,6 +777,7 @@ GEM
rdoc (6.2.1)
recaptcha (5.5.0)
json
+ redcarpet (3.5.0)
reform (2.2.4)
disposable (>= 0.4.1)
representable (>= 2.4.0, < 3.1.0)
@@ -852,6 +860,14 @@ GEM
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
nokogumbo (~> 2.0)
+ sassc (2.4.0)
+ ffi (~> 1.9)
+ sassc-rails (2.1.2)
+ railties (>= 4.0.0)
+ sassc (>= 2.0)
+ sprockets (> 3.0)
+ sprockets-rails
+ tilt
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
@@ -1008,6 +1024,7 @@ DEPENDENCIES
launchy (~> 2.5.0)
letter_opener
listen (~> 3.2.1)
+ livingstyleguide (~> 2.1.0)
lograge (~> 0.11.0)
meta-tags (~> 2.13.0)
multi_json (~> 1.14.1)
@@ -1086,6 +1103,7 @@ DEPENDENCIES
ruby-progressbar (~> 1.10.0)
rubytree (~> 1.0.0)
sanitize (~> 5.2.1)
+ sassc-rails
secure_headers (~> 6.3.0)
selenium-webdriver (~> 3.14)
semantic (~> 1.6.1)
diff --git a/app/assets/stylesheets/styleguide.html.lsg b/app/assets/stylesheets/styleguide.html.lsg
index 8acbdecb612..2a226583d5d 100644
--- a/app/assets/stylesheets/styleguide.html.lsg
+++ b/app/assets/stylesheets/styleguide.html.lsg
@@ -1,95 +1 @@
-@require sassc
-
-@sass styleguide.sass
-@title "Living Style Guide for OpenProject"
-
-@style base-font: Lato
-@style base-font-size: 16px
-@style background-color: white
-
-@default preprocessor: sass
-
-@css
-
- .styleguide-banner {
- height: 280px;
- padding: 200px 0 0;
- background: url('/assets/styleguide/logo_openproject.png');
- background-position: top center;
- background-repeat: no-repeat;
- }
-
- .styleguide-banner--text {
- text-align: center;
- }
-
- .styleguide-nav--menu-items {
- @extend %menu-bar;
- @include menu-bar-layout;
- @include menu-bar-style(#eee);
- }
-
- .livingstyleguide--code-block {
- max-height: 300px;
- }
-
- .livingstyleguide--example {
- overflow: visible;
- }
-
- .lsg-search-box {
- width: 40%;
- margin: 0 auto;
- }
-
- .icon-list {
- display: flex;
- flex-flow: row wrap;
- width: 640px;
- margin: 0 auto;
- }
-
- .icon-list li {
- flex: 1;
- flex-basis: 15%;
- display: block;
- text-align: center;
- margin: 10px;
- font-size: 12px;
- }
-
- .icon-list span.icon {
- display: block;
- font-size: 30px;
- }
-
-@header
- <header class="livingstyleguide--header grid-content">
- <div class="styleguide-banner">
- <h1 class="styleguide-banner--text">Living Style Guide</h1>
- </div>
- </header>
-
- <nav class="styleguide-nav">
- <ul class="styleguide-nav--menu-items">
- <li><a target="_self" href="#color-variables">Colors</a></li>
- <li><a target="_self" href="#fonts">Fonts</a></li>
- <li><a target="_self" href="#forms">Forms</a></li>
- <li><a target="_self" href="#notifications">Notifications</a></li>
- <li><a target="_self" href="#buttons">Buttons</a></li>
- <li><a target="_self" href="#pagination">Pagination</a></li>
- </ul>
- </nav>
-
- <section class="livingstyleguide--intro grid-content">
- <p>&nbsp;</p>
- </section>
-
-@search-box
-
-@footer
- <footer class="livingstyleguide--footer grid-content">
- Copyright © 2020 OpenProject - All rights reserved.
- </footer>
-
@import ../../../frontend/src/global_styles/**/_*.lsg
diff --git a/app/assets/stylesheets/styleguide.layout.html.erb b/app/assets/stylesheets/styleguide.layout.html.erb
new file mode 100644
index 00000000000..20c1c91c36d
--- /dev/null
+++ b/app/assets/stylesheets/styleguide.layout.html.erb
@@ -0,0 +1,104 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta content="ie=edge" http-equiv="x-ua-compatible">
+ <meta content="width=device-width,initial-scale=1" name="viewport">
+ <meta content="livingstyleguide.org <%= LivingStyleGuide::VERSION %>" name="generator">
+ <title>Living Style Guide for OpenProject</title>
+ <script src="http://localhost:4200/assets/frontend/vendor.js"></script>
+ <script src="http://localhost:4200/assets/frontend/polyfills.js"></script>
+ <script src="http://localhost:4200/assets/frontend/runtime.js"></script>
+ <script src="http://localhost:4200/assets/frontend/main.js"></script>
+ <script src="http://localhost:4200/assets/frontend/styles.js"></script>
+ <style>
+ body {
+ max-width: 65vw;
+ margin: 0 auto;
+ font-family: Lato;
+ font-size: 16px;
+ background-color: white;
+ }
+
+ .styleguide-banner {
+ height: 280px;
+ padding: 200px 0 0;
+ background: url('/assets/styleguide/logo_openproject.png');
+ background-position: top center;
+ background-repeat: no-repeat;
+ }
+
+ .styleguide-banner--text {
+ text-align: center;
+ }
+
+ .styleguide-nav--menu-items {
+ display: flex;
+ justify-content: space-between;
+ list-style: none;
+ }
+
+ .livingstyleguide--code-block {
+ max-height: 300px;
+ }
+
+ .livingstyleguide--example {
+ overflow: visible;
+ }
+
+ .lsg-search-box {
+ width: 40%;
+ margin: 0 auto;
+ }
+
+ .icon-list {
+ display: flex;
+ flex-flow: row wrap;
+ width: 640px;
+ margin: 0 auto;
+ }
+
+ .icon-list li {
+ flex: 1;
+ flex-basis: 15%;
+ display: block;
+ text-align: center;
+ margin: 10px;
+ font-size: 12px;
+ }
+
+ .icon-list span.icon {
+ display: block;
+ font-size: 30px;
+ }
+ </style>
+ </head>
+<body class="lsg">
+ <header class="livingstyleguide--header grid-content">
+ <div class="styleguide-banner">
+ <h1 class="styleguide-banner--text">Living Style Guide</h1>
+ </div>
+ </header>
+
+ <nav class="styleguide-nav">
+ <ul class="styleguide-nav--menu-items">
+ <li><a target="_self" href="#color-variables">Colors</a></li>
+ <li><a target="_self" href="#fonts">Fonts</a></li>
+ <li><a target="_self" href="#forms">Forms</a></li>
+ <li><a target="_self" href="#notifications">Notifications</a></li>
+ <li><a target="_self" href="#buttons">Buttons</a></li>
+ <li><a target="_self" href="#pagination">Pagination</a></li>
+ </ul>
+ </nav>
+
+ <section class="livingstyleguide--intro grid-content">
+ <p>&nbsp;</p>
+ </section>
+ <article class="lsg-container">
+ <%= html %>
+ </article>
+ <footer class="livingstyleguide--footer grid-content">
+ Copyright © 2020 OpenProject - All rights reserved.
+ </footer>
+ </body>
+</html>
diff --git a/app/assets/stylesheets/styleguide.sass b/app/assets/stylesheets/styleguide.sass
deleted file mode 100644
index 3b17ad97097..00000000000
--- a/app/assets/stylesheets/styleguide.sass
+++ /dev/null
@@ -1,10 +0,0 @@
-// Variables
-@import "../../../frontend/src/global_styles/openproject/_variables.scss"
-// Foundation variables
-@import "../../../frontend/src/global_styles/openproject/_settings.scss"
-
-// Dependencies
-@import "../../../frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss"
-
-// Core styles
-@import "../../../frontend/src/global_styles/openproject.sass"
\ No newline at end of file
diff --git a/app/views/common/_favicons.html.erb b/app/views/common/_favicons.html.erb
index 2e3c5e1cb4c..27faad36db4 100644
--- a/app/views/common/_favicons.html.erb
+++ b/app/views/common/_favicons.html.erb
@@ -1,3 +1,5 @@
+<% begin %>
+
<% unless (EnterpriseToken.allows_to?(:define_custom_style) && CustomStyle.try(:current).present? && CustomStyle.current.favicon.present?) %>
<%= favicon_link_tag OpenProject::CustomStyles::Design.favicon_asset_path %>
<% end %>
@@ -8,3 +10,9 @@
type: 'image/png',
sizes: "120x120" %>
<% end %>
+
+<% rescue => e
+ binding.pry
+ warn e
+ end
+%>
diff --git a/config/initializers/livingstyleguide_patches.rb b/config/initializers/livingstyleguide_patches.rb
new file mode 100644
index 00000000000..4362883aa7a
--- /dev/null
+++ b/config/initializers/livingstyleguide_patches.rb
@@ -0,0 +1,48 @@
+#-- encoding: UTF-8
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+#
+if defined?(LivingStyleGuide)
+ ##
+ # Override CSS to never be called
+ module DocumentTemplatePatch
+ ##
+ # Define our own template
+ def template_erb
+ if @template == :layout
+ File.read(Rails.root.join('app/assets/stylesheets/styleguide.layout.html.erb'))
+ else
+ super
+ end
+ end
+ end
+
+ LivingStyleGuide::Document.prepend DocumentTemplatePatch
+end
+