Skip to content

Commit e039030

Browse files
authored
Merge pull request #45 from haru/develop
2 parents 4748235 + 8d1df6b commit e039030

File tree

10 files changed

+553
-40
lines changed

10 files changed

+553
-40
lines changed

.devcontainer/docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ services:
66
context: ..
77
dockerfile: .devcontainer/Dockerfile
88
args:
9-
# Update 'VARIANT' to pick a version of Ruby: 3, 3.0, 2, 2.7, 2.6
9+
# Update 'VARIANT' to pick a version of Ruby: 3, 3.1, 3.2, 3.3, 3.4.
1010
# Append -bullseye or -buster to pin to an OS version.
1111
# Use -bullseye variants on local arm64/Apple Silicon.
12-
RUBY_VERSION: "3.2"
12+
RUBY_VERSION: "3.4"
1313
# Optional Node.js version to install
1414
NODE_VERSION: "lts/*"
15-
REDMINE_VERSION: "6.0-stable"
15+
REDMINE_VERSION: "6.1-stable"
1616

1717
# Overrides default command so things don't shut down after the process ends.
1818
command: sleep infinity
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Bug Report
2+
description: Create a bug report
3+
title: "[Bug]: "
4+
labels: ["bug"]
5+
assignees:
6+
- octocat
7+
body:
8+
- type: markdown
9+
attributes:
10+
value: |
11+
Thanks for taking the time to fill out this bug report!
12+
validations:
13+
required: false
14+
- type: textarea
15+
id: what-happened
16+
attributes:
17+
label: 🐛What happened?
18+
description: Also tell us, what did you expect to happen?
19+
placeholder: Tell us what you see!
20+
value: "A bug happened!"
21+
validations:
22+
required: true
23+
- type: input
24+
id: WikiExtensions-version
25+
attributes:
26+
label: Wiki Extensions Version
27+
description: What version of Wiki Extensions plugin are you running?
28+
validations:
29+
required: true
30+
- type: input
31+
id: Redmine-version
32+
attributes:
33+
label: Redmine Version
34+
description: What version of Redmine are you running?
35+
validations:
36+
required: true
37+
- type: input
38+
id: Ruby-version
39+
attributes:
40+
label: Ruby Version
41+
description: What version of Ruby are you running?
42+
validations:
43+
required: false
44+
- type: dropdown
45+
id: browsers
46+
attributes:
47+
label: What browsers are you seeing the problem on?
48+
multiple: true
49+
options:
50+
- Firefox
51+
- Chrome
52+
- Safari
53+
- Microsoft Edge
54+
- Other
55+
- type: textarea
56+
id: logs
57+
attributes:
58+
label: Relevant log output
59+
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
60+
render: shell

.github/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Configuration for welcome - https://github.com/behaviorbot/welcome
2+
3+
# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
4+
5+
# Comment to be posted to on first time issues
6+
newIssueWelcomeComment: >
7+
Thanks for opening your first issue here!
8+
9+
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
10+
11+
# Comment to be posted to on PRs from first time contributors in your repository
12+
newPRWelcomeComment: >
13+
Thanks for opening this pull request!
14+
# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
15+
16+
# Comment to be posted to on pull requests merged by a first time user
17+
firstPRMergeComment: >
18+
Congrats on merging your first pull request!
19+
# It is recommended to include as many gifs and emojis as possible!

.github/copilot-instructions.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# Redmine Wiki Extensions Plugin - AI Coding Guidelines
2+
3+
## Project Architecture
4+
5+
This is a **Redmine plugin** (not a standalone Rails app) that extends wiki functionality with macros, comments, tags, and voting. The plugin follows Redmine's plugin architecture patterns:
6+
7+
- `init.rb` - Plugin registration, permissions, and menu definitions
8+
- `lib/` - Wiki macros and patches to Redmine core classes
9+
- `app/` - Standard Rails MVC structure for additional features
10+
- `db/migrate/` - Database migrations for plugin-specific tables
11+
- `build-scripts/` - Complex CI/test environment setup scripts
12+
13+
## Key Components
14+
15+
### Wiki Macros (`lib/*_macro.rb`)
16+
All macros follow this pattern:
17+
```ruby
18+
module WikiExtensions[Name]Macro
19+
Redmine::WikiFormatting::Macros.register do
20+
desc "Macro description"
21+
macro :macro_name do |obj, args|
22+
# Implementation
23+
end
24+
end
25+
end
26+
```
27+
28+
**Important macros**: `count`, `wiki`, `tags`, `recent`, `vote`, `project`, `twitter`
29+
30+
### Patches (`lib/*_patch.rb`)
31+
Extend Redmine core functionality using Rails' `prepend` pattern. Critical patterns:
32+
- **Controller patches**: Use `after_action` hooks (e.g., `after_action :wiki_extensions_save_tags`)
33+
- **Method overrides**: Override `render()` and `respond_to()` in WikiController
34+
- **Module inclusion**: `ActionView::Base.class_eval { include WikiExtensionsHelper }`
35+
36+
Key patches:
37+
- `wiki_extensions_wiki_controller_patch.rb` - Adds functionality to WikiController
38+
- `wiki_extensions_formatter_patch.rb` - Extends wiki formatting
39+
- `wiki_extensions_helper_patch.rb` - Adds helper methods
40+
41+
### Models (`app/models/`)
42+
Plugin-specific models with Redmine associations:
43+
- `WikiExtensionsComment` - Hierarchical comments on wiki pages
44+
- `WikiExtensionsTag` - Tagging system for wiki pages
45+
- `WikiExtensionsVote` - Voting/rating system
46+
47+
## Development Workflows
48+
49+
### Testing
50+
- Use `bundle exec rake redmine:plugins:test NAME=redmine_wiki_extensions`
51+
- Tests require Redmine environment setup via `build-scripts/install.sh`
52+
- Coverage reports generated in `coverage/` directory
53+
- Test fixtures in `test/fixtures/` must be copied to Redmine's test/fixtures/
54+
55+
### Database Changes
56+
- Always create migrations in `db/migrate/` with sequential numbering
57+
- Use `rake redmine:plugins:migrate` for deployment
58+
- Model tables prefixed with `wiki_extensions_`
59+
60+
### Build Process
61+
The plugin uses a complex CI setup:
62+
- Matrix builds across Ruby 3.1-3.4 and Redmine 6.0-master
63+
- Tests against SQLite, MySQL, PostgreSQL
64+
- Build scripts in `build-scripts/` handle Redmine checkout and plugin setup
65+
- **Environment variables**: `TESTSPACE`, `PATH_TO_REDMINE`, `PATH_TO_PLUGIN` must be absolute paths
66+
- Fixtures are automatically copied from `test/fixtures/` to Redmine's test environment
67+
68+
### Git Workflow
69+
- **All commits must use English commit messages** - Never use Japanese or other languages
70+
- Follow conventional commit format: "verb + brief description"
71+
- Examples: "Add macro functionality", "Fix permission check", "Update documentation"
72+
- Keep commit messages concise (under 50 characters for subject line)
73+
- All pull requests must target the `develop` branch
74+
75+
### Code Documentation
76+
- **All source code comments must be written in English** - Never use Japanese or other languages
77+
- Use clear, concise English for inline comments, method documentation, and code explanations
78+
- Follow Ruby documentation conventions using YARD format when appropriate
79+
- Examples of good comments:
80+
```ruby
81+
# Check if the plugin module is enabled for the current project
82+
return nil unless WikiExtensionsUtil.is_enabled?(@project) if @project
83+
84+
# Register the macro with Redmine's wiki formatting system
85+
Redmine::WikiFormatting::Macros.register do
86+
desc "Display page access count with optional reset functionality"
87+
macro :count do |obj, args|
88+
# Implementation details...
89+
end
90+
end
91+
```
92+
93+
## Coding Patterns
94+
95+
### Plugin Module Enablement
96+
**CRITICAL**: Always check if plugin is enabled before any functionality:
97+
```ruby
98+
return nil unless WikiExtensionsUtil.is_enabled?(@project) if @project
99+
```
100+
This pattern appears in every macro and controller action. The plugin can be disabled per-project.
101+
102+
### Permission Checks
103+
Layer permission checks after module enablement:
104+
```ruby
105+
return nil unless WikiExtensionsUtil.is_enabled?(@project) if @project
106+
User.current.allowed_to?({controller: 'wiki_extensions', action: 'action'}, @project)
107+
```
108+
109+
### Session State Management
110+
Macros use session storage for stateful behavior (e.g., access counting):
111+
```ruby
112+
session[:access_count_table] = Hash.new unless session[:access_count_table]
113+
unless session[:access_count_table][page.id]
114+
WikiExtensionsCount.countup(page.id)
115+
session[:access_count_table][page.id] = 1
116+
end
117+
```
118+
119+
### View Helpers
120+
- Complex HTML generation in `lib/wiki_extensions_helper.rb`
121+
- Tree-like comment display with JavaScript interaction
122+
- Contextual menus with permission-based visibility
123+
124+
### Internationalization
125+
- Locale files in `config/locales/`
126+
- Use `l(:symbol)` for translations
127+
- Support for 10+ languages
128+
129+
### JavaScript/CSS
130+
- Assets in `assets/` directory (not Rails standard `app/assets/`)
131+
- jQuery-based interactions
132+
- Separate stylesheets for print (`wiki_extensions_print.css`)
133+
134+
## Integration Points
135+
136+
### With Redmine Core
137+
- Hooks in `lib/wiki_extensions_application_hooks.rb`
138+
- Menu integration via `menu :project_menu` in `init.rb`
139+
- Activity provider for comment notifications
140+
- Email notifications via `WikiExtensionsCommentsMailer`
141+
142+
### Plugin Settings
143+
- Per-project settings via `WikiExtensionsSettingsController`
144+
- Settings stored in `wiki_extensions_settings` table
145+
- Feature toggles for different functionality
146+
147+
## Common Tasks
148+
149+
### Adding New Macro
150+
1. Create `lib/wiki_extensions_[name]_macro.rb`
151+
2. Follow macro registration pattern
152+
3. Add tests in `test/unit/`
153+
4. Update permissions in `init.rb` if needed
154+
5. **Always include module enablement check**: `WikiExtensionsUtil.is_enabled?(@project)`
155+
156+
### Adding Model/Feature
157+
1. Create migration in `db/migrate/`
158+
2. Add model in `app/models/` with proper associations
159+
3. Add controller actions if web interface needed
160+
4. Update permissions and routes
161+
5. Add project-specific feature toggles via `WikiExtensionsSetting`
162+
163+
### Debugging
164+
- Plugin works "only on production mode" (per README)
165+
- Use Rails logger: `Rails.logger.info`
166+
- Check `WikiExtensionsUtil.is_enabled?` for feature availability
167+
- Verify per-project settings via `WikiExtensionsSetting.find_or_create(project.id)`

.github/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
authors:
6+
- octocat
7+
categories:
8+
- title: Breaking Changes 🛠
9+
labels:
10+
- Semver-Major
11+
- breaking-change
12+
- title: New Features 🎉
13+
labels:
14+
- Semver-Minor
15+
- enhancement
16+
- title: Bug Fixes 🐛
17+
labels:
18+
- Semver-Patch
19+
- bug
20+
- title: Translations 🌐
21+
labels:
22+
- translation
23+
- title: Other Changes 📝
24+
labels:
25+
- "*"

.github/workflows/build.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
name: build
22
on:
33
push:
4+
branches:
5+
- '**'
6+
tags-ignore:
7+
- '**'
48
pull_request:
9+
workflow_dispatch:
510
env:
611
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
712
jobs:
@@ -10,8 +15,15 @@ jobs:
1015
strategy:
1116
matrix:
1217
db: [sqlite3, mysql, postgres]
13-
ruby_version: ["3.1", "3.2", "3.3"]
14-
redmine_version: [6.0-stable, master]
18+
ruby_version: ["3.1", "3.2", "3.3", "3.4"]
19+
redmine_version: [6.0-stable, 6.1-stable, master]
20+
exclude:
21+
- ruby_version: "3.4"
22+
redmine_version: 6.0-stable
23+
- ruby_version: "3.1"
24+
redmine_version: 6.1-stable
25+
- ruby_version: "3.1"
26+
redmine_version: master
1527
services:
1628
mysql:
1729
image: mysql:5.7
@@ -50,7 +62,7 @@ jobs:
5062
fail_ci_if_error: true
5163
- name: Slack Notification on Failure
5264
uses: rtCamp/[email protected]
53-
if: failure()
65+
if: failure() && env.SLACK_WEBHOOK != ''
5466
env:
5567
SLACK_CHANNEL: plugin-wiki_ext
5668
SLACK_TITLE: Test Failure
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Prevent Direct Pull Requests to Main
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
branches:
7+
- main
8+
9+
permissions:
10+
pull-requests: write
11+
issues: write
12+
13+
jobs:
14+
prevent-main-pr:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Comment and close PR
18+
uses: actions/github-script@v8
19+
with:
20+
script: |
21+
const message = "## ⚠️ Direct pull requests to main branch are not allowed. Please create a pull request to the develop branch instead.";
22+
23+
// Add comment
24+
await github.rest.issues.createComment({
25+
issue_number: context.issue.number,
26+
owner: context.repo.owner,
27+
repo: context.repo.repo,
28+
body: message
29+
});
30+
31+
// Close the PR
32+
await github.rest.pulls.update({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
pull_number: context.issue.number,
36+
state: 'closed'
37+
});
38+
39+
console.log('PR has been commented and closed automatically');

.hgeol

Lines changed: 0 additions & 2 deletions
This file was deleted.

.hgignore

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)