├── .gitignore ├── LICENSE ├── README.md └── custom_css ├── custom_css.meta └── custom_css.php /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.toptal.com/developers/gitignore/api/netbeans,phpstorm,notepadpp,visualstudiocode 3 | # Edit at https://www.toptal.com/developers/gitignore?templates=netbeans,phpstorm,notepadpp,visualstudiocode 4 | 5 | ### NetBeans ### 6 | **/nbproject/private/ 7 | **/nbproject/Makefile-*.mk 8 | **/nbproject/Package-*.bash 9 | build/ 10 | nbbuild/ 11 | dist/ 12 | nbdist/ 13 | .nb-gradle/ 14 | 15 | ### NotepadPP ### 16 | # Notepad++ backups # 17 | *.bak 18 | 19 | ### PhpStorm ### 20 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider 21 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 22 | 23 | # User-specific stuff 24 | .idea/**/workspace.xml 25 | .idea/**/tasks.xml 26 | .idea/**/usage.statistics.xml 27 | .idea/**/dictionaries 28 | .idea/**/shelf 29 | 30 | # Generated files 31 | .idea/**/contentModel.xml 32 | 33 | # Sensitive or high-churn files 34 | .idea/**/dataSources/ 35 | .idea/**/dataSources.ids 36 | .idea/**/dataSources.local.xml 37 | .idea/**/sqlDataSources.xml 38 | .idea/**/dynamic.xml 39 | .idea/**/uiDesigner.xml 40 | .idea/**/dbnavigator.xml 41 | 42 | # Gradle 43 | .idea/**/gradle.xml 44 | .idea/**/libraries 45 | 46 | # Gradle and Maven with auto-import 47 | # When using Gradle or Maven with auto-import, you should exclude module files, 48 | # since they will be recreated, and may cause churn. Uncomment if using 49 | # auto-import. 50 | # .idea/artifacts 51 | # .idea/compiler.xml 52 | # .idea/jarRepositories.xml 53 | # .idea/modules.xml 54 | # .idea/*.iml 55 | # .idea/modules 56 | # *.iml 57 | # *.ipr 58 | 59 | # CMake 60 | cmake-build-*/ 61 | 62 | # Mongo Explorer plugin 63 | .idea/**/mongoSettings.xml 64 | 65 | # File-based project format 66 | *.iws 67 | 68 | # IntelliJ 69 | out/ 70 | 71 | # mpeltonen/sbt-idea plugin 72 | .idea_modules/ 73 | 74 | # JIRA plugin 75 | atlassian-ide-plugin.xml 76 | 77 | # Cursive Clojure plugin 78 | .idea/replstate.xml 79 | 80 | # Crashlytics plugin (for Android Studio and IntelliJ) 81 | com_crashlytics_export_strings.xml 82 | crashlytics.properties 83 | crashlytics-build.properties 84 | fabric.properties 85 | 86 | # Editor-based Rest Client 87 | .idea/httpRequests 88 | 89 | # Android studio 3.1+ serialized cache file 90 | .idea/caches/build_file_checksums.ser 91 | 92 | ### PhpStorm Patch ### 93 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 94 | 95 | # *.iml 96 | # modules.xml 97 | # .idea/misc.xml 98 | # *.ipr 99 | 100 | # Sonarlint plugin 101 | # https://plugins.jetbrains.com/plugin/7973-sonarlint 102 | .idea/**/sonarlint/ 103 | 104 | # SonarQube Plugin 105 | # https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin 106 | .idea/**/sonarIssues.xml 107 | 108 | # Markdown Navigator plugin 109 | # https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced 110 | .idea/**/markdown-navigator.xml 111 | .idea/**/markdown-navigator-enh.xml 112 | .idea/**/markdown-navigator/ 113 | 114 | # Cache file creation bug 115 | # See https://youtrack.jetbrains.com/issue/JBR-2257 116 | .idea/$CACHE_FILE$ 117 | 118 | # CodeStream plugin 119 | # https://plugins.jetbrains.com/plugin/12206-codestream 120 | .idea/codestream.xml 121 | 122 | ### VisualStudioCode ### 123 | .vscode/* 124 | !.vscode/settings.json 125 | !.vscode/tasks.json 126 | !.vscode/launch.json 127 | !.vscode/extensions.json 128 | *.code-workspace 129 | 130 | ### VisualStudioCode Patch ### 131 | # Ignore all local history of files 132 | .history 133 | 134 | # End of https://www.toptal.com/developers/gitignore/api/netbeans,phpstorm,notepadpp,visualstudiocode 135 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Shaarli Custom CSS Plugin 2 | 3 | [Shaarli](https://github.com/shaarli/Shaarli) plugin to customize the look and feel of the UI with custom CSS rules. 4 | 5 | Tested on Shaarli 0.12.0-beta with the default theme but it should work with the [Shaarli-Material](https://github.com/kalvn/Shaarli-Material) and all [built-in themes](https://github.com/shaarli/Shaarli/tree/master/tpl/) as well. 6 | 7 | ## Features 8 | 9 | * Set up your custom CSS rules on the Plugin Administration page for easy configuration 10 | 11 | ## Installation 12 | 13 | The plugin's folder (`custom_css`) should be placed in the `/plugins/` directory. 14 | 15 | The directory structure should look like: 16 | 17 | ```bash 18 | └── plugins 19 | └── custom_css 20 | ├── custom_css.html 21 | ├── custom_css.meta 22 | └── custom_css.php 23 | ``` 24 | 25 | To enable the plugin, just check it in the Plugin Administration page (`?do=pluginadmin`). 26 | 27 | You can also add `custom_css` to your list of enabled plugins in `data/config.json.php`. 28 | The `general.enabled_plugins` list should look like then: 29 | 30 | ``` 31 | "general": { 32 | "enabled_plugins": [ 33 | ...other_plugins_above, 34 | "custom_css" 35 | ], 36 | } 37 | ``` 38 | 39 | ## Configuration 40 | 41 | Go to the Plugin Administration page, and edit the following settings (with the plugin enabled). 42 | 43 | * **CUSTOM_CSS**: 44 | *Your CSS as one huge line. Default empty* 45 | Example value: `.some-class { color: red; font-size: 1.2em } .another-class { margin: 0; }` 46 | Supported values: any string (without validation!), defaults to empty. 47 | 48 | > Note: this setting can also be set in `data/config.json.php`, in the `plugins` section: 49 | 50 | ``` 51 | "general": { 52 | "plugins": { 53 | "CUSTOM_CSS": ".some-class { color: red; font-size: 1.2em } .another-class { margin: 0; }", 54 | [...] 55 | }, 56 | } 57 | ``` 58 | 59 | ## Known issues 60 | 61 | - :warning: There is no validation on the CSS file contents upon saving and loading! Your only "protection" against a self-[XSS](https://en.wikipedia.org/wiki/Cross-site_scripting) attack is the `rel="stylesheet"` attribute on the link. It should be enough but please consider your attack vector. 62 | 63 | ## Recommendations 64 | 65 | Put this plugin to the bottom of the enabled plugins list either in the config JSON file or via the administration UI. This lets you redefine other plugins CSS rules as well. 66 | 67 | An example CSS you can try out for starting customizations over the default theme: `.linklist-item, .linklist-item-title, .linklist-item-infos, .page-form, .page-form .window-title, .linksperpage a, .linklist-filters .filter-off, .linksperpage input[type="text"], .searchform-block input[type="text"] { background: #fff } .linklist-item-infos-url { display: none } .linklist-item-infos-dateblock { width: 100% } .linklist-item-title h2 { line-height: 1em; padding: 0.3em 10px 0.3em } .linklist-item-infos .label-tag { background: #f4f4f4; } .label-tag a { color: #595959 } .linklist-item-infos .linklist-item-tags { font-size: .8em; padding: 0.2em 0 0.7em; }` 68 | 69 | Shaarli Custom CSS works best with my [Shaarli Markdown Toolbar](https://github.com/immanuelfodor/shaarli-markdown-toolbar) plugin, check it out, too! 😉 70 | 71 | ## Contact 72 | 73 | Immánuel Fodor 74 | [fodor.it](https://fodor.it/shaarlifactorit) | [Linkedin](https://fodor.it/shaarlifactorin) 75 | -------------------------------------------------------------------------------- /custom_css/custom_css.meta: -------------------------------------------------------------------------------- 1 | description="Customizer plugin to add your own CSS rules to the header of every page." 2 | parameters="CUSTOM_CSS" 3 | parameter.CUSTOM_CSS="Your CSS as one huge line. Default empty" -------------------------------------------------------------------------------- /custom_css/custom_css.php: -------------------------------------------------------------------------------- 1 | get('resource.data_dir') . '/custom_css.css'; 34 | 35 | if (file_exists($customCss)) { 36 | $data['css_files'][] = $customCss; 37 | } 38 | 39 | return $data; 40 | } 41 | 42 | /** 43 | * When plugin parameters are saved. 44 | * 45 | * @see https://shaarli.readthedocs.io/en/master/Plugin-System/#save_plugin_parameters 46 | * 47 | * @param array $data - $_POST array 48 | * @param ConfigManager $conf - configmanager instance 49 | * 50 | * @return array Updated $_POST array 51 | */ 52 | function hook_custom_css_save_plugin_parameters($data, $conf) 53 | { 54 | $customCss = ''; 55 | 56 | if (!empty($data['CUSTOM_CSS'])) { 57 | $customCss = $data['CUSTOM_CSS']; 58 | } 59 | 60 | file_put_contents($conf->get('resource.data_dir') . '/custom_css.css', $customCss); 61 | 62 | return $data; 63 | } 64 | 65 | 66 | /** 67 | * This function is never called, but contains translation calls for GNU gettext extraction. 68 | */ 69 | function custom_css_dummy_translation() 70 | { 71 | // meta 72 | t('Customizer plugin to add your own CSS rules to the header of every page.'); 73 | t('Your CSS as one huge line. Default empty'); 74 | } 75 | --------------------------------------------------------------------------------