Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-695

Allow plugins to define css styles

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: plugin-proposals
    • Labels:
      None
    • Environment:
      Platform: All, OS: All
    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          kohsuke 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.

          Show
          kohsuke 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.
          Hide
          peterkittreilly peterkittreilly added a comment -

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

          Show
          peterkittreilly peterkittreilly added a comment - Created an attachment (id=75) proposed patch for layout.jelly
          Hide
          peterkittreilly 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>

          Show
          peterkittreilly 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>
          Hide
          kohsuke 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.

          Show
          kohsuke 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.
          Hide
          peterkittreilly 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

          Show
          peterkittreilly 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
          Hide
          peterkittreilly 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

          Show
          peterkittreilly 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
          Hide
          kohsuke Kohsuke Kawaguchi added a comment -

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

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

          Awesome! Thanks. Peter

          Show
          peterkittreilly peterkittreilly added a comment - Awesome! Thanks. Peter

            People

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

              Dates

              Created:
              Updated:
              Resolved: