You are here

README.txt in Code per Node 7

Same filename and directory in other branches
  1. 6 README.txt
Code-per-Node
-------------
This module allows arbitrary amounts of CSS or JS to be added to nodes and
blocks.


Features
------------------------------------------------------------------------------
The primary features include:

* CSS and JS may be added to any node, with an optional wrapper to make the code
  simpler.

* CSS and JS may be added to any block, with an optional wrapper to make the
  code simpler.

* A "noscript" code block may be added for nodes and blocks to display HTML if
  the visitor has disabled JS.

* Control over which node view modes cause the CSS and JS to be loaded.

* Control over whether the CSS and JS output is aggregated with other files.

* Optional global CSS and JS that will be loaded on all non-admin pages.

* Syntax highlighting for both CSS and JS using the CodeMirror library.

* Optional support for Libraries API to control the location of the CodeMirror
  library.

* Optional token replacement for node and block CSS and JS, if the Token module
  is installed a popup token browser will be available.

* Optionally control the weight of the CSS and JS, allowing for exact
  positioning of each.

* Integrate with the AdvAgg and Varnish modules to clear their respective caches
  when the CSS or JS are updated.


Installation
------------------------------------------------------------------------------
The module should be installed and enabled in the usual way.

It is suggested to also install the CodeMirror library (v3.20 or newer) to
provide syntax highlighting, etc. To install CodeMirror:

 1. Download the latest package from http://codemirror.net/.
 2. Extract the archive.
 3. Ensure that the directory is named "codemirror" (case sensitive).
 4. Move the directory to sites/all/libraries so that there is a file located
    at sites/all/libraries/codemirror/lib/codemirror.js.
 5. If using the Libraries API module, it may be relocated as necessary.


Configuration
------------------------------------------------------------------------------
 1. On the People Permissions administration page ("Administer >> People
    >> Permissions") you need to assign:

    - The "Administer Code per Node" permission to the roles that are allowed to
      change the main settings and edit CSS or JS for individual nodes and
      blocks.

    - The "Edit CSS per node" permission to the roles that are allowed to add
      custom CSS for individual nodes.

    - The "Edit JS per node" permission to the roles that are allowed to add
      custom JavaScript for individual nodes.

    - The "Edit CSS per block" permission to the roles that are allowed to add
      custom CSS for individual blocks.

    - The "Edit JS per block" permission to the roles that are allowed to add
      custom JavaScript for individual blocks.

 2. The main administrative page controls the site-wide settings, including the
    location of the custom files, whether aggregation is enabled, customize the
    code wrappers, and global CSS & JS:
      admin/config/content/cpn

 3. Each content type can have the CSS & JS enabled on their respective edit
    page, along with custom code that will be loaded on each node page of that
    type.

 4. Each node add & edit page, belonging to the content type(s) enabled in step
    3 above, will have a new section called "CSS & JavaScript" containing the
    fields for entering the code.


SECURITY WARNING
------------------------------------------------------------------------------
BE VERY CAREFUL with the user roles that are granted access to insert custom CSS
and JS, THERE IS NO SECURITY FILTERING APPLIED to the code so only grant access
to it to people who are trusted.


Troubleshooting / Tips
------------------------------------------------------------------------------
* The CSS and JS will be automatically loaded on the appropriate pages, however
  nothing is added to make the CSS or JS only affect the elements of that node
  or block, so the code should be handled accordingly.
* The CSS and JS wrapper options can be used to simplify the code that is
  necessary for each node or block, e.g. the following would allow all JS code
  to be written to just use the simpler $() syntax for JS selection:
    (function ($) {
    [code]
    })(jQuery);
* The global CSS/JS options are meant for temporary adhoc changes, they are not
  a replacement for properly built code added to the site's theme.


Related Modules
------------------------------------------------------------------------------
Other modules provide related or similar functionality to CPN:

* Panels CSS & JS
  https://www.drupal.org/project/panels_css_js
  Add CSS and JS to displays managed by Panels, Mini Panels, Panels Everywhere
  and Panelizer.


Credits / Contact
------------------------------------------------------------------------------
Originally build by joelstein [1], Rob Loach [2] contributed on the D7 port.

Currently maintained by Damien McKenna [3].

Continued development is sponsored by Mediacurrent [4].

The best way to contact the authors is to submit an issue, be it a support
request, a feature request or a bug report, in the project issue queue:
  http://drupal.org/project/issues/cpn


References
------------------------------------------------------------------------------
1: http://drupal.org/user/61114
2: http://drupal.org/user/36598
3: http://drupal.org/user/108450
4: http://www.mediacurrent.com/

File

README.txt
View source
  1. Code-per-Node
  2. -------------
  3. This module allows arbitrary amounts of CSS or JS to be added to nodes and
  4. blocks.
  5. Features
  6. ------------------------------------------------------------------------------
  7. The primary features include:
  8. * CSS and JS may be added to any node, with an optional wrapper to make the code
  9. simpler.
  10. * CSS and JS may be added to any block, with an optional wrapper to make the
  11. code simpler.
  12. * A "noscript" code block may be added for nodes and blocks to display HTML if
  13. the visitor has disabled JS.
  14. * Control over which node view modes cause the CSS and JS to be loaded.
  15. * Control over whether the CSS and JS output is aggregated with other files.
  16. * Optional global CSS and JS that will be loaded on all non-admin pages.
  17. * Syntax highlighting for both CSS and JS using the CodeMirror library.
  18. * Optional support for Libraries API to control the location of the CodeMirror
  19. library.
  20. * Optional token replacement for node and block CSS and JS, if the Token module
  21. is installed a popup token browser will be available.
  22. * Optionally control the weight of the CSS and JS, allowing for exact
  23. positioning of each.
  24. * Integrate with the AdvAgg and Varnish modules to clear their respective caches
  25. when the CSS or JS are updated.
  26. Installation
  27. ------------------------------------------------------------------------------
  28. The module should be installed and enabled in the usual way.
  29. It is suggested to also install the CodeMirror library (v3.20 or newer) to
  30. provide syntax highlighting, etc. To install CodeMirror:
  31. 1. Download the latest package from http://codemirror.net/.
  32. 2. Extract the archive.
  33. 3. Ensure that the directory is named "codemirror" (case sensitive).
  34. 4. Move the directory to sites/all/libraries so that there is a file located
  35. at sites/all/libraries/codemirror/lib/codemirror.js.
  36. 5. If using the Libraries API module, it may be relocated as necessary.
  37. Configuration
  38. ------------------------------------------------------------------------------
  39. 1. On the People Permissions administration page ("Administer >> People
  40. >> Permissions") you need to assign:
  41. - The "Administer Code per Node" permission to the roles that are allowed to
  42. change the main settings and edit CSS or JS for individual nodes and
  43. blocks.
  44. - The "Edit CSS per node" permission to the roles that are allowed to add
  45. custom CSS for individual nodes.
  46. - The "Edit JS per node" permission to the roles that are allowed to add
  47. custom JavaScript for individual nodes.
  48. - The "Edit CSS per block" permission to the roles that are allowed to add
  49. custom CSS for individual blocks.
  50. - The "Edit JS per block" permission to the roles that are allowed to add
  51. custom JavaScript for individual blocks.
  52. 2. The main administrative page controls the site-wide settings, including the
  53. location of the custom files, whether aggregation is enabled, customize the
  54. code wrappers, and global CSS & JS:
  55. admin/config/content/cpn
  56. 3. Each content type can have the CSS & JS enabled on their respective edit
  57. page, along with custom code that will be loaded on each node page of that
  58. type.
  59. 4. Each node add & edit page, belonging to the content type(s) enabled in step
  60. 3 above, will have a new section called "CSS & JavaScript" containing the
  61. fields for entering the code.
  62. SECURITY WARNING
  63. ------------------------------------------------------------------------------
  64. BE VERY CAREFUL with the user roles that are granted access to insert custom CSS
  65. and JS, THERE IS NO SECURITY FILTERING APPLIED to the code so only grant access
  66. to it to people who are trusted.
  67. Troubleshooting / Tips
  68. ------------------------------------------------------------------------------
  69. * The CSS and JS will be automatically loaded on the appropriate pages, however
  70. nothing is added to make the CSS or JS only affect the elements of that node
  71. or block, so the code should be handled accordingly.
  72. * The CSS and JS wrapper options can be used to simplify the code that is
  73. necessary for each node or block, e.g. the following would allow all JS code
  74. to be written to just use the simpler $() syntax for JS selection:
  75. (function ($) {
  76. [code]
  77. })(jQuery);
  78. * The global CSS/JS options are meant for temporary adhoc changes, they are not
  79. a replacement for properly built code added to the site's theme.
  80. Related Modules
  81. ------------------------------------------------------------------------------
  82. Other modules provide related or similar functionality to CPN:
  83. * Panels CSS & JS
  84. https://www.drupal.org/project/panels_css_js
  85. Add CSS and JS to displays managed by Panels, Mini Panels, Panels Everywhere
  86. and Panelizer.
  87. Credits / Contact
  88. ------------------------------------------------------------------------------
  89. Originally build by joelstein [1], Rob Loach [2] contributed on the D7 port.
  90. Currently maintained by Damien McKenna [3].
  91. Continued development is sponsored by Mediacurrent [4].
  92. The best way to contact the authors is to submit an issue, be it a support
  93. request, a feature request or a bug report, in the project issue queue:
  94. http://drupal.org/project/issues/cpn
  95. References
  96. ------------------------------------------------------------------------------
  97. 1: http://drupal.org/user/61114
  98. 2: http://drupal.org/user/36598
  99. 3: http://drupal.org/user/108450
  100. 4: http://www.mediacurrent.com/