• Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • plugin-proposals
    • None
    • Platform: All, OS: All

      It would be nice if plugins could define css styles that could
      be used in their jelly scripts.

      These could be put into
      src/main/webapp/css/*.css

      and loaded by hudson for jobs that have the corresponding
      plugin configured.

      The current setup is less than optimal - inline styles.

          [JENKINS-695] Allow plugins to define css styles

          Would you need to specify order among CSS, or can Hudson use some trivial
          ordering scheme (like alphabetical order)?

          I ask this because order in CSS matters.

          Kohsuke Kawaguchi added a comment - Would you need to specify order among CSS, or can Hudson use some trivial ordering scheme (like alphabetical order)? I ask this because order in CSS matters.

          Created an attachment (id=75)
          proposed patch for layout.jelly

          peterkittreilly added a comment - Created an attachment (id=75) proposed patch for layout.jelly

          Good point about the ordering.

          I have been playing a little with the code and
          a very simple solution exists for index.jelly pages:

          Modify hudson/main/core/src/main/resources/lib/layout/layout.jelly
          to allow an optional css attribute, some thing like the included patch.

          in an index.jelly one can then do:

          <j:jelly xmlns:j="jelly:core"
          xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
          xmlns:t="/lib/hudson" xmlns:f="/lib/form">
          <l:layout css="/plugin/mysuperplugin/css/myneatstyle.css">
          ..

          the myneatstyle.css would contain the styles for this page,
          and could if needs import other stylesheets.

          Peter.

          — layout.jelly 2007-06-26 18:09:52.000000000 +0100
          +++ layout-modified.jelly 2007-08-01 23:35:39.000000000 +0100
          @@ -20,6 +20,7 @@
          <title>${h.appendIfNotNull(title, ' [Hudson]', 'Hudson')}</title>
          <link rel="stylesheet" href="${rootURL}/css/style.css" type="text/css" />
          <link rel="stylesheet" href="${rootURL}/css/color.css" type="text/css" />
          + <link rel="stylesheet" href="${rootURL}/${css}" type="text/css" />
          <link rel="shortcut icon" href="${rootURL}/favicon.ico"
          type="image/vnd.microsoft.icon" />
          <script src="${rootURL}/scripts/prototype.js" type="text/javascript"></script>
          <script src="${rootURL}/scripts/behavior.js" type="text/javascript"></script>

          peterkittreilly added a comment - Good point about the ordering. I have been playing a little with the code and a very simple solution exists for index.jelly pages: Modify hudson/main/core/src/main/resources/lib/layout/layout.jelly to allow an optional css attribute, some thing like the included patch. in an index.jelly one can then do: <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> <l:layout css="/plugin/mysuperplugin/css/myneatstyle.css"> .. the myneatstyle.css would contain the styles for this page, and could if needs import other stylesheets. Peter. — layout.jelly 2007-06-26 18:09:52.000000000 +0100 +++ layout-modified.jelly 2007-08-01 23:35:39.000000000 +0100 @@ -20,6 +20,7 @@ <title>${h.appendIfNotNull(title, ' [Hudson] ', 'Hudson')}</title> <link rel="stylesheet" href="${rootURL}/css/style.css" type="text/css" /> <link rel="stylesheet" href="${rootURL}/css/color.css" type="text/css" /> + <link rel="stylesheet" href="${rootURL}/${css}" type="text/css" /> <link rel="shortcut icon" href="${rootURL}/favicon.ico" type="image/vnd.microsoft.icon" /> <script src="${rootURL}/scripts/prototype.js" type="text/javascript"></script> <script src="${rootURL}/scripts/behavior.js" type="text/javascript"></script>

          Thanks. I modified it slightly so that in future we can use path that doesn't
          start with '/' to mean something more intuitive (like loading from plugin's
          src/main/webapp/)

          This fix will be in 1.125.

          Kohsuke Kawaguchi added a comment - Thanks. I modified it slightly so that in future we can use path that doesn't start with '/' to mean something more intuitive (like loading from plugin's src/main/webapp/) This fix will be in 1.125.

          Thanks for getting this in so quickly.
          When I tested with it (using the snapshot war file) however, I was not able
          to get it to work. I needed to change the line
          27: <j:if test="${attrs.css}">
          to
          27: <j:if test="${css != null}">

          (I cannot compile hudson at the moment (I am using linux and
          have not been able to compile it), so I made the changes
          by hand in the webapps/hudson/WEB-INF/lib/core-hudson-...jar file

          Peter

          peterkittreilly added a comment - Thanks for getting this in so quickly. When I tested with it (using the snapshot war file) however, I was not able to get it to work. I needed to change the line 27: <j:if test="${attrs.css}"> to 27: <j:if test="${css != null}"> (I cannot compile hudson at the moment (I am using linux and have not been able to compile it), so I made the changes by hand in the webapps/hudson/WEB-INF/lib/core-hudson-...jar file Peter

          Oh, I see that
          27: <j:if test="${attrs.css != null}">
          also works and is better as it does not
          pick up "css" in parent jexl contexts.

          I will re-open the issue.
          Peter

          peterkittreilly added a comment - Oh, I see that 27: <j:if test="${attrs.css != null}"> also works and is better as it does not pick up "css" in parent jexl contexts. I will re-open the issue. Peter

          Fixed. Just in time for 1.125 release, which I'm starting now.

          Kohsuke Kawaguchi added a comment - Fixed. Just in time for 1.125 release, which I'm starting now.

          Awesome! Thanks. Peter

          peterkittreilly added a comment - Awesome! Thanks. Peter

            Unassigned Unassigned
            peterkittreilly peterkittreilly
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: