├── .github └── ISSUE_TEMPLATE │ └── issue-template.md ├── Dockerfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── app ├── controllers │ ├── banner_controller.rb │ ├── banners │ │ └── api │ │ │ └── global_banner_controller.rb │ └── global_banner_controller.rb ├── models │ ├── banner.rb │ └── global_banner.rb └── views │ ├── banner │ ├── _body_bottom.html.erb │ ├── _off.erb │ ├── _project_banner_off.erb │ ├── _project_body_bottom.html.erb │ └── show.html.erb │ └── global_banner │ └── show.html.erb ├── assets ├── images │ ├── alert-msg.png │ ├── alert.png │ ├── banner-screenshot.png │ ├── close.png │ ├── edit.png │ ├── icon-timer.png │ ├── info.png │ └── warn.png ├── javascripts │ └── banner.js └── stylesheets │ └── banner.css ├── config ├── locales │ ├── bg.yml │ ├── de.yml │ ├── en.yml │ ├── es.yml │ ├── fr.yml │ ├── it.yml │ ├── ja.yml │ ├── ko.yml │ ├── nl.yml │ ├── pt-BR.yml │ ├── ru.yml │ ├── tr.yml │ └── zh.yml └── routes.rb ├── db └── migrate │ ├── 001_create_banners.rb │ ├── 002_rename_column_type.rb │ ├── 003_add_display_part_to_banners.rb │ ├── 004_change_column_style.rb │ └── 005_change_column_banner_description.rb ├── docker-compose.yml ├── init.rb ├── lang └── en.yml └── lib ├── banners └── banner_header_hooks.rb └── tasks └── test.rake /.github/ISSUE_TEMPLATE/issue-template.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | This is a template to report a bug related to the Redmine issue templates plugin. 11 | You can fill in any format, freestyle in case report features or questions. 12 | 13 | ## Summary 14 | 15 | 16 | ## Description 17 | 18 | 19 | ## Environment 20 | 21 | This information is greatly helpful to support quickly. 22 | You can get this information from Redmine's information page. 23 | (E.g. http://example.com/admin/info) 24 | 25 | - Redmine version 26 | - Installed plugins 27 | - Ruby version 28 | - OS Platform 29 | - Database (MariaDB, MySQL, PostgreSQL) and its version 30 | - Rails Env 31 | 32 | 33 | ## Visual Proof / Screenshot 34 | 35 | When reporting an application error, post the error stack trace that you should find in the **log file** (eg. log/production.log). 36 | 37 | A screenshot would be also helpful. 38 | 39 | 40 | ## Expected Results 41 | 42 | ## Actual Results 43 | 44 | ## Workaround 45 | 46 | Please let me know if you have any workaround. 47 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # 2 | # docker build --build-arg=COMMIT=$(git rev-parse --short HEAD) \ 3 | # --build-arg=BRANCH=$(git name-rev --name-only HEAD) -t akiko/redmine_banner:latest . 4 | # 5 | # 6 | FROM ruby:2.5 7 | LABEL maintainer="AKIKO TAKANO / (Twitter: @akiko_pusu)" \ 8 | description="Image to run Redmine simply with sqlite to try/review plugin." 9 | 10 | ARG BRANCH="master" 11 | ARG COMMIT="commit_sha" 12 | 13 | ENV COMMIT_SHA=${COMMIT} 14 | ENV COMMIT_BRANCH=${BRANCH} 15 | 16 | RUN mkdir /app 17 | 18 | ### get Redmine source 19 | ### Replace shell with bash so we can source files ### 20 | RUN rm /bin/sh && ln -s /bin/bash /bin/sh 21 | 22 | ### install default sys packeges ### 23 | 24 | RUN apt-get update 25 | RUN apt-get install -qq -y --no-install-recommends \ 26 | git vim subversion \ 27 | sqlite3 && rm -rf /var/lib/apt/lists/* 28 | 29 | RUN cd /app && svn co http://svn.redmine.org/redmine/branches/4.0-stable/ redmine 30 | WORKDIR /app/redmine 31 | 32 | COPY . /app/redmine/plugins/redmine_banner/ 33 | 34 | # add database.yml (for development, development with mysql, test) 35 | RUN echo $'test:\n\ 36 | adapter: sqlite3\n\ 37 | database: /app/data/redmine_test.sqlite3\n\ 38 | encoding: utf8mb4\n\ 39 | development:\n\ 40 | adapter: sqlite3\n\ 41 | database: /app/data/redmine_development.sqlite3\n\ 42 | encoding: utf8mb4\n'\ 43 | >> config/database.yml 44 | 45 | RUN gem update bundler 46 | RUN bundle install --without postgresql rmagick mysql 47 | RUN bundle exec rake db:migrate && bundle exec rake redmine:plugins:migrate \ 48 | && bundle exec rake generate_secret_token 49 | RUN bundle exec rails runner \ 50 | "Setting.send('plugin_redmine_banner=', {enable: 'true', type: 'info', display_part: 'both', banner_description: 'This is a test message for Global Banner. (${COMMIT_BRANCH}:${COMMIT_SHA})'}.stringify_keys)" 51 | 52 | # Change Admin's password to 'redmine_banner_${COMMIT_SHA}' 53 | # Default is 'redmine_banner_commit_sha' 54 | RUN bundle exec rails runner \ 55 | "User.find_by_login('admin').update!(password: 'redmine_banner_${COMMIT_SHA}', must_change_passwd: false)" 56 | 57 | EXPOSE 3000 58 | RUN ls /app/redmine 59 | CMD ["rails", "server", "-b", "0.0.0.0"] 60 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Redmine Banner Plugin 2 | 3 | Plugin to show site-wide message from site administrator, such as maintenance 4 | information or notifications. 5 | 6 | [![Plugin info at redmine.org](https://img.shields.io/badge/Redmine-plugin-green.svg?)](http://www.redmine.org/plugins/redmine_banner) 7 | [![CircleCI](https://circleci.com/gh/akiko-pusu/redmine_banner/tree/master.svg?style=shield)](https://circleci.com/gh/akiko-pusu/redmine_banner/tree/master) 8 | [![Sider](https://img.shields.io/badge/Special%20Thanks!-Sider-blue.svg?)](https://sider.review/features) 9 | 10 | 11 | 12 | ## Plugin installation 13 | 14 | 1. Copy the plugin directory into the $REDMINE_ROOT/plugins directory. Please 15 | note that plugin's folder name should be **"redmine_banner"**. If 16 | changed, some migration task will be failed. 17 | 2. Do migration task. 18 | 19 | e.g. rake redmine:plugins:migrate RAILS_ENV=production 20 | 21 | 3. (Re)Start Redmine. 22 | 23 | ## Uninstall 24 | 25 | Try this: 26 | 27 | * rake redmine:plugins:migrate NAME=redmine_banner VERSION=0 28 | RAILS_ENV=production 29 | 30 | ## Usage for site wide banner 31 | 32 | 1. Go to plugin's page and click "Settings" link of Redmine Banner Plugin. 33 | You can edit banner message and select style for message. Also you can access setting page from administration menu, click "banner" icon. 34 | 35 | ### Usage for project scope banner 36 | 37 | 1. Banner can be used as project module. If you want to manage the banner for your project, "Manage Banner" permission is required to your role. 38 | 39 | 2. Go to project settings tab and check "Banner" as project module. 40 | 3. Then you can see "Banner" tab on project settings page. 41 | 42 | ### Current limitations 43 | 44 | 1. Banner for each project does not support timer. 45 | 2. Banner for each project is located at the top of the project only. (Not support footer) 46 | 47 | ### Note 48 | 49 | Please use ver **0.1.x** or ``v0.1.x-support-Redmine3`` branch in case using Redmine3.x. 50 | 51 | ## Changelog 52 | 53 | ### 0.3.4 54 | 55 | Maintenance release. 56 | 57 | * Update German translation. (GutHub: #142 by @teatower) 58 | 59 | ### 0.3.3 60 | 61 | This is bugfix release against 0.3.2. 62 | Updating to 0.3.3 is highly recommended! 63 | 64 | * Bugfix: HTML problems on redmine_banner. 65 | * Bugfix: Fix wrong url to project banner setting. 66 | *Refactor: Remove unused file. 67 | 68 | ### 0.3.2 69 | 70 | This is bugfix release against 0.3.1. 71 | Updating to 0.3.2 is highly recommended! 72 | 73 | * Bugfix: HTML problems on redmine_banner 0.3.1. (#134) 74 | * Bugfix: Global banner off does not work correctly. (Degrade from v0.2x) 75 | * Update Chinese translation. (GutHub: #131 by iWangJiaxiang) 76 | 77 | ### 0.3.1 78 | 79 | * Feature: Enabled to switch who can see the global banner. (#126) 80 | * Refactor: Change to use project menu to prevent the project setting tab's conflict. (#127) 81 | ### 0.3.1 82 | 83 | * Feature: Enabled to switch who can see the global banner. (#126) 84 | * Refactor: Change to use project menu to prevent the project setting tab's conflict. (#127) 85 | 86 | ### 0.3.0 87 | 88 | * Add feature: Give the ability to specific users to manage the site-wide banner. (GitHub: #86 / #113) 89 | * Administrator can assign a group to manage global banner via UI. 90 | * Code refactoring for maintainability. 91 | * Change not to use SettingsController's patch to the update global banner. 92 | 93 | ### 0.2.2 94 | 95 | This is bugfix release against 0.2.1. 96 | Updating to 0.2.2 is highly recommended! 97 | 98 | * Fix: Prevent conflict with other plugins. (GitHub: #121) 99 | * French translation update by sparunakian (GitHub: #117) 100 | 101 | ### 0.2.1 102 | 103 | * Fix: Prevent conflict with CKEditor. (GitHub: #111) 104 | * Code refactoring. 105 | * Add feature to update Global Banner via API. (Alpha / Related: #86 #113) 106 | * Not only Redmine admin but also user who assigned group named **GlobalBanner_Admin** can also update Global banner via API. 107 | * Even prptotype version. 108 | * Please see [swagger.yml](script/swagger.yml) to try update global banner via API. 109 | * Update CI Setting 110 | * Add step to build and push image to AWS ECR. 111 | * Add steps to build and deploy to Heroku Container registry as release container service. 112 | * Add how to try banner via Docker in README. 113 | 114 | ### 0.2.0 115 | 116 | * Support Redmine 4.x. 117 | * Now master branch **unsupports** Redmine 3.x. 118 | * Please use ver **0.1.x** or ``v0.1.x-support-Redmine3`` branch in case using Redmine3.x. 119 | * 120 | * Follow Redmine's preview option to the wiki toolbar. 121 | 122 | NOTE: Mainly, maintenance, bugfix and refactoring only. There is no additional feature, translation in this release. 123 | 124 | ### 0.1.2 125 | 126 | * Fix style and css selector. (Github: #45) 127 | * Change global banner style for responsive mode. (Github: #68) 128 | * Code refactoring. 129 | * Fix: Prevent deprecation warning. (Github PR: #60) Thanks, Wojciech. 130 | * Refactor: Rename file to prevent conflict (Github #63 / r-labs: 54). 131 | * i18n: Update Italian translation file. (Github: #61 / r-labs: 57) Thanks, R-i-c-k-y. 132 | * i18n: Add Spanish translation file. (Github: #61 / r-labs: 52) Thanks Picazamora! 133 | * i18n: Update Turkish translation file. (Github: #64) Thank you so much, Adnan. 134 | * i18n: Update Portuguese translation file. (Github: #50) Thanks, Guilherme. 135 | 136 | ### 0.1.1 137 | 138 | * Support Redmine 3.x. 139 | * Update some translation files. Bulgarian, German. Thank you so much, Ivan Cenov, Daniel Felix. 140 | * Change column type of banner_description from string to text.Thank you so much Namezero. (#44) 141 | 142 | ### 0.1.0 143 | 144 | * Fixed bug: Global banner timer does not work. (r-labs: #1337) 145 | * Feature: Add related link field for more information to Global Banner. (r-labs: #1339) 146 | * i18n: Update Korean translation file. (r-labs: #1329) Thank you so much, Ki Won Kim. 147 | 148 | ### 0.0.9 149 | 150 | * Authenticated users can turn off global banner in their session. 151 | * Add option to show global banner only for authenticated users. 152 | * Add option to show only at the login page. 153 | * Code refactoring. 154 | * Italian translation was contributed by @R-i-c-k-y. 155 | * French translation was contributed by Laurent HADJADJ. 156 | 157 | ### 0.0.8 158 | 159 | * Support Redmine 2.1. (Redmine 2.0.x is no longer supported. Please use version 0.0.7 for Redmine 2.0.x) 160 | 161 | ### 0.0.7 162 | 163 | * Compatible with Redmine 2.0.0 164 | 165 | ### 0.0.6 166 | 167 | * Fixed bug: Project banner should be off when module turned disabled. 168 | * Fixed bug: In some situation, "ActionView::TemplateError undefined method is_action_to_display" is happened. 169 | * Update Russian Translation. Thank you so much, Александр Ананьев. 170 | 171 | ### 0.0.5 172 | 173 | * Support banner for each project. Thank you so much, Denny Schäfer, Haru Iida. 174 | 175 | ### 0.0.4 176 | 177 | * Support timer function. 178 | * Add links to turn off or modify banner message quickly. (Links are shown to Administrator only) 179 | 180 | ### 0.0.3 181 | 182 | * Code refactoring. Stop to override base.rhtml and use javascript. Great thanks, Haru Iida-san. Also, remove some "To-Do" section of README. 183 | 184 | * Add translations. Russian, German, Brazilian Portugues. Thank you so much, Александр Ананьев, Denny Schäfer, Maiko de Andrade! 185 | 186 | ### 0.0.2 187 | 188 | * Support i18n. 189 | 190 | ### 0.0.1 191 | 192 | * First release 193 | 194 | ### Quick try with using Docker 195 | 196 | You can try quickly this plugin with Docker environment. 197 | Please try: 198 | 199 | ```bash 200 | # Admin password is 'redmine_banner_commit_sha' 201 | % git clone https://github.com/akiko-pusu/redmine_banner 202 | % cd redmine_banner 203 | % docker-compose up web -d 204 | 205 | # or 206 | # 207 | # Admin password is 'redmine_banner_{COMMIT}' 208 | % docker build --build-arg=COMMIT=$(git rev-parse --short HEAD) \ 209 | --build-arg=BRANCH=$(git name-rev --name-only HEAD) -t akiko/redmine_banner:latest . 210 | 211 | % docker run -p 3000:3000 akiko/redmine_banner:latest 212 | ``` 213 | 214 | ### Run test 215 | 216 | Please see wercker.yml for more details. 217 | 218 | ```bash 219 | % cd REDMINE_ROOT_DIR 220 | % cp plugins/redmine_banner/Gemfile.local plugins/redmine_banner/Gemfile 221 | % bundle install --with test 222 | % export RAILS_ENV=test 223 | % bundle exec ruby -I"lib:test" -I plugins/redmine_banner/test \ 224 | plugins/redmine_banner/test/functional/banner_controller_test.rb 225 | ``` 226 | 227 | or 228 | 229 | ```bash 230 | % bundle exec rails redmine_banner:test 231 | ``` 232 | 233 | ### Repository 234 | 235 | * 236 | 237 | ### WebPage 238 | 239 | * (Project Page) 240 | 241 | ### License 242 | 243 | This software is licensed under the GNU GPL v2. See COPYRIGHT and COPYING for 244 | details. 245 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | require 'rake/testtask' 3 | require 'yard' 4 | 5 | desc 'Default: run unit tests.' 6 | task :default => :test 7 | 8 | desc 'Test the redmine_banner plugin.' 9 | Rake::TestTask.new(:test) do |t| 10 | t.libs << 'lib' 11 | t.pattern = 'test/**/*_test.rb' 12 | t.verbose = true 13 | end 14 | 15 | YARD::Rake::YardocTask.new(:yardoc) do |t| 16 | files = ['lib/**/*.rb', 'app/**/*.rb'] #exclude test file 17 | t.files = files 18 | t.options += ['--output-dir', './doc'] 19 | end 20 | -------------------------------------------------------------------------------- /app/controllers/banner_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class BannerController < ApplicationController 4 | # 5 | # NOTE: Authorized user can turn off banner while their in session. (Changed from version 0.0.9) 6 | # If Administrator hope to disable site wide banner, please go to settings page and uncheck 7 | # eabned checkbox. 8 | before_action :require_login, only: [:off] 9 | before_action :find_user, :find_project, :authorize, except: %i[preview off] 10 | 11 | def preview 12 | @text = params[:setting][:banner_description] 13 | render partial: 'common/preview' 14 | end 15 | 16 | # 17 | # Turn off (hide) banner while in user's session. 18 | # 19 | def off 20 | session[:pref_banner_off] = Time.now.to_i 21 | render action: '_off', layout: false 22 | rescue StandardError => e 23 | logger&.warn("Message for the log file / When off banner #{e.message}") 24 | render text: '' 25 | end 26 | 27 | def project_banner_off 28 | @banner = Banner.find_or_create(@project.id) 29 | @banner.enabled = false 30 | @banner.save 31 | render action: '_project_banner_off', layout: false 32 | end 33 | 34 | def show 35 | @banner = Banner.find_or_create(@project.id) 36 | render layout: !request.xhr? 37 | end 38 | 39 | def edit 40 | return if params[:setting].nil? 41 | 42 | @banner = Banner.find_or_create(@project.id) 43 | @banner.safe_attributes = banner_params 44 | 45 | if @banner.save 46 | flash[:notice] = l(:notice_successful_update) 47 | else 48 | flash[:error] = @banner.errors.messages 49 | end 50 | redirect_to action: 'show' 51 | nil 52 | end 53 | 54 | private 55 | 56 | def find_user 57 | @user = User.current 58 | end 59 | 60 | def find_project 61 | @project = Project.find(params[:project_id]) 62 | rescue ActiveRecord::RecordNotFound 63 | render_404 64 | end 65 | 66 | def banner_params 67 | params.require(:setting).permit('banner_description', 'style', 'start_date', 'end_date', 'enabled', 'use_timer', 'display_part') 68 | end 69 | end 70 | -------------------------------------------------------------------------------- /app/controllers/banners/api/global_banner_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Banners 4 | module Api 5 | class GlobalBannerController < ApplicationController 6 | before_action :require_login, :require_banner_admin 7 | accept_api_auth :show, :register_banner 8 | 9 | def show 10 | render json: global_banner_json 11 | end 12 | 13 | def register_banner 14 | begin 15 | global_banner_params = build_params 16 | rescue ActionController::ParameterMissing, ActionController::UnpermittedParameters => e 17 | response_bad_request(e.message) && (return) 18 | end 19 | 20 | global_banner = GlobalBanner.find_or_default 21 | global_banner.merge_value(global_banner_params.stringify_keys) 22 | 23 | if global_banner.save 24 | render status: :ok, json: { status: 'OK', message: 'updating the global banner' } 25 | else 26 | response_bad_request("Can't save data to settings table.") 27 | end 28 | rescue StandardError => e 29 | response_internal_server_error(e.message) 30 | end 31 | 32 | private 33 | 34 | def build_params 35 | keys = GlobalBanner::GLOBAL_BANNER_DEFAULT_SETTING.stringify_keys.keys 36 | 37 | unless User.current.admin? 38 | keys.delete('banner_admin') 39 | end 40 | 41 | params.require(:global_banner).permit(keys) 42 | end 43 | 44 | def global_banner_json 45 | { global_banner: GlobalBanner.find_or_default.value } 46 | end 47 | 48 | # 400 Bad Request 49 | def response_bad_request(error_message = nil) 50 | json_data = { status: 400, message: 'Bad Request' } 51 | json_data[:reason] = error_message if error_message.present? 52 | logger&.warn("Global Banner Update failed. Caused: #{json_data}") 53 | 54 | render status: :bad_request, json: json_data 55 | end 56 | 57 | # 401 Unauthorized 58 | def response_unauthorized 59 | render status: :unauthorized, json: { status: 401, message: 'Unauthorized' } 60 | end 61 | 62 | # 500 Internal Server Error 63 | def response_internal_server_error(error_message = nil) 64 | json_data = { status: 500, message: 'Internal Server Error' } 65 | json_data[:reason] = error_message if error_message.present? 66 | logger&.warn("Global Banner Update failed. Caused: #{json_data}") 67 | 68 | render status: :internal_server_error, json: json_data 69 | end 70 | 71 | def require_banner_admin 72 | return if User.current.admin? || banner_admin?(User.current) 73 | 74 | response_unauthorized 75 | end 76 | 77 | def banner_admin?(user) 78 | GlobalBanner.banner_admin?(user) 79 | end 80 | end 81 | end 82 | end 83 | -------------------------------------------------------------------------------- /app/controllers/global_banner_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class GlobalBannerController < ApplicationController 4 | before_action :require_login, :require_banner_admin 5 | 6 | def show 7 | global_banner = GlobalBanner.find_or_default 8 | render layout: !request.xhr?, locals: setting_values(global_banner) 9 | end 10 | 11 | def update 12 | global_banner = GlobalBanner.find_or_default 13 | 14 | begin 15 | global_banner_params = build_params 16 | rescue ActionController::ParameterMissing, ActionController::UnpermittedParameters => e 17 | response_bad_request(e.message) && (return) 18 | end 19 | 20 | global_banner.merge_value(global_banner_params.stringify_keys) 21 | 22 | unless global_banner.valid_date_range? && global_banner.save 23 | flash[:error] = l(:error_banner_date_range) 24 | redirect_to action: 'show' 25 | return 26 | end 27 | 28 | flash[:notice] = l(:notice_successful_update) 29 | redirect_to action: 'show' 30 | nil 31 | end 32 | 33 | private 34 | 35 | def require_banner_admin 36 | return if User.current.admin? || GlobalBanner.banner_admin?(User.current) 37 | 38 | render_403 39 | false 40 | end 41 | 42 | def build_params 43 | keys = GlobalBanner::GLOBAL_BANNER_DEFAULT_SETTING.stringify_keys.keys 44 | 45 | unless User.current.admin? 46 | keys.delete('banner_admin') 47 | end 48 | 49 | params.require(:setting).permit(keys) 50 | end 51 | 52 | def setting_values(instance) 53 | setting = instance.value 54 | 55 | current_time = Time.zone.now 56 | use_timer = instance.use_timer? 57 | 58 | begin 59 | # date range check 60 | start_datetime = instance.start_time 61 | end_datetime = instance.end_time 62 | rescue ArgumentError 63 | # Ref. https://github.com/akiko-pusu/redmine_banner/issues/11 64 | start_datetime = current_time 65 | end_datetime = current_time 66 | use_timer = false 67 | end 68 | 69 | banner_description = setting[:banner_description] 70 | 71 | if banner_description.respond_to?(:force_encoding) 72 | setting[:banner_description] = banner_description.force_encoding('UTF-8') 73 | end 74 | 75 | { 76 | setting: setting.stringify_keys, 77 | start_datetime: start_datetime, 78 | end_datetime: end_datetime, 79 | use_timer: use_timer, 80 | banner_updated_on: instance&.updated_on&.localtime 81 | } 82 | end 83 | end 84 | -------------------------------------------------------------------------------- /app/models/banner.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Banner < ActiveRecord::Base 4 | include Redmine::SafeAttributes 5 | belongs_to :project 6 | 7 | validates :project_id, uniqueness: true 8 | validates :project_id, presence: true 9 | validates :display_part, inclusion: { in: %w[all new_issue overview overview_and_issues] } 10 | validates :style, inclusion: { in: %w[info warn alert normal nodata] } 11 | # project should be stable. 12 | safe_attributes 'banner_description', 'style', 'start_date', 'end_date', 'enabled', 'use_timer', 'display_part' 13 | 14 | def self.find_or_create(project_id) 15 | banner = Banner.find_by(project_id: project_id) 16 | if banner.blank? 17 | banner = Banner.new 18 | banner.project_id = project_id 19 | banner.enabled = false 20 | 21 | # Set default (Also set default by migration file) 22 | banner.display_part = 'all' 23 | banner.style = 'info' 24 | banner.save! 25 | end 26 | banner 27 | end 28 | 29 | def enable_banner? 30 | return true if enabled == true && banner_description.present? 31 | 32 | false 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /app/models/global_banner.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class GlobalBanner < Setting 4 | # Default 5 | GLOBAL_BANNER_ADMIN_GROUP = 'GlobalBanner_Admin' 6 | 7 | GLOBAL_BANNER_DEFAULT_SETTING = { 8 | enable: 'false', 9 | banner_description: 'exp. Information about upcoming Service Interruption.', 10 | display_for: 'all', 11 | display_only_login_page: nil, 12 | type: 'info', 13 | display_part: 'both', 14 | use_timer: 'false', 15 | start_ymd: nil, 16 | start_hour: nil, 17 | start_min: nil, 18 | end_ymd: nil, 19 | end_hour: nil, 20 | end_min: nil, 21 | related_link: nil, 22 | banner_admin: nil 23 | }.freeze 24 | 25 | # Class method 26 | # 27 | class << self 28 | def find_or_default 29 | super('plugin_redmine_banner') 30 | end 31 | 32 | def banner_admin?(user) 33 | return true if user.admin? 34 | 35 | instance = find_or_default 36 | instance.banner_admin?(user) 37 | end 38 | end 39 | 40 | def admin_group 41 | value[:admin_group] || GLOBAL_BANNER_ADMIN_GROUP 42 | end 43 | 44 | def banner_admin?(user) 45 | return true if user.admin? 46 | 47 | admin_group = value['banner_admin'] || GLOBAL_BANNER_ADMIN_GROUP 48 | 49 | banner_admin_group = Group.find_by(lastname: admin_group) 50 | return false if banner_admin_group.blank? 51 | 52 | banner_admin_group.users.include?(user) 53 | end 54 | 55 | def use_timer? 56 | value['use_timer'] == 'true' 57 | end 58 | 59 | def start_time 60 | get_time( 61 | value['start_ymd'], 62 | value['start_hour'], 63 | value['start_min'] 64 | ) 65 | end 66 | 67 | def end_time 68 | get_time( 69 | value['end_ymd'], 70 | value['end_hour'], 71 | value['end_min'] 72 | ) 73 | end 74 | 75 | def get_time(ymd, hour, minute) 76 | begin 77 | d = Date.strptime(ymd, '%Y-%m-%d') 78 | rescue StandardError => e 79 | logger&.warn("Passed value #{ymd} for Banner has wrong format. #{e.message}") 80 | d = Date.current 81 | end 82 | Time.mktime(d.year, d.month, d.day, hour.to_i, minute.to_i) 83 | end 84 | 85 | def valid_date_range? 86 | return true unless use_timer? 87 | 88 | end_time > start_time 89 | end 90 | 91 | def enable? 92 | value['enable'] == 'true' 93 | end 94 | 95 | def disable? 96 | value['enable'] != 'true' 97 | end 98 | 99 | def merge_value(new_value) 100 | current_value = value 101 | self.value = current_value.merge(new_value).stringify_keys 102 | end 103 | end 104 | -------------------------------------------------------------------------------- /app/views/banner/_body_bottom.html.erb: -------------------------------------------------------------------------------- 1 | 21 | 22 | <% if setting['display_part'] == 'header' %> 23 | 33 | <% end %> 34 | 35 | <% if setting['display_part'] == 'both' %> 36 | 46 | <% end %> -------------------------------------------------------------------------------- /app/views/banner/_off.erb: -------------------------------------------------------------------------------- 1 | let elements = document.getElementsByClassName('global_banner'); 2 | elements = Array.from(elements); 3 | elements.forEach(function(element) { 4 | element.classList.add('fadeout'); 5 | setTimeout(function(){ 6 | element.style.display = "none"; 7 | }, 500); 8 | }); -------------------------------------------------------------------------------- /app/views/banner/_project_banner_off.erb: -------------------------------------------------------------------------------- 1 | let elements = document.getElementsById('banner_content'); 2 | element.classList.add('fadeout'); 3 | setTimeout(function(){ 4 | element.style.display = "none"; 5 | }, 500); 6 | 7 | -------------------------------------------------------------------------------- /app/views/banner/_project_body_bottom.html.erb: -------------------------------------------------------------------------------- 1 | 30 | 39 | -------------------------------------------------------------------------------- /app/views/banner/show.html.erb: -------------------------------------------------------------------------------- 1 | <% banner = @banner %> 2 |

<%= l(:banner) %>

3 | 4 | <%= form_tag({ action: 'edit' }, id: 'banner') do %> 5 | 6 | 48 | 49 | -------------------------------------------------------------------------------- /app/views/global_banner/show.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_tag({ action: 'show' }, id: 'global_banner') do %> 2 | 3 |
4 | 5 |

Plugins » Redmine Banner plugin

6 | 7 |
8 |

9 | <%= content_tag(:label, l(:button_activate))%> 10 | <%= hidden_field_tag('setting[enable]', false).html_safe %> 11 | <%= check_box_tag 'setting[enable]', true, setting['enable'] == 'true' %> 12 |

13 | 14 |

15 | <%= content_tag(:label, l(:setting_banner_display_for, default: 'Display for'))%> 16 | <%= select_tag('setting[display_for]', 17 | options_for_select([[l(:label_anonymous_only, default: 'Anonymous'),'anonymous'], 18 | [l(:label_authenticated_only, default: 'Authenticated'),'authenticated'], 19 | [l(:label_display_all, default: 'All'), 'all']], 20 | { selected: setting['display_for'] })) %> 21 |

22 | 23 |

24 | <%= content_tag(:label, l(:label_message_type))%> 25 | <%= radio_button_tag 'setting[type]', 'info', setting['type'] == 'info' %>
26 | <%= radio_button_tag 'setting[type]', 'warn', setting['type'] == 'warn' %>
27 | <%= radio_button_tag 'setting[type]', 'alert', setting['type'] == 'alert' %>
28 | <%= radio_button_tag 'setting[type]', 'normal', setting['type'] == 'normal' %> 29 |

30 | 31 |

32 | <%= content_tag(:label, l(:setting_banner_display_part))%> 33 | <%= select_tag('setting[display_part]', 34 | options_for_select([[l(:label_header_only),'header'], 35 | [l(:label_footer_only),'footer'], 36 | [l(:label_both),'both']], 37 | setting['display_part'])) %> 38 | <%= hidden_field_tag('setting[display_only_login_page]', false).html_safe %> 39 | <%= check_box_tag 'setting[display_only_login_page]', true, setting['display_only_login_page'] == 'true' %> 40 | <%= l(:label_check_if_banner_show_only_login_page) %> 41 |

42 | 43 |

44 | <%= content_tag(:label, l(:label_banner_message)) %> 45 | <%= text_area_tag 'setting[banner_description]', setting['banner_description'], size: '40x3', 46 | class: 'wiki-edit', required: true %>
47 |

48 | <%= wikitoolbar_for 'setting_banner_description' %> 49 | 50 | 51 | 52 |

53 | <%= content_tag(:label, l(:setting_banner_related_link))%> 54 | <%= text_field_tag 'setting[related_link]', setting['related_link'], size: 40 %>
55 | <%= l(:setting_banner_related_link_description) %> 56 |

57 | 58 |

59 | <%= content_tag(:label, l(:label_use_timer)) %> 60 | 61 | <%= hidden_field_tag('setting[use_timer]', false).html_safe %> 62 | <%= check_box_tag 'setting[use_timer]', true, use_timer, onclick: '$("#banner_timer_setting").toggle();' %> 63 | 64 |

65 | 66 | 88 | 89 |

90 | <%= content_tag(:label, l(:field_updated_on)) %> 91 | <%= banner_updated_on %> 92 |

93 | 94 |

95 | <%= content_tag(:label, l(:banner_admin_group, default: 'Banner Admin Group')) %> 96 | <% if User.current.admin? %> 97 | <%= select_tag('setting[banner_admin]', 98 | options_for_select( Group.givable.pluck(:lastname) << GlobalBanner::GLOBAL_BANNER_ADMIN_GROUP, 99 | selected: setting['banner_admin'] || GlobalBanner::GLOBAL_BANNER_ADMIN_GROUP )) %> 100 |
<%= l(:description_for_banner_admin_group, default: "Specify a group that can manage the global banner without admin rights.") %> 101 | <% else %> 102 | <%= setting['banner_admin'] || GlobalBanner::GLOBAL_BANNER_ADMIN_GROUP %> 103 | <% end %> 104 |

105 |
106 |
107 | 108 | <%= submit_tag l(:button_apply) %> 109 | <% end %> 110 | 111 | 112 | -------------------------------------------------------------------------------- /assets/images/alert-msg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/alert-msg.png -------------------------------------------------------------------------------- /assets/images/alert.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/alert.png -------------------------------------------------------------------------------- /assets/images/banner-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/banner-screenshot.png -------------------------------------------------------------------------------- /assets/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/close.png -------------------------------------------------------------------------------- /assets/images/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/edit.png -------------------------------------------------------------------------------- /assets/images/icon-timer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/icon-timer.png -------------------------------------------------------------------------------- /assets/images/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/info.png -------------------------------------------------------------------------------- /assets/images/warn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/agileware-jp/redmine_banner/3ae4cd380b73cf4c8e593e74b0a6c9169bd935a1/assets/images/warn.png -------------------------------------------------------------------------------- /assets/javascripts/banner.js: -------------------------------------------------------------------------------- 1 | /* Code for Banner UI */ 2 | function checkDateRange(event, confirm_msg, date_range_error_msg) { 3 | let s = $('#setting_start_ymd').val() + " " + $('#setting_start_hour').val() + ":" + $('#setting_start_min').val(); 4 | let e = $('#setting_end_ymd').val() + " " + $('#setting_end_hour').val() + ":" + $('#setting_end_min').val(); 5 | if (e.replace(/\-\s:/gi, "") < s.replace(/\-\s:/gi, "")) { 6 | window.alert(date_range_error_msg + " (From " + s + " to " + e + ")"); 7 | return false; 8 | } else { 9 | let response = confirm(confirm_msg); 10 | if (response) { 11 | return true; 12 | } 13 | } 14 | return false; 15 | } 16 | 17 | function displayTopBanner() { 18 | if (window.matchMedia( '(max-width: 899px)' ).matches) { 19 | $('#content').prepend($('div.banner_area.global_banner').first()); 20 | } else { 21 | $('div.banner_area.global_banner').first().insertAfter($('#top-menu')); 22 | } 23 | } 24 | 25 | function displayTopAndBottomBanner() { 26 | if (window.matchMedia( '(max-width: 899px)' ).matches) { 27 | $('#content').prepend($('div.banner_area.global_banner').clone()); 28 | } else { 29 | $('div.banner_area.global_banner').clone().insertAfter($('#top-menu')); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /assets/stylesheets/banner.css: -------------------------------------------------------------------------------- 1 | div.banner { 2 | border: 1px solid; 3 | margin: 2px 0; 4 | padding: 2px 20px; 5 | } 6 | 7 | div.banner_info { 8 | border-color: #b0c4de; 9 | background: #f0f8ff url("../images/info.png") no-repeat 4px; 10 | padding-left: 26px; 11 | } 12 | 13 | div.banner_warn { 14 | border-color: #f3d51a; 15 | background: #f9f99e url("../images/warn.png") no-repeat 4px; 16 | padding-left: 26px; 17 | } 18 | 19 | div.banner_alert { 20 | border-color: #dd0000; 21 | background: #ffe3e3 url("../images/alert.png") no-repeat 4px; 22 | padding-left: 26px; 23 | } 24 | 25 | div.banner_normal { 26 | background-color: #ffffff; 27 | border-color: #ffffff; 28 | } 29 | 30 | div.banner_nodata { 31 | text-align: center; 32 | background-color: #FFEBC1; 33 | border-color: #FDBF3B; 34 | color: #A6750C; 35 | } 36 | 37 | div.banner_edit { 38 | background-image: none; 39 | text-align: right; 40 | font-size: smaller; 41 | } 42 | 43 | span.banner_info { 44 | background: url("../images/info.png") no-repeat left center; 45 | padding-left: 26px; 46 | background-size: contain; 47 | } 48 | 49 | span.banner_warn { 50 | background: url("../images/warn.png") no-repeat left center; 51 | padding-left: 26px; 52 | background-size: contain; 53 | } 54 | 55 | span.banner_alert { 56 | background: url("../images/alert.png") no-repeat left center; 57 | padding-left: 26px; 58 | background-size: contain; 59 | } 60 | 61 | #admin-menu a.redmine-banner { 62 | background-image: url("../images/alert-msg.png"); 63 | } 64 | 65 | span.use_timer { 66 | background: url("../images/icon-timer.png") no-repeat right center; 67 | padding-right: 20px; 68 | } 69 | 70 | div.banner_area { 71 | position: relative; 72 | } 73 | 74 | div.project_banner_area { 75 | position: relative; 76 | } 77 | 78 | div.banner_area div.banner_edit { 79 | display: block; 80 | position: absolute; 81 | bottom: 5px; 82 | right: 10px; 83 | font-size: smaller; 84 | background: none; 85 | color: #000; 86 | filter: alpha(opacity=60); 87 | -moz-opacity: .6; 88 | opacity: .6; 89 | } 90 | 91 | div.banner_area div.banner_edit:hover { 92 | filter: alpha(opacity=90); 93 | -moz-opacity: .9; 94 | opacity: .9; 95 | } 96 | 97 | .banner-icon-off { 98 | background-image: url("../images/close.png"); 99 | } 100 | 101 | .banner-icon-edit { 102 | background-image: url("../images/edit.png"); 103 | } 104 | 105 | div.project_banner_area div.banner_edit { 106 | display: block; 107 | position: absolute; 108 | bottom: 5px; 109 | right: 10px; 110 | font-size: smaller; 111 | background: none; 112 | color: #000; 113 | filter: alpha(opacity=30); 114 | -moz-opacity: .3; 115 | opacity: .3; 116 | } 117 | 118 | div.project_banner_area div.banner_edit:hover { 119 | filter: alpha(opacity=80); 120 | -moz-opacity: .8; 121 | opacity: .8; 122 | } 123 | 124 | div.banner_area div.banner_more_info { 125 | display: block; 126 | position: absolute; 127 | bottom: 5px; 128 | right: 50%; 129 | font-size: smaller; 130 | background: none; 131 | color: #000; 132 | filter: alpha(opacity=50); 133 | -moz-opacity: .5; 134 | opacity: .5; 135 | } 136 | 137 | div.banner_area div.banner_more_info:hover { 138 | filter: alpha(opacity=90); 139 | -moz-opacity: .9; 140 | opacity: .9; 141 | } 142 | 143 | /*------------ plugin settings -----------------*/ 144 | .tabular.settings > .settings_for_banner > p { 145 | padding-left: 200px; 146 | } 147 | 148 | .tabular.settings > .settings_for_banner > p > label { 149 | margin-left: -200px; 150 | width: 180px; 151 | } 152 | @media (max-width: 899px) { 153 | #content > div.banner_area { 154 | margin-bottom: 8px; 155 | } 156 | } 157 | 158 | .fadeout { 159 | animation: fadeOut 1s; 160 | animation-fill-mode: both; 161 | } 162 | @keyframes fadeOut { 163 | 0% { 164 | opacity: 1; 165 | } 166 | 167 | 100% { 168 | opacity: 0; 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /config/locales/bg.yml: -------------------------------------------------------------------------------- 1 | # Bulgarian strings go here for Rails i18n, translated by Ivan Cenov i_cenov@botevgrad.com 2 | bg: 3 | banner: "Банер" 4 | setting_banner_display_part: "Място за показване" 5 | label_header_only: "Заглавна част" 6 | label_footer_only: "Основа" 7 | label_both: "Заглавна част и основа" 8 | label_banner_message: "Съобщение" 9 | label_message_type: "Тип на съобщението" 10 | label_start_datetime: "Начална дата и час" 11 | label_end_datetime: "Крайна дата и час" 12 | label_use_timer: "Използване на таймер" 13 | error_banner_date_range: "Началният момент трябва да бъде преди крайния." 14 | redmine_banner_title: "Банер" 15 | button_off: "Изключване" 16 | banner_off: "Изключване на банера" 17 | permission_manage_banner: "Управление на банерите" 18 | project_module_banner: "Банер" 19 | page_overview_only: "Само общ изглед" 20 | page_all: "Навсякъде" 21 | page_overview_and_issues: "Общ изглед и задачи" 22 | page_new_issue_only: "Само нови задачи" 23 | label_display_authenticated_user_only: "Показване на банери само за регистрирани потребители (logged in)." 24 | label_check_if_banner_show_only_login_page: "По избор: Показване само на страницата за вход в Redmine." 25 | setting_banner_related_link: "Връзка" 26 | setting_banner_related_link_description: "Добавя връзка към повече информация, ако е дефинирана." 27 | more_info: "[Повече информация]" 28 | label_more_info: "Натиснете, за да видите повече информация относно съобщението" 29 | -------------------------------------------------------------------------------- /config/locales/de.yml: -------------------------------------------------------------------------------- 1 | # German strings go here for Rails i18n 2 | de: 3 | banner: "Banner" 4 | setting_banner_display_part: "Anzeigeposition" 5 | label_header_only: "Nur Kopfzeile" 6 | label_footer_only: "Nur Fußzeile" 7 | label_both: "Kopf und Fußzeile" 8 | label_banner_message: "Banner Nachricht" 9 | label_message_type: "Nachrichtenart" 10 | label_start_datetime: "Startzeitpunkt" 11 | label_end_datetime: "Endzeitpunkt" 12 | label_use_timer: "Timer benutzen" 13 | error_banner_date_range: "Der Startzeitpunkt muss vor dem Endzeitpunkt liegen." 14 | redmine_banner_title: "Springe zu den Banner Einstellungen." 15 | button_off: "Deaktivieren" 16 | banner_off: "Deaktiviert das Banner." 17 | permission_manage_banner: "Banner verwalten" 18 | project_module_banner: "Banner" 19 | page_overview_only: "Nur auf der Übersichtsseite" 20 | page_all: "Auf allen Seiten" 21 | page_overview_and_issues: "Auf der Übersichtsseite und Ticketübersicht" 22 | page_new_issue_only: "Nur auf der Seite für neue Tickets" 23 | label_display_authenticated_user_only: "Banner nur bei authentifizierten Benutzern anzeigen." 24 | label_check_if_banner_show_only_login_page: "Option: Banner nur auf der Login Seite anzeigen." 25 | setting_banner_related_link: "Zugehöriger Link" 26 | setting_banner_related_link_description: "Wenn ein zugehöriger Link definiert ist, wird er an die Informationen angehängt." 27 | more_info: "[Weitere Informationen]" 28 | label_more_info: "Link zu weiteren Informationen." 29 | banner_admin_group: "Gruppe für Banneradministration" 30 | description_for_banner_admin_group: "Gruppe, die globale Banner auch ohne Admin-Rechte verwalten darf." 31 | setting_banner_display_for: "Banner anzeigen für" 32 | label_anonymous_only: "Anonyme Benutzer" 33 | label_authenticated_only: "Eingeloggte Benutzer" 34 | label_display_all: "Alle" 35 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # English strings go here for Rails i18n 2 | en: 3 | banner: "Banner" 4 | setting_banner_display_part: "Display Location" 5 | label_header_only: "Header only" 6 | label_footer_only: "Footer only" 7 | label_both: "Both Header / Footer" 8 | label_banner_message: "Banner message" 9 | label_message_type: "Message type" 10 | label_start_datetime: "Start datetime" 11 | label_end_datetime: "End datetime" 12 | label_use_timer: "Use timer" 13 | error_banner_date_range: "Start date should be prior to End date." 14 | redmine_banner_title: "Go to Banner Setting." 15 | button_off: "Off" 16 | banner_off: "Turn off banner message in your session. (Turn on banner again if Admin updates global banner message.)" 17 | permission_manage_banner: "Manage Banner" 18 | project_module_banner: "Banner" 19 | page_overview_only: "Overview only" 20 | page_all: "All the page" 21 | page_overview_and_issues: "Overview and Issues" 22 | page_new_issue_only: "New issue only" 23 | label_display_authenticated_user_only: "Show banner only for authenticated users." 24 | label_check_if_banner_show_only_login_page: "Option: Display only at the login page." 25 | setting_banner_related_link: "Related link" 26 | setting_banner_related_link_description: "If defined, link for more information is appended." 27 | more_info: "[More Info]" 28 | label_more_info: "Link to more information." 29 | banner_admin_group: "Banner Admin Group" 30 | description_for_banner_admin_group: "Specify a group that can manage the global banner without admin rights." 31 | setting_banner_display_for: "Display for" 32 | label_anonymous_only: "Anonymous users" 33 | label_authenticated_only: "Authenticated users" 34 | label_display_all: "All" 35 | -------------------------------------------------------------------------------- /config/locales/es.yml: -------------------------------------------------------------------------------- 1 | # Translation by Picazamora (https://github.com/akiko-pusu/redmine_banner/issues/52) 2 | es: 3 | banner: "Baner" 4 | setting_banner_display_part: "Posición en la pantalla" 5 | label_header_only: "Solo en la cabecera" 6 | label_footer_only: "Solo en el pie" 7 | label_both: "Cabecera y pie" 8 | label_banner_message: "Mensaje del baner" 9 | label_message_type: "Tipo de mensaje" 10 | label_start_datetime: "Fecha y hora de inicio" 11 | label_end_datetime: "Fecha y hora de fin" 12 | label_use_timer: "Temporizador" 13 | error_banner_date_range: "La fecha de inicio debe ser anterior a la de fin." 14 | redmine_banner_title: "Ir a la configuración del baner." 15 | button_off: "Apagado" 16 | banner_off: "No mostrar el baner en la sesión. (El baner se volvera a encender si el admin lo modifica)" 17 | permission_manage_banner: "Administrar banner" 18 | project_module_banner: "Baner" 19 | page_overview_only: "Solo vista general" 20 | page_all: "En toda la pagina" 21 | page_overview_and_issues: "Vista general y tareas" 22 | page_new_issue_only: "Solo en nueva tarea" 23 | label_display_authenticated_user_only: "Mostrar solo el baner solo a los usuarios autenticados." 24 | label_check_if_banner_show_only_login_page: "Opción: Mostrar solo en la pagina de acceso." 25 | setting_banner_related_link: "Enlace relacionado" 26 | setting_banner_related_link_description: "Si se define, Enlace para obtener información adjunta." 27 | more_info: "[Más info]" 28 | label_more_info: "Enlace para más información." 29 | -------------------------------------------------------------------------------- /config/locales/fr.yml: -------------------------------------------------------------------------------- 1 | # French strings go here for Rails i18n - Laurent HADJADJ 08/04/2013 2 | fr: 3 | banner: "Bannière" 4 | setting_banner_display_part: "Emplacement de la bannière" 5 | label_header_only: "En-tête uniquement" 6 | label_footer_only: "Bas de page uniquement" 7 | label_both: "Les deux en-tête / bas de page" 8 | label_banner_message: "Message de la bannière" 9 | label_message_type: "Type de message" 10 | label_start_datetime: "Début" 11 | label_end_datetime: "Fin" 12 | label_use_timer: "Utilisez un programateur" 13 | error_banner_date_range: "La date de début doit être inférieure à la date de fin." 14 | redmine_banner_title: "Aller au paramétrage de la bannière." 15 | button_off: "Désactiver" 16 | banner_off: "Désactiver la bannière pour votre session. (Elle réapparaitra si le message est modifié par un administrateur)" 17 | permission_manage_banner: "Configurer la bannière" 18 | project_module_banner: "Bannière" 19 | page_overview_only: "Aperçu seulement" 20 | page_all: "Sur toutes les pages" 21 | page_overview_and_issues: "Aperçus et demandes" 22 | page_new_issue_only: "Nouvelles demandes seulement" 23 | label_display_authenticated_user_only: "Afficher la bannière uniquement pour les personnes authentifiées." 24 | label_check_if_banner_show_only_login_page: "Option : Afficher uniquement sur la page de connexion." 25 | setting_banner_related_link: "Lien apparenté" 26 | setting_banner_related_link_description: "Si défini, le lien sera ajouté dans la bannière." 27 | more_info: "[Plus d'informations]" 28 | label_more_info: "Lien vers plus d'informations." 29 | -------------------------------------------------------------------------------- /config/locales/it.yml: -------------------------------------------------------------------------------- 1 | # Italian strings go here for Rails i18n 2 | it: 3 | banner: "Banner" 4 | setting_banner_display_part: "Posizione sullo schermo" 5 | label_header_only: "Solo testata" 6 | label_footer_only: "Solo piè di pagina" 7 | label_both: "Testata / Piè di pagina" 8 | label_banner_message: "Messaggio sul banner" 9 | label_message_type: "Tipo di messaggio" 10 | label_start_datetime: "Data/ora inizio" 11 | label_end_datetime: "Data/ora fine" 12 | label_use_timer: "Usa timer" 13 | error_banner_date_range: "La data di inizio deve precedere quella di fine." 14 | redmine_banner_title: "Vai alle impostazioni del banner." 15 | button_off: "Spento" 16 | banner_off: "Disattiva messaggio banner." 17 | permission_manage_banner: "Gestione Banner" 18 | project_module_banner: "Banner" 19 | page_overview_only: "Solo visione" 20 | page_all: "Tutta la pagina" 21 | page_overview_and_issues: "Visione e segnalazioni" 22 | page_new_issue_only: "Solo nuova segnalazione" 23 | label_display_authenticated_user_only: "Mostra banner solo agli utenti autenticati." 24 | label_check_if_banner_show_only_login_page: "Opzione: mostra solo nella pagina di login." 25 | setting_banner_related_link: "Link collegato" 26 | setting_banner_related_link_description: "Se definito, viene allegato il link per ulteriori informazioni." 27 | more_info: "[Piu' Info]" 28 | label_more_info: "Link per ulteriori informazioni." 29 | 30 | -------------------------------------------------------------------------------- /config/locales/ja.yml: -------------------------------------------------------------------------------- 1 | # English strings go here for Rails i18n 2 | ja: 3 | banner: "バナー" 4 | setting_banner_display_part: "表示位置" 5 | label_header_only: "ヘッダのみ" 6 | label_footer_only: "フッタのみ" 7 | label_both: "ヘッダ / フッタ両方とも" 8 | label_banner_message: "バナーメッセージ" 9 | label_message_type: "メッセージタイプ" 10 | label_start_datetime: "表示開始時刻" 11 | label_end_datetime: "表示終了時刻" 12 | label_use_timer: "タイマーを利用する" 13 | error_banner_date_range: "日付の範囲が正しく設定されていません。" 14 | redmine_banner_title: "バナーの設定画面へ" 15 | button_off: "表示オフ" 16 | banner_off: "セッションが有効な間、バナーの表示をオフにします。(バナーの内容に変更があった場合は、再度表示されます)" 17 | permission_manage_banner: "バナーの管理" 18 | project_module_banner: "バナー" 19 | page_overview_only: "概要ページ" 20 | page_all: "全てのページ" 21 | page_overview_and_issues: "概要とチケットトラッキングのページ" 22 | page_new_issue_only: "新規チケットのページ" 23 | label_display_authenticated_user_only: "ログインユーザのみ表示" 24 | label_check_if_banner_show_only_login_page: "オプション: ログインページのみ表示" 25 | setting_banner_related_link: "関連リンク" 26 | setting_banner_related_link_description: "関連/詳細情報へのリンクをメッセージに追加します。" 27 | more_info: "[詳細]" 28 | label_more_info: "詳細はこちら。" 29 | banner_admin_group: "バナー管理者グループ" 30 | description_for_banner_admin_group: "バナー管理者グループのユーザは、Redmine全体の管理者権限なしでもグローバルバナーを編集できるようになります。" 31 | setting_banner_display_for: "表示対象" 32 | label_anonymous_only: "ログインしていないユーザのみ" 33 | label_authenticated_only: "ログインユーザのみ" 34 | label_display_all: "全てのユーザ" 35 | -------------------------------------------------------------------------------- /config/locales/ko.yml: -------------------------------------------------------------------------------- 1 | # Translation by Ki Won Kim (http://x10.iptime.org/redmine, http://xyz37.blog.me, xyz37@naver.com) 2 | ko: 3 | banner: "배너 광고" 4 | setting_banner_display_part: "표시 위치" 5 | label_header_only: "머리말 만" 6 | label_footer_only: "꼬리말 만" 7 | label_both: "머리말/꼬리말" 8 | label_banner_message: "배너 메세지" 9 | label_message_type: "메세지 종류" 10 | label_start_datetime: "시작 일시" 11 | label_end_datetime: "종료 일시" 12 | label_use_timer: "타이머 사용" 13 | error_banner_date_range: "시작일시가 종료일시 보다 먼저 와야 합니다." 14 | redmine_banner_title: "배너 설정으로 이동" 15 | button_off: "끄기" 16 | banner_off: "배너 메세지 끄기" 17 | permission_manage_banner: "배너 관리" 18 | project_module_banner: "배너 광고" 19 | page_overview_only: "초기화면만" 20 | page_all: "모든 페이지" 21 | page_overview_and_issues: "초기화면과 일감" 22 | page_new_issue_only: "새로운 일감만" 23 | label_display_authenticated_user_only: "인증된 사용자만 배너 보임" 24 | label_check_if_banner_show_only_login_page: "옵션: 로그인 페이지에서만 보임" 25 | -------------------------------------------------------------------------------- /config/locales/nl.yml: -------------------------------------------------------------------------------- 1 | # Dutch strings go here for Rails i18n 2 | nl: 3 | banner: "Banner" 4 | setting_banner_display_part: "Locatie" 5 | label_header_only: "Alleen header" 6 | label_footer_only: "Alleen footer" 7 | label_both: "Beide Header / Footer" 8 | label_banner_message: "Banner bericht" 9 | label_message_type: "Bericht type" 10 | label_start_datetime: "Start datumtijd" 11 | label_end_datetime: "End datumijd" 12 | label_use_timer: "Gebruik timer" 13 | error_banner_date_range: "Start datum moet voor eind datum liggen." 14 | redmine_banner_title: "Ga naar Banner instellingen." 15 | button_off: "Uitgeschakeld" 16 | banner_off: "Het Banner bericht is voor uw sessie uitgeschakeld. (Schakel de Banner weer in wanneer de beheerder het globale bericht update.)" 17 | permission_manage_banner: "Beheer Banner" 18 | project_module_banner: "Banner" 19 | page_overview_only: "Alleen bij de samenvatting" 20 | page_all: "De gehele pagina" 21 | page_overview_and_issues: "Samevatting en Incidenten" 22 | page_new_issue_only: "Alleen bij nieuwe Incidenten" 23 | label_display_authenticated_user_only: "Laat de Banneer alleen zien bij aangemelde gebruikers." 24 | label_check_if_banner_show_only_login_page: "Optie: Alleen weergeven bij het loginscherm." 25 | 26 | -------------------------------------------------------------------------------- /config/locales/pt-BR.yml: -------------------------------------------------------------------------------- 1 | # Brazilian Portugues strings go here for Rails i18n 2 | # Author: Maiko de Andrade 3 | # Update: Guilherme de Mesquita 4 | pt-BR: 5 | banner: "Banner" 6 | setting_banner_display_part: "Local da exibição" 7 | label_header_only: "Somente no cabeçalho" 8 | label_footer_only: "Somente no rodapé" 9 | label_both: "Ambos Cabeçalho e Rodapé" 10 | label_banner_message: "Mensagem do Banner" 11 | label_message_type: "Tipo de Mensagem" 12 | label_start_datetime: "Começo" 13 | label_end_datetime: "Fim" 14 | label_use_timer: "Usar timer" 15 | error_banner_date_range: "A data de início deve ser anterior à data de término." 16 | redmine_banner_title: "Ir para definições do Banner." 17 | button_off: "Desligar" 18 | banner_off: "Desligar a notificação na sua sessão" 19 | permission_manage_banner: "Administrar Banners" 20 | project_module_banner: "Banners" 21 | page_overview_only: "Somente visão geral" 22 | page_all: "Em toda página" 23 | page_overview_and_issues: "Visão geral e Tarefas" 24 | page_new_issue_only: "Somente para novas tarefas" 25 | label_display_authenticated_user_only: "Mostrar somente para usuários autenticados" 26 | label_check_if_banner_show_only_login_page: "Mostrar somente na página de Login" 27 | setting_banner_related_link: "Link relacionado" 28 | setting_banner_related_link_description: "Se definido, link para mais informações é anexado." 29 | more_info: "[Mais Informações]" 30 | label_more_info: "Link para mais informações" 31 | -------------------------------------------------------------------------------- /config/locales/ru.yml: -------------------------------------------------------------------------------- 1 | # Russian strings go here for Rails i18n 2 | ru: 3 | banner: "Баннер" 4 | setting_banner_display_part: "Отображать" 5 | label_header_only: "Сверху" 6 | label_footer_only: "Снизу" 7 | label_both: "Сверху и снизу" 8 | label_banner_message: "Сообщение" 9 | label_message_type: "Тип сообщения" 10 | label_start_datetime: "Начало" 11 | label_end_datetime: "Окончание" 12 | label_use_timer: "Использовать таймер" 13 | error_banner_date_range: "Дата начала показа должна быть меньше даты окончания" 14 | redmine_banner_title: "Перейти к настройкам баннера." 15 | button_off: "Отключить" 16 | banner_off: "Отключить сообщение." 17 | permission_manage_banner: "Управление баннером" 18 | project_module_banner: "Баннер" 19 | page_overview_only: "Обзор" 20 | page_all: "Везде" 21 | page_overview_and_issues: "Обзор и Задачи" 22 | page_new_issue_only: "Новая задача" 23 | 24 | -------------------------------------------------------------------------------- /config/locales/tr.yml: -------------------------------------------------------------------------------- 1 | # Turkish strings by Adnan Topçu for Rails i18n 2 | tr: 3 | banner: "Banner" 4 | setting_banner_display_part: "Gösterme konumu" 5 | label_header_only: "Sadece üst" 6 | label_footer_only: "Sadece alt" 7 | label_both: "Hem üst hem alt" 8 | label_banner_message: "Banner mesajı" 9 | label_message_type: "Mesaj tipi" 10 | label_start_datetime: "Gösterim başlangıç zamanı" 11 | label_end_datetime: "Bösterim bitiş zamanı" 12 | label_use_timer: "Zamanlayıcı kullan" 13 | error_banner_date_range: "Gösterim başlama zamanı bitiş zamanından önce olmalıdır." 14 | redmine_banner_title: "Banner ayarlarına git." 15 | button_off: "Kapalı" 16 | banner_off: "Banner mesajını kendi oturumun için kapat. (Eğer yönetici genel banner mesajını güncellerse tekrar aç.)" 17 | permission_manage_banner: "Banner'i yönet" 18 | project_module_banner: "Banner" 19 | page_overview_only: "Genel Sayfası sadece" 20 | page_all: "Tüm sayfalar" 21 | page_overview_and_issues: "Genel ve işler" 22 | page_new_issue_only: "Yeni İş açma yalnızca" 23 | label_display_authenticated_user_only: "Sadece kimlik doğrulaması olan kullanıcılarda çıksın." 24 | label_check_if_banner_show_only_login_page: "Opsiyon: Sadece oturum açma ekranında çıksın." 25 | setting_banner_related_link: "İlgili bağlantı" 26 | setting_banner_related_link_description: "tanımlıysa, daha fazla bilgi bağlantısı eklenir." 27 | more_info: "[Daha fazla bilgi]" 28 | label_more_info: "Daha fazla bilgi için bağlantı." 29 | -------------------------------------------------------------------------------- /config/locales/zh.yml: -------------------------------------------------------------------------------- 1 | # Chinese strings go here for Rails i18n 2 | zh: 3 | banner: "Banner横幅提示" 4 | setting_banner_display_part: "显示位置" 5 | label_header_only: "仅在页首显示" 6 | label_footer_only: "仅在页尾显示" 7 | label_both: "在页首和页尾同时显示" 8 | label_banner_message: "Banner横幅信息" 9 | label_message_type: "信息类型" 10 | label_start_datetime: "起始时间" 11 | label_end_datetime: "结束时间" 12 | label_use_timer: "使用计时器" 13 | error_banner_date_range: "起始时间必须小于结束时间。" 14 | redmine_banner_title: "Banner横幅设置" 15 | button_off: "关闭" 16 | banner_off: "关闭Banner横幅信息。" 17 | permission_manage_banner: "管理Banner横幅" 18 | project_module_banner: "Banner横幅" 19 | page_overview_only: "仅概述页面" 20 | page_all: "所有页面" 21 | page_overview_and_issues: "概述页面和问题页面" 22 | page_new_issue_only: "仅新建问题页面" 23 | label_display_authenticated_user_only: "仅对授权用户显示对应的Banner横幅信息" 24 | label_check_if_banner_show_only_login_page: "选项:仅在登陆页面上显示。" 25 | setting_banner_related_link: "相关链接" 26 | setting_banner_related_link_description: "若定义,点击相关链接查看更多信息。" 27 | more_info: "[更多…]" 28 | label_more_info: "查看更多信息。" 29 | banner_admin_group: "管理用户组" 30 | description_for_banner_admin_group: "指定一个用户组,使其无需管理员权限也可以管理全局Banner横幅" 31 | setting_banner_display_for: "显示用户" 32 | label_anonymous_only: "匿名用户" 33 | label_authenticated_only: "认证用户" 34 | label_display_all: "所有用户" 35 | 36 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | Rails.application.routes.draw do 4 | concern :previewable do 5 | post 'preview', on: :collection 6 | get 'preview', on: :collection 7 | end 8 | 9 | resources :projects do 10 | resources :banner, only: %i[show] do 11 | get '/', to: 'banner#show', on: :collection 12 | post '/', to: 'banner#edit', on: :collection 13 | post 'project_banner_off', on: :collection 14 | get 'project_banner_off', on: :collection 15 | end 16 | end 17 | 18 | resources :banner, only: %i[preview off], concerns: [:previewable] do 19 | post 'off', on: :collection 20 | get 'off', on: :collection 21 | end 22 | 23 | resources :global_banner, only: %i[show] do 24 | get '/', to: 'global_banner#show', on: :collection 25 | post '/', to: 'global_banner#update', on: :collection 26 | end 27 | 28 | namespace 'banners' do 29 | namespace 'api' do 30 | resource :global_banner, only: %i[register_banner] do 31 | put '/', to: 'global_banner#register_banner', on: :member 32 | get '/', to: 'global_banner#show', on: :member 33 | end 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /db/migrate/001_create_banners.rb: -------------------------------------------------------------------------------- 1 | class CreateBanners < ActiveRecord::Migration[4.2] 2 | def self.up 3 | create_table :banners do |t| 4 | t.column :enabled, :boolean 5 | t.column :type, :string 6 | t.column :banner_description, :string 7 | t.column :use_timer, :boolean 8 | t.column :start_date, :datetime 9 | t.column :end_date, :datetime 10 | t.column :project_id, :integer, :null => false 11 | t.column :updated_on, :datetime 12 | end 13 | end 14 | 15 | def self.down 16 | drop_table :banners 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /db/migrate/002_rename_column_type.rb: -------------------------------------------------------------------------------- 1 | class RenameColumnType < ActiveRecord::Migration[4.2] 2 | def self.up 3 | # Not to use "type". It causes problem, "Can't mass-assign these protected attributes: type" 4 | rename_column :banners, :type, :style 5 | end 6 | 7 | def self.down 8 | rename_column :banners, :style, :type 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/003_add_display_part_to_banners.rb: -------------------------------------------------------------------------------- 1 | class AddDisplayPartToBanners < ActiveRecord::Migration[4.2] 2 | def self.up 3 | add_column :banners, :display_part, :string, :default => "all", :null => false 4 | end 5 | 6 | def self.down 7 | remove_column :banners, :display_part 8 | end 9 | end 10 | 11 | -------------------------------------------------------------------------------- /db/migrate/004_change_column_style.rb: -------------------------------------------------------------------------------- 1 | # To change this template, choose Tools | Templates 2 | # and open the template in the editor. 3 | 4 | class ChangeColumnStyle < ActiveRecord::Migration[4.2] 5 | def self.up 6 | change_column :banners, :style, :string, :default => "info", :null => false 7 | end 8 | 9 | def self.down 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /db/migrate/005_change_column_banner_description.rb: -------------------------------------------------------------------------------- 1 | # #44: Changed banner description to text for advanced integration of images, etc 2 | class ChangeColumnBannerDescription < ActiveRecord::Migration[4.2] 3 | def self.up 4 | change_column :banners, :banner_description, :text 5 | end 6 | 7 | def down 8 | change_column :banners, :banner_description, :string 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.2' 2 | services: 3 | # start service for redmine with plugin 4 | # 1. $ docker-compose build --force-rm --no-cache 5 | # 2. $ docker-compose up -d web 6 | # 7 | # 8 | web: 9 | build: 10 | context: . 11 | image: redmine_sqlite3 12 | container_name: redmine_sqlite3 13 | command: > 14 | bash -c "bundle && 15 | bundle exec rake db:migrate && 16 | bundle exec rake redmine:plugins:migrate && 17 | bundle exec rake generate_secret_token && 18 | bundle exec rails s -p 3000 -b '0.0.0.0'" 19 | environment: 20 | RAILS_ENV: development 21 | volumes: 22 | - .:/app/redmine/plugins/redmine_banner 23 | ports: 24 | - "3000:3000" 25 | 26 | 27 | -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require File.dirname(__FILE__) + '/../../lib/redmine' 4 | require File.dirname(__FILE__) + '/app/models/global_banner' 5 | require File.dirname(__FILE__) + '/lib/banners/banner_header_hooks' 6 | 7 | # NOTE: Keep error message for a while to support Redmine3.x users. 8 | def banner_version_message(original_message = nil) 9 | <<-"USAGE" 10 | ========================== 11 | #{original_message} 12 | If you use Redmine3.x, please use Redmine Banner version 0.1.x or clone via 13 | 'v0.1.x-support-Redmine3' branch. 14 | You can download older version from here: https://github.com/akiko-pusu/redmine_banner/releases 15 | ========================== 16 | USAGE 17 | end 18 | 19 | def banner_admin? 20 | GlobalBanner.banner_admin?(User.current) 21 | end 22 | 23 | def project_menu_allowed? 24 | proc { |p| User.current.allowed_to?({ controller: 'banner', action: 'show' }, p) } 25 | end 26 | 27 | Redmine::Plugin.register :redmine_banner do 28 | begin 29 | name 'Redmine Banner plugin' 30 | author 'Akiko Takano' 31 | author_url 'http://twitter.com/akiko_pusu' 32 | description 'Plugin to show site-wide message, such as maintenacne informations or notifications.' 33 | version '0.3.4' 34 | requires_redmine version_or_higher: '4.0' 35 | url 'https://github.com/akiko-pusu/redmine_banner' 36 | 37 | settings partial: nil, default: GlobalBanner::GLOBAL_BANNER_DEFAULT_SETTING 38 | 39 | menu :admin_menu, 'icon redmine_banner', { controller: 'global_banner', action: 'show', "id": nil }, caption: :banner 40 | menu :top_menu, :redmine_banner, { controller: 'global_banner', action: 'show', "id": nil }, caption: :banner, 41 | last: true, 42 | if: proc { banner_admin? } 43 | menu :project_menu, :banner, { controller: 'banner', action: 'show', "id": nil }, 44 | caption: :banner, param: :project_id, after: :settings, if: project_menu_allowed? 45 | 46 | project_module :banner do 47 | permission :manage_banner, { banner: %I[show edit project_banner_off] }, require: :member 48 | end 49 | rescue ::Redmine::PluginRequirementError => e 50 | raise ::Redmine::PluginRequirementError.new(banner_version_message(e.message)) # rubocop:disable Style/RaiseArgs 51 | end 52 | end 53 | -------------------------------------------------------------------------------- /lang/en.yml: -------------------------------------------------------------------------------- 1 | # English strings go here 2 | banner: "Banner" 3 | -------------------------------------------------------------------------------- /lib/banners/banner_header_hooks.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Banners 4 | class BannerHeaderHooks < Redmine::Hook::ViewListener 5 | include ApplicationHelper 6 | 7 | def view_layouts_base_html_head(_context = {}) 8 | o = stylesheet_link_tag('banner', plugin: 'redmine_banner') 9 | o << javascript_include_tag('banner', plugin: 'redmine_banner') 10 | o 11 | end 12 | end 13 | 14 | # 15 | # for Project Banner 16 | # 17 | class ProjectBannerMessageHooks < Redmine::Hook::ViewListener 18 | def view_layouts_base_content(context = {}) 19 | project = context[:project] 20 | return unless enabled?(project) 21 | 22 | banner = Banner.where(project_id: project.id).first 23 | return '' unless banner&.enable_banner? 24 | 25 | display_part = banner.display_part 26 | return '' unless action_to_display?(context[:controller], display_part) 27 | 28 | locals_params = { display_part: display_part, banner: banner } 29 | context[:controller].send( 30 | :render_to_string, partial: 'banner/project_body_bottom', locals: locals_params 31 | ) 32 | end 33 | 34 | private 35 | 36 | def enabled?(project) 37 | return false if project.nil? 38 | 39 | project.module_enabled? :banner 40 | end 41 | 42 | def action_to_display?(controller, display_part) 43 | return true if display_part == 'all' 44 | 45 | action_name = controller.action_name 46 | controller_name = controller.controller_name 47 | 48 | case display_part 49 | when 'overview' 50 | return true if controller_name == 'projects' && action_name == 'show' 51 | when 'overview_and_issues' 52 | return true if controller_name == 'issues' || (controller_name == 'projects' && action_name == 'show') 53 | when 'new_issue' 54 | return true if controller_name == 'issues' && action_name == 'new' 55 | else 56 | false 57 | end 58 | end 59 | end 60 | 61 | class BannerMessageHooks < Redmine::Hook::ViewListener 62 | def pass_timer?(global_banner) 63 | return true unless global_banner.use_timer? 64 | 65 | Time.zone.now.between?(global_banner.start_time, global_banner.end_time) 66 | end 67 | 68 | def view_layouts_base_body_bottom(context = {}) 69 | global_banner = GlobalBanner.find_or_default 70 | 71 | # In case global_banner is not stored. 72 | return if global_banner.updated_on.blank? || global_banner.disable? 73 | return unless pass_timer?(global_banner) 74 | 75 | setting = global_banner.value 76 | return unless should_display_on_current_page?(context, setting) 77 | 78 | banner_description = setting['banner_description'] 79 | banner_description.force_encoding('UTF-8') if banner_description.respond_to?(:force_encoding) 80 | 81 | locals_params = { setting: setting.merge(banner_description: banner_description), 82 | updated_on: global_banner.updated_on } 83 | 84 | context[:controller].send( 85 | :render_to_string, partial: 'banner/body_bottom', locals: locals_params 86 | ) 87 | end 88 | 89 | def should_display_on_current_page?(context, setting) 90 | return false if ((context[:controller].class.name != 'AccountController') && 91 | (context[:controller].action_name != 'login')) && 92 | (setting['display_only_login_page'] == 'true') 93 | 94 | return false if banner_is_off?(context[:controller]) 95 | should_display_for?(setting) 96 | end 97 | 98 | def should_display_for?(setting) 99 | target = setting['display_for'] || 'all' 100 | return true if target == 'all' 101 | 102 | return true if target == 'authenticated' && User.current.logged? 103 | return true if target == 'anonymous' && User.current.anonymous? 104 | 105 | false 106 | end 107 | 108 | def banner_is_off?(controller) 109 | banner_off_time = controller.session[:pref_banner_off] 110 | 111 | global_banner = GlobalBanner.find_or_default 112 | 113 | if !global_banner.blank? && !banner_off_time.blank? && global_banner.updated_on.to_i < banner_off_time 114 | return true 115 | end 116 | 117 | false 118 | end 119 | end 120 | end 121 | -------------------------------------------------------------------------------- /lib/tasks/test.rake: -------------------------------------------------------------------------------- 1 | require 'rake/testtask' 2 | 3 | namespace :redmine_banner do 4 | desc 'Run test for redmine_banner plugin.' 5 | task :test do |task_name| 6 | next unless ENV['RAILS_ENV'] == 'test' && task_name.name == 'redmine_banner:test' 7 | end 8 | 9 | Rake::TestTask.new(:test) do |t| 10 | t.libs << 'lib' 11 | t.pattern = 'plugins/redmine_banner/test/**/*_test.rb' 12 | t.verbose = false 13 | t.warning = false 14 | end 15 | end 16 | --------------------------------------------------------------------------------