Module: ChiliPDF::Config
Constant Summary collapse
- PLUGIN_KEYNAME =
'plugin_chili_pdf'
- ENABLED_VALUE =
'1'
- DISABLED_VALUE =
'0'
- FOOTER_ENABLED_KEYNAME =
'footer_enabled'
- HEADER_ENABLED_KEYNAME =
'header_enabled'
- CUSTOM_CSS_KEYNAME =
'custom_css'
- CUSTOM_JS_KEYNAME =
'custom_javascript'
- HEADER_LEFT_KEYNAME =
:header_content_left
- HEADER_CENTER_KEYNAME =
:header_content_center
- HEADER_RIGHT_KEYNAME =
:header_content_right
- FOOTER_LEFT_KEYNAME =
:footer_content_left
- FOOTER_CENTER_KEYNAME =
:footer_content_center
- FOOTER_RIGHT_KEYNAME =
:footer_content_right
- LOGO_KEYNAME =
:watermarks_logo
- HEADER_LEFT_DEFAULT_VALUE =
'{{page_title}}'
- HEADER_CENTER_DEFAULT_VALUE =
''
- HEADER_RIGHT_DEFAULT_VALUE =
''
- FOOTER_LEFT_DEFAULT_VALUE =
'{{datestamp}}'
- FOOTER_CENTER_DEFAULT_VALUE =
''
- FOOTER_RIGHT_DEFAULT_VALUE =
'{{current_page}}/{{total_pages}}'
- CUSTOM_CSS_DEFAULT_VALUE =
<<END_OF_CSS_DEF <!-- stylesheet link example, uncomment & modify if you like --> <!-- <link href='/stylesheets/your_custom.css' rel='stylesheet' type='text/css' /> <!-- inline example --> <style type="text/css"> //#custom-pdf-styles h2 {color: red;} </style> END_OF_CSS_DEF
- CUSTOM_JS_DEFAULT_VALUE =
<<END_OF_JS_DEF <!-- Script tag link example. Uncomment & modify if you like. --> <!-- <script src='/javascripts/your_custom.js' type='text/javascript' /> <!-- Inline JavaScript example --> <script type="text/javascript"> // Your custom-inline JS here </script> END_OF_JS_DEF
Instance Method Summary collapse
- #custom_css ⇒ Object
- #custom_js ⇒ Object
- #defaults ⇒ Object
-
#footer_enabled? ⇒ Boolean
Public: Returns whether the footer will be printed when exporting a PDF.
- #footer_values ⇒ Object
-
#header_enabled? ⇒ Boolean
Public: Returns whether the header will be printed when exporting a PDF.
- #header_values ⇒ Object
- #logo_url ⇒ Object
- #logo_url? ⇒ Boolean
-
#update(options) ⇒ Object
Public: Accepts anything which responds to ‘[]’ and ‘.has_key?’ (ie: Hash-like objects).
Instance Method Details
#custom_css ⇒ Object
100 101 102 103 104 105 106 |
# File 'lib/chili_pdf/config.rb', line 100 def custom_css if plugin_settings[CUSTOM_CSS_KEYNAME].blank? CUSTOM_CSS_DEFAULT_VALUE else plugin_settings[CUSTOM_CSS_KEYNAME] end end |
#custom_js ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/chili_pdf/config.rb', line 108 def custom_js if plugin_settings[CUSTOM_JS_KEYNAME].blank? CUSTOM_JS_DEFAULT_VALUE else plugin_settings[CUSTOM_JS_KEYNAME] end end |
#defaults ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/chili_pdf/config.rb', line 47 def defaults { FOOTER_ENABLED_KEYNAME => ENABLED_VALUE, HEADER_ENABLED_KEYNAME => ENABLED_VALUE, HEADER_LEFT_KEYNAME => HEADER_LEFT_DEFAULT_VALUE, HEADER_CENTER_KEYNAME => HEADER_CENTER_DEFAULT_VALUE, HEADER_RIGHT_KEYNAME => HEADER_RIGHT_DEFAULT_VALUE, FOOTER_LEFT_KEYNAME => FOOTER_LEFT_DEFAULT_VALUE, FOOTER_CENTER_KEYNAME => FOOTER_CENTER_DEFAULT_VALUE, FOOTER_RIGHT_KEYNAME => FOOTER_RIGHT_DEFAULT_VALUE, CUSTOM_CSS_KEYNAME => CUSTOM_CSS_DEFAULT_VALUE, CUSTOM_JS_KEYNAME => CUSTOM_JS_DEFAULT_VALUE, LOGO_KEYNAME => '' } end |
#footer_enabled? ⇒ Boolean
Public: Returns whether the footer will be printed when exporting
a PDF.
Returns either true or false.
67 68 69 |
# File 'lib/chili_pdf/config.rb', line 67 def == ENABLED_VALUE end |
#footer_values ⇒ Object
96 97 98 |
# File 'lib/chili_pdf/config.rb', line 96 def .merge() end |
#header_enabled? ⇒ Boolean
Public: Returns whether the header will be printed when exporting
a PDF.
Returns either true or false.
75 76 77 |
# File 'lib/chili_pdf/config.rb', line 75 def header_enabled? header_enabled == ENABLED_VALUE end |
#header_values ⇒ Object
92 93 94 |
# File 'lib/chili_pdf/config.rb', line 92 def header_values default_header_values.merge(stored_header_settings) end |
#logo_url ⇒ Object
116 117 118 |
# File 'lib/chili_pdf/config.rb', line 116 def logo_url plugin_settings[LOGO_KEYNAME] end |
#logo_url? ⇒ Boolean
120 121 122 |
# File 'lib/chili_pdf/config.rb', line 120 def logo_url? !logo_url.blank? end |
#update(options) ⇒ Object
Public: Accepts anything which responds to ‘[]’ and ‘.has_key?’
(ie: Hash-like objects)
Utilizes following keys (values of):
- HEADER_ENABLED_KEYNAME
- FOOTER_ENABLED_KEYNAME
Returns true. Always.
87 88 89 90 |
# File 'lib/chili_pdf/config.rb', line 87 def update() Setting[PLUGIN_KEYNAME] = defaults.merge() true end |