1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 20:04:24 +02:00

Compare commits

..

1500 Commits

Author SHA1 Message Date
David Sevilla Martin
4c8af1cdf8 common: use AlertState for Alert component data - pass this to AlertManager
app.alerts.show() now can take plain object OR AlertState instance - will return AlertState.prototype.key
app.alerts.dismiss() takes AlertState or state key (returned by show())
2020-05-03 17:45:55 -04:00
David Sevilla Martin
4a5a5a9ef0 forum: uncomment discussion list pane methods 2020-05-03 16:41:38 -04:00
David Sevilla Martin
1d83b740d2 forum: pass key to home route with current time to recreate components 2020-05-03 16:05:22 -04:00
David Sevilla Martin
b180cd9daf common: change mapRoutes from using resolver, and pass vnode attrs 2020-05-03 16:04:38 -04:00
David Sevilla Martin
0302a2c5a7 forum: move DiscussionList component logic into a custom state class
Only the state has to be saved to app.cache.discussionList
Cleans up the component class
2020-05-03 16:03:27 -04:00
David Sevilla Martin
bd2850d5ea common: merge admin & forum Page components
Now both extend src/common/components/Page.tsx
Admin component is the exact same as common
Forum component extends common & adds one line
2020-05-03 16:00:00 -04:00
David Sevilla Martin
c5f1e30855 admin: export AdminLinkButtonProps interface 2020-05-03 14:48:21 -04:00
David Sevilla Martin
b00eae1ce9 common: add routeName to component props in mapRoutes 2020-05-03 10:48:33 -04:00
David Sevilla Martin
717e8aa27e common: fix Button children issue introduced in admin PR 2020-05-03 10:42:25 -04:00
David Sevilla Martin
8b4046fdd4 Update JS dependencies & fix default route if URL has doesn't exist 2020-05-03 09:29:28 -04:00
Alexander Skvortsov
8437e44112 Admin link button typing minor cleanup 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
df08d174ff Compile dist 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
ef9612f55e Removed accidential comment 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
14ea7101fc Prettifier 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
5e6251204b Added all admin exports to compat 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
c1c2a15b96 Add extensions page 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
6823cdc3b8 Added extension typing to admindata interface 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
8980189917 Removed more outdated license docblocks 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
ea880632e1 Added Appearance page 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
e9ad848530 Fixed settings modal form method typing 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
9a3aec6079 Added permissions page 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
77eefc85c6 Add mail settings page 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
8e9f006c3a Updated saveSettings to actually save settings 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
b7af59fe43 Fixed select onchange not working 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
b952f6a2bc Added Basics page 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
2bf190ffab Mithril/typing redo for upload image button and settings modal 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
5a8eb2f978 Add settings to AdminDate type 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
7756c78805 Explicitly import app in SettingDropdown 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
a344319dde Update admin's page.tsx 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
c6062019c5 Removed outdated config method from primary and secondary header 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
532e866760 Fixed typing of app data in status widget 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
28f2341430 Typing fix for status widget 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
bfc6ed2e99 LoadingModal typing fix 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
968ece2c61 Widget Cleanup
Removed unused Widget (which is duplicate of DashboardWidget), made DashboardWidget abstract
2020-05-03 09:26:21 -04:00
Alexander Skvortsov
d83d082c4a Removed license docblock that we don't use anywhere else in the frontend 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
8b6f9ddbfe Change admin route prefix to #, not #! 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
990cdbc571 Ultra-basic admin site (dashboard page only) 2020-05-03 09:26:21 -04:00
Alexander Skvortsov
a7937edac7 common: button typings improvements (#2139) 2020-04-30 17:09:43 -04:00
David Sevilla Martin
91522f84c5 lint code 2020-04-20 16:51:44 -04:00
David Sevilla Martin
2c2f6fd4ed Add less changes from #1950
They got lost when I dropped the commits
2020-04-20 15:44:53 -04:00
David Sevilla Martin
81b2f4a74e Build JS 2020-04-18 09:18:59 -04:00
David Sevilla Martin
11e373f299 Modify JSON prettier configuration, make commands use it, add husky from master branch 2020-04-18 09:12:55 -04:00
Alexander Skvortsov
c1a4f19399 common: add Select component (#2125) 2020-04-18 09:07:30 -04:00
David Sevilla Martin
d644b490cd forum: add Pane util 2020-04-18 09:07:30 -04:00
David Sevilla Martin
5e853aa52d common: add Navigation component 2020-04-18 09:07:29 -04:00
David Sevilla Martin
84d977f819 forum: add notifications page (used in mobile) 2020-04-18 09:07:29 -04:00
David Sevilla Martin
58164b680a forum: add EditUserModal component 2020-04-18 09:07:29 -04:00
Alexander Skvortsov
860e91f317 Fix typo in classnames expose-loader import (#2122) 2020-04-18 09:07:29 -04:00
David Sevilla Martin
be844519f2 update prettier to v2 & format files 2020-04-18 09:07:29 -04:00
David Sevilla Martin
458045ad33 common: update micromodal 2020-04-18 09:07:28 -04:00
David Sevilla Martin
99b5b5ff00 forum: fix PostStreamScrubber not showing unread count 2020-04-18 09:07:28 -04:00
David Sevilla Martin
8a07bb68f6 forum: fix PostStream dates with dayjs in between long periods of time 2020-04-18 09:07:28 -04:00
David Sevilla Martin
dbc3aac14e forum: add RenameDiscussionModal, DiscussionRenamedPost and EventPost components 2020-04-18 09:07:28 -04:00
David Sevilla Martin
37cec1487e common: fix modal animation on mobile & tweak some transition & animation css 2020-04-18 09:07:27 -04:00
David Sevilla Martin
39dc303b80 forum: add colorthief - NOT color-thief-browser (outdated, same package) 2020-04-18 09:07:27 -04:00
David Sevilla Martin
88aa9fc038 forum: create app.ts file that exports Forum instance
This file can now be imported so 'app' is an instance of Forum instead of just Application - for typings
2020-04-18 09:07:27 -04:00
David Sevilla Martin
d73f1d8a67 common: add compat 2020-04-18 09:07:27 -04:00
David Sevilla Martin
82ef5f975c forum: remove 'controls' from user, moderation, and destructive controls in util 2020-04-18 09:07:27 -04:00
David Sevilla Martin
717442741f update changes file 2020-04-18 09:07:26 -04:00
David Sevilla Martin
0dc846bc4a change some typings, rename $.fn.animatedScrollTop to $.fn.animateScrollTop 2020-04-18 09:07:26 -04:00
David Sevilla Martin
83d0345e93 build js 2020-04-18 09:07:26 -04:00
David Sevilla Martin
8f7435f3fc forum: fix post stream scrubber dragging on mobile 2020-04-18 09:07:25 -04:00
David Sevilla Martin
f9cda85937 forum: fix avatar editor not uploading 2020-04-18 09:07:25 -04:00
David Sevilla Martin
cfc0000df0 forum: fix setting history state multiple times when scrolling in DiscussionPage 2020-04-18 09:07:25 -04:00
David Sevilla Martin
c819a8d520 forum: change some title attributes to transText 2020-04-18 09:07:25 -04:00
David Sevilla Martin
2a6360216e common: remove Bus, fix typing for requestError 2020-04-18 09:07:25 -04:00
David Sevilla Martin
c95f7b89bf build dev 2020-04-18 09:07:25 -04:00
David Sevilla Martin
afda17bc5f update dependencies & fix vulnerabilities 2020-04-18 09:07:24 -04:00
David Sevilla Martin
3027916d97 forum: use 'extract' in GroupBadge instead of 'delete' 2020-04-18 09:07:24 -04:00
David Sevilla Martin
babbda044b common: move the component children prop logic to Component class instead of patchMithril
Should make easier debugging if something doesn't work as well
2020-04-18 09:07:24 -04:00
David Sevilla Martin
66b839d241 common: rework Component#render again to simplify substite m(class, props)
Can be used instead of m(DiscussionList, app.cache.discussionList.props), for example - it's now app.cache.discussionList.render()
2020-04-18 09:07:24 -04:00
David Sevilla Martin
5bc6e52190 common: add AlertManager 2020-04-18 09:07:24 -04:00
David Sevilla Martin
58e096a8cc compile dev js 2020-04-18 09:07:24 -04:00
David Sevilla Martin
9b83159be5 change a few typings 2020-04-18 09:07:23 -04:00
David Sevilla Martin
e86940b6a3 common: remove falsy params when using app.route() 2020-04-18 09:07:23 -04:00
David Sevilla Martin
c615fb96c9 forum: add IndexPage and WelcomeHero components + $.fn.slideUp() 2020-04-18 09:07:23 -04:00
David Sevilla Martin
0356ecf379 common: use 'lodash' instead of 'lodash-es' because 'lodash-es' adds megabytes to development build 2020-04-18 09:07:23 -04:00
David Sevilla Martin
ef47e09300 revert Application implementation from experimental breaking change to use existing implementation in master 2020-04-18 09:07:23 -04:00
David Sevilla Martin
4484f3e35f common: add more typings to Model, fix type issues with Session and Store 2020-04-18 09:07:22 -04:00
David Sevilla Martin
cc6619466e common: fix Model issue resetting relationships when pushing data 2020-04-18 09:07:21 -04:00
David Sevilla Martin
0a5493c631 forum: add SignUpModal component 2020-04-18 09:07:21 -04:00
David Sevilla Martin
93e565ccee common: run ModalManager#onready once fade in animation ends
This makes sure the component has been initialized (exists in app.modal.component) and the zoom & fade in animations have completed
2020-04-18 09:07:21 -04:00
David Sevilla Martin
c4cb731f1b common: change ModalManager#show to accept two parameters instead of a component class instance 2020-04-18 09:07:21 -04:00
David Sevilla Martin
58ccb8415a common: use 'extend' with modal manager oninit, run clear method when fade out completes 2020-04-18 09:07:21 -04:00
David Sevilla Martin
d29b5c7262 common: move modal manager clear code to clear method, and call it on micromodal close 2020-04-18 09:07:20 -04:00
David Sevilla Martin
2ca078618b common: rewrite modal manager to not store vnode 2020-04-18 09:07:20 -04:00
David Sevilla Martin
22a031a3f1 common: fix Button not showing loading spinner 2020-04-18 09:07:20 -04:00
David Sevilla Martin
da31fc2619 forum: add change password & email modal components 2020-04-18 09:07:20 -04:00
David Sevilla Martin
c3237d4845 remove console log 2020-04-18 09:07:19 -04:00
David Sevilla Martin
f0140c6656 forum: fix zepto selector in PostStream 2020-04-18 09:07:19 -04:00
David Sevilla Martin
35b91c98da forum: add PostEdited and PostMeta components 2020-04-18 09:07:19 -04:00
David Sevilla Martin
d6b07153ec common: add fullTime helper 2020-04-18 09:07:19 -04:00
David Sevilla Martin
6a67167eed common: fix subtree retainer not adding new callback checks 2020-04-18 09:07:18 -04:00
David Sevilla Martin
dcb3cc1701 forum: make Discussion Page properly redraw PostStream - don't store vnode
Issue is that the code now looks like an ugly mess. :/
2020-04-18 09:07:18 -04:00
David Sevilla Martin
b9583943c5 forum: fix PostStream not scrolling to post number on load & potential issues with app.route.discussion 2020-04-18 09:07:18 -04:00
David Sevilla Martin
31cfe0f9df forum: resolve some typings issues & move Notifications to not use Component#render 2020-04-18 09:07:18 -04:00
David Sevilla Martin
dfcc099040 forum: add PostStreamScrubber, refactor things to move away from Component#render
Post components don't seem to be redrawing for some reason when in the PostStream - this doesn't seem to be caused by the subtree retainer, none of the lifecycle hooks are called when Mithril redraws, as far as I can tell
2020-04-18 09:07:18 -04:00
David Sevilla Martin
c8e97f295d update rewrite changes changelog 2020-04-18 09:07:17 -04:00
David Sevilla Martin
4910205dc7 bring local dev flarum-webpack-config to core for easier development 2020-04-18 09:07:17 -04:00
David Sevilla Martin
8ea7f9bc17 common: add formatNumber - use toLocaleString and support current application locale + custom options 2020-04-18 09:07:17 -04:00
David Sevilla Martin
3bf7f6f85b common: modify Component#render to properly do what it is supposed to - modify the original instance 2020-04-18 09:07:17 -04:00
David Sevilla Martin
68c17f2c30 common: add rest of Translator class 2020-04-18 09:07:17 -04:00
David Sevilla Martin
c03e0f7f75 remove 'old' folder from git 2020-04-18 09:07:17 -04:00
David Sevilla Martin
bcaa6f4d8a forum: make DiscussionPage use m.route.set to change route 2020-04-18 09:06:52 -04:00
David Sevilla Martin
fa47228b3f common: make Evented wrapper arguments into Array 2020-04-18 09:06:52 -04:00
David Sevilla Martin
241b8cc99c common: add actual ComponentProps file that hadn't been commited 2020-04-18 09:06:52 -04:00
David Sevilla Martin
eeae395a15 build JS 2020-04-18 09:06:52 -04:00
David Sevilla Martin
f24aafd47b a few fixes here & there - cache typehinting moved to Forum.ts, don't use button link in PostUser 2020-04-18 09:06:52 -04:00
David Sevilla Martin
2a66dc5572 forum: add DiscussionsUserPage component 2020-04-18 09:06:52 -04:00
David Sevilla Martin
80d8707d15 common: add SplitDropdown component - used in discussion page 2020-04-18 09:06:52 -04:00
David Sevilla Martin
21d19df9bd forum: add DiscussionList component with DiscussionListItem & TerminalPost 2020-04-18 09:06:52 -04:00
David Sevilla Martin
7485559cbf forum: add DiscussionPage with hero, loading post, post preview, post stream, reply placeholder
No post stream scrubber yet. Composer hasn't been added either, so many calls return errors because of app.composer not being set.
2020-04-18 09:06:51 -04:00
David Sevilla Martin
4368dfcc6c common: add humanTime helper 2020-04-18 09:06:51 -04:00
David Sevilla Martin
8ba86f9c5e common: add utils abbreviateNumber, anchorScroll, Evented, ScrollListener
Evented is now a class instead of an object - it can be extended from a class now. Object.assign can still be used with it, but instead of `evented` with `Evented.prototype`
2020-04-18 09:06:51 -04:00
David Sevilla Martin
4f79a05a4b change use of classNames so no arrays/objects are used, just spread arguments 2020-04-18 09:06:51 -04:00
David Sevilla Martin
eae6a11719 common: fix computed util when only passing one key as a string 2020-04-18 09:06:51 -04:00
David Sevilla Martin
f75c2cfc9c forum: do not update lastSeenAt when modifying discloseOnline preference
This value is immediately set in the backend again, so apart from causing visual glitches, it is useless as the preference doesn't prevent admins from seeing your last seen at time
2020-04-18 09:06:51 -04:00
David Sevilla Martin
f22f4c02e6 common: mark some ModalManager methods/properties as protected 2020-04-18 09:06:51 -04:00
David Sevilla Martin
3410bf0935 use .render a bit more... hopefully no weird errors or issues arise 2020-04-18 09:06:51 -04:00
David Sevilla Martin
6656820f24 forum: add NotificationGrid and SettingsPage - missing modals 2020-04-18 09:06:51 -04:00
David Sevilla Martin
66745916b3 common: add constructor & render method to Component 2020-04-18 09:06:50 -04:00
David Sevilla Martin
220a36c2e4 common: add Checkbox, Switch, FieldSet components 2020-04-18 09:06:50 -04:00
David Sevilla Martin
dfedd585f5 add prettier config and prettify javascript 2020-04-18 09:06:50 -04:00
David Sevilla Martin
dd13ff4169 update npm dependencies and add prettier to dev 2020-04-18 09:06:50 -04:00
David Sevilla Martin
4e96900dee forum: fix index.filter route overriding 'settings' route 2020-04-18 09:05:34 -04:00
David Sevilla Martin
d404b11fcd common: fix listItems marking all items as active 2020-04-18 09:05:34 -04:00
David Sevilla Martin
fb50540be4 common: use proper request attribute for Store.prototype.find
The property is 'params' instead of 'body' or 'data'
2020-04-18 09:05:33 -04:00
David Sevilla Martin
b2cbbd5862 forum: use transText on user delete control confirmation 2020-04-18 09:05:33 -04:00
David Sevilla Martin
d6a4058c28 forum: change some LinkButton code to properly work with 'active' attribute 2020-04-18 09:05:33 -04:00
David Sevilla Martin
be6a41ad0e common: fix listItems not working as intended with mithril v2 2020-04-18 09:05:33 -04:00
David Sevilla Martin
557bb086f9 forum: add components/LogInButtons 2020-04-18 09:05:33 -04:00
David Sevilla Martin
1f1986c527 Remove immediate debug in app.request 2020-04-18 09:05:33 -04:00
David Sevilla Martin
6978c0aa77 Implement latest 'master' branch changes - not including files that haven't been ported yet 2020-04-18 09:05:33 -04:00
David Sevilla Martin
660cd1c81e Fix ModalManager not allowing vnodes, make modals set themselves to app.modal.component when created 2020-04-18 09:05:32 -04:00
David Sevilla Martin
87792f5911 Fix Button component not working because of attrs.children being frozen 2020-04-18 09:05:32 -04:00
David Sevilla Martin
056e6c0fea Update changes 2020-04-18 09:05:32 -04:00
David Sevilla Martin
0de0c83353 Fix listItems isSeparator function, add m() children to attrs, work on posts, subtree retainer 2020-04-18 09:05:32 -04:00
David Sevilla Martin
49d2539aef Added some more type hinting, changed arguments for computed util 2020-04-18 09:05:32 -04:00
David Sevilla Martin
b47ba94a9b Include flarum webpack config shims in core shims 2020-04-18 09:05:32 -04:00
David Sevilla Martin
39c8ef4ddb Remove dayjs from flarum/core specific shims 2020-04-18 09:05:31 -04:00
David Sevilla Martin
654a0b5da1 Fix issues with error alert and them being in modals 2020-04-18 09:05:31 -04:00
David Sevilla Martin
2fd3aa8c71 Update app.request calls to use 'body' instead of 'data' for form data 2020-04-18 09:05:31 -04:00
David Sevilla Martin
48dccda707 Add ModalManager & LogInModal, add bidi attribute, fix Translator issues with text and vnodes 2020-04-18 09:05:31 -04:00
David Sevilla Martin
b885346029 Fix m.withAttr for input value, show search results, fix some old m.route code
TODO: Fix "SyntaxError: '> li:not(.Dropdown-header)' is not a valid selector" when hovering search results in navbar
2020-04-18 09:05:31 -04:00
David Sevilla Martin
c037598537 Remove constructor calls in app.routes, they aren't needed 2020-04-18 09:05:31 -04:00
David Sevilla Martin
6401e45b56 Start work on user page, fix routes not working 2020-04-18 09:05:31 -04:00
David Sevilla Martin
c6bcb79541 Add notifications, and frontend framework rewrite changes changelog file 2020-04-18 09:05:30 -04:00
David Sevilla Martin
46eab64f41 Add Translator#transChoice method that extracts text
Fixes #1200
2020-04-18 09:05:30 -04:00
David Sevilla Martin
9a5063c083 done a bunch of work, header secondary has some components, app.request works, idk... 2020-04-18 09:05:30 -04:00
David Sevilla Martin
3c84f41070 did a thing, struff works now :o 2020-04-18 09:02:49 -04:00
flarum-bot
798a3486bf Bundled output for commit 89ef14faf1 [skip ci] 2020-04-17 09:59:47 +00:00
Franz Liedke
89ef14faf1 Run prettier for all JS files 2020-04-17 11:57:55 +02:00
Franz Liedke
84cf938379 Merge pull request #2099 from flarum/fl/prettier
Install prettier for consistent JS styling
2020-04-17 11:20:52 +02:00
Franz Liedke
899cdfda4e CI: Run prettier to check for JS code formatting 2020-04-17 11:14:37 +02:00
Franz Liedke
72ed4faa83 Setup husky for automatic formatting before commit 2020-04-17 10:45:36 +02:00
Franz Liedke
64ad21e5da Add NPM shortcut for running prettier 2020-04-17 10:45:05 +02:00
Franz Liedke
14e8e9a7cb Configure prettier via JSON file 2020-04-17 10:44:36 +02:00
Franz Liedke
ee996e2cae Install prettier 2020-04-17 10:44:31 +02:00
Franz Liedke
7b35674e4a Merge pull request #2117 from flarum/fl/2055-streamline-uploads
Simplify uploads, avoid Application contract
2020-04-15 22:52:03 +02:00
Franz Liedke
1d953b3514 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-04-13 09:59:07 +00:00
Franz Liedke
b7d8f77529 Tweak event extender (tests)
- Inject contract, not implementation
- Do not dispatch event in test, let the core do that
- Ensure the relevant database tables are reset prior to the test
- Use correct parameter order for assertions

Refs #2097.
2020-04-13 11:58:47 +02:00
Franz Liedke
b343206c7b Tweak mail extender (tests)
- Use private over protected
- Use "public" API for building requests in tests
- Add more assertions
- Formatting
- Use correct parameter order for assertions

Refs #2012.
2020-04-13 11:58:46 +02:00
flarum-bot
2aead54aea Bundled output for commit dbfae0b55e [skip ci] 2020-04-13 09:22:40 +00:00
Alexander Skvortsov
dbfae0b55e Add year, localization support for displaying things older than 1 year (#2034) 2020-04-13 11:21:27 +02:00
Alexander Skvortsov
2d86eb9b9f Mail Extender (#2012)
This allows registering new drivers, or overwriting existing ones.
2020-04-13 10:46:33 +02:00
Alexander Skvortsov
3ac5e58fa1 Add event extender (used for domain events) (#2097) 2020-04-13 10:45:34 +02:00
Alexander Skvortsov
ffa56595c3 Improved UI of Switch with loading indicator (#2039)
* Moved loading indicator outside of checkboxes to improve ui
* Made loading indicator more visible, fade label when switch is loading
2020-04-10 22:51:58 +02:00
flarum-bot
453c44632d Bundled output for commit 117c2f65ac [skip ci] 2020-04-10 19:18:00 +00:00
w-4
117c2f65ac Fix PostStreamScrubber click (#1945) 2020-04-10 21:16:57 +02:00
Franz Liedke
cd9edf656b ForumSerializer: Use UrlGenerator for base URLs
The test from the previous commit proves this works as intended. :)

This is one more step in trying to avoid the widespread usage of the
`Application` godclass.

Refs #2055.
2020-04-10 17:46:15 +02:00
Franz Liedke
8c19ba1aaa Add integration test for API root endpoint 2020-04-10 17:46:15 +02:00
Hasan Özbey
3f5554816e Fix mobile notification bubble on colored header (#2109) 2020-04-10 12:50:36 +02:00
flarum-bot
cb9801a324 Bundled output for commit fd4c0d30d8 [skip ci] 2020-04-10 10:32:46 +00:00
Taraflex
fd4c0d30d8 Protect dismissible modals from closing by ESC key 2020-04-10 12:30:56 +02:00
Franz Liedke
922e294668 Permissions page: Tweak icon styling
- Give them a fixed width (independent of font library)
- Center the icons in their column
- De-emphasize the icons by applying a muted color

Fixes #2016, closes #2018.
2020-04-10 12:01:04 +02:00
Franz Liedke
1fa37a7a6a Simplify uploads, inject filesystem instances
This avoids injecting the Application god class and assembling default
file locations in multiple places.

In addition, we no longer use the `MountManager` for these uploads. It
only added complexity (by moving tmp files around) and will not be
available in the next major release of Flysystem.

Note: Passing PSR upload streams to Intervention Image requires an
explicit upgrade of the library. (Very likely, users have already
updated to the newer versions, as the old constraint allowed it, but
we should be explicit for correctness' sake.)
2020-04-10 11:38:57 +02:00
Franz Liedke
1cbb2a365e Validate PSR-compatible file upload
Instead of converting the uploaded file object to an UploadedFile
instance from Symfony, because the latter is compatible with
Laravel's validation, let's re-implement the validation for the
three rules we were using.

The benefit: we can now avoid copying the uploaded file to a
temporary location just to do the wrapping.

In the next step, we will remove the temporary file and let the
uploader / Intervention Image handle the PSR stream directly.
2020-04-10 11:38:55 +02:00
Charlie
4c50c8d77a Change default discussion comment count
This allows new public discussions to be immediately visible by users.
2020-04-08 01:13:52 +02:00
Alexander Skvortsov
0d57820b50 Added CSRF Extender (#2095) 2020-04-03 21:32:18 +02:00
flarum-bot
ecdd7a2b49 Bundled output for commit 30942bdf38 [skip ci] 2020-04-03 19:27:57 +00:00
Sami Mazouz
30942bdf38 Fix new post injected above unread sticky (#1868)
Refresh the discussion list instead of prepending the new post
2020-04-03 21:26:51 +02:00
Alexander Skvortsov
345ad4bc6d Add console extender (#2057)
* Made the console command system extender-friendly

* Added console extender

* Added ConsoleTestCase to integration tests

* Added integration tests for console extender

* Marked event-based console extension system as deprecated

* Moved trimming command output of whitespace into superclass

* Renamed 'add' to 'command'

* Added special processing for laravel commands

* Code style fixes

* More style fixes

* Fixed $this->container
2020-04-03 19:38:54 +02:00
Alexander Skvortsov
03a4997a1c Send emails through the queue 2020-04-03 13:47:12 +02:00
flarum-bot
857fd95b5e Bundled output for commit dd43e49d0a [skip ci] 2020-04-03 10:03:45 +00:00
Franz Liedke
dd43e49d0a Update JS dependencies to secure versions 2020-04-03 12:02:18 +02:00
Franz Liedke
4efdd2a4f2 Deprecations: Add removal dates and replacements 2020-04-03 11:46:32 +02:00
Hasan Özbey
b286e39429 fix extensions page layout 2020-04-03 11:44:02 +02:00
Franz Liedke
1cda9dca4f Revert BC breaks around notification blueprints
No need for breaking backwards compatibility here - encapsulating the
logic for `getAttributes()` in one place turns out to be quite useful.

Refs #1931.
2020-04-03 11:33:33 +02:00
flarum-bot
e16d57d4e2 Bundled output for commit 2e2aa8747e [skip ci] 2020-04-01 12:42:05 +00:00
Daniël Klabbers
2e2aa8747e fixed an issue with Post--by-start-user for discussions that contain posts of deleted users 2020-04-01 14:40:40 +02:00
flarum-bot
44ac2ec8ee Bundled output for commit 6bbd603a41 [skip ci] 2020-03-30 19:19:56 +00:00
Hasan Özbey
6bbd603a41 Update ModalManager.js 2020-03-30 21:18:48 +02:00
Hasan Özbey
a4910f3d94 Update Modal.less 2020-03-30 21:18:48 +02:00
Hasan Özbey
f003f6e04a fix modals 2020-03-30 21:18:48 +02:00
Franz Liedke
2fe3987c19 Use UrlGenerator over Application for base URL
We need to get rid of this god class, as Laravel's Application contract
gets even bigger with 5.8. To avoid having to add all these methods, we
should try to stop using it where we can.
2020-03-28 11:17:45 +01:00
Franz Liedke
f4ab6f4b1f Laravel: Stop calling deprecated fire() method
This has been deprecated and removed from the contract for a long time,
and it will be completely dropped in v5.8, our next upgrade target.
2020-03-28 11:08:44 +01:00
Franz Liedke
9ae8bcdffe Make tests compatible with PHPUnit 8 2020-03-28 11:06:47 +01:00
Franz Liedke
29bdd471bc Merge pull request #1931 from flarum/dk/1869-queue-notifications
Notifications into the queue
2020-03-27 23:06:36 +01:00
Franz Liedke
fb70826469 Add new method to DiscussionRenamedBlueprint 2020-03-27 16:22:39 +01:00
Franz Liedke
bbe7e97ba1 Add BC layer for notification blueprints
This gives extension authors time to add the new `getAttributes()`
method to their `BlueprintInterface` implementations.

The layer itself is easy to remove in beta.14.
2020-03-27 16:22:38 +01:00
Franz Liedke
310065fb1c Remove unnecessary constructor parameter 2020-03-27 16:22:38 +01:00
Franz Liedke
23da7b3373 Remove Notifying event for now
As discussed with @luceos, let's add this once the use case comes up. It
might be a left-over from a previous state of this PR anyway.
2020-03-27 16:22:37 +01:00
Daniël Klabbers
2ba29a9088 Moved sending emails to the syncer
This separates sending each individual mail, thus hardening the app.
There are still many improvements possible in this code, e.g. chaining
these commands, making emails just another notification type and
listening to the Notify event instead. We can postpone this to a later
stable release.
2020-03-27 16:22:37 +01:00
Daniël Klabbers
cd8a8e9dd7 Notifications into the queue
Forces notifications into a dedicated SendNotificationsJob and passed
to the queue.

- One static method re-used in the job ::getAttributes, is that okay or
  use a trait?
- Do we want to use this solution and refactor into a better Hub after
  stable, postpone this implementation or use it in b11?
2020-03-27 16:16:36 +01:00
Franz Liedke
6b3d634917 Convert last two controller tests to request tests 2020-03-27 13:39:38 +01:00
Daniël Klabbers
8c6fac62d6 fixes checking for enabled extension and correct pointer of 30c6ea9912 2020-03-27 13:29:16 +01:00
Franz Liedke
02e72f4b03 Rename API tests for more consistency
I could not come up with a noun for the new "UpdateTest" for users, so
this is easier in terms of consistency.
2020-03-27 13:22:27 +01:00
Franz Liedke
e3f1e69748 Convert more controller tests to request tests 2020-03-27 13:21:10 +01:00
Matt Kilgore
bc7cea6e61 Fix test and extender for middleware (#2084) 2020-03-27 11:00:30 +01:00
Daniël Klabbers
30c6ea9912 Resolved enabled extension test
The getEnabled method returns all extensions (previously) enabled, yet manually
uninstalled through composer. This does not reference the exact, current state
of the forum. getEnabledExtensions returns a list where the getEnabled list
is filtered on the extensions found in the composer installed.json file.
2020-03-25 11:47:39 +01:00
Matt Kilgore
0bc06e1bb1 fix insertAfter and insertBefore middleware extender functions (#2063) 2020-03-20 22:59:57 +01:00
Franz Liedke
b10a17529d Convert more controller tests to request tests 2020-03-20 18:54:20 +01:00
Franz Liedke
bc80085ce4 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-03-20 17:28:58 +00:00
Franz Liedke
f31fbc5bcf Tests: Use new authenticatedAs option where useful
There are two more API integration tests that explicitly add the
"Authorization" header right now:

- `Flarum\Tests\integration\api\authentication\WithApiKeyTest`
- `Flarum\Tests\integration\api\csrf_protection\RequireCsrfTokenTest`

These two specifically test authentication, so in those cases the
explicitness seems desirable.
2020-03-20 18:28:35 +01:00
Franz Liedke
25f772c1ea Replace authenticatedRequest() by request() option
I feel this makes the parameters a bit more clear, does not rely on
inheritance (you can only inherit from one class, but we might want more
of these helpers in the future), and has less side effects (e.g. no
creation and, more importantly, deletion of users in the database).

Refs #2052.
2020-03-20 18:23:06 +01:00
Franz Liedke
a13c0bb612 Tests: Extract trait for building requests 2020-03-20 17:51:03 +01:00
Alexander Skvortsov
4791cc77b3 Add Authenticated Test Case utility 2020-03-20 17:18:35 +01:00
Alexander Skvortsov
e10da825d4 Users should not be able to restore discussions if deleted by admins (#2037) 2020-03-20 15:57:03 +01:00
Franz Liedke
a2d1d2b819 Update less.php to version 3.0
Now that we require PHP 7.2, this ensures we get the latest updates and
fixes as well.

Refs #1988.
2020-03-17 23:12:23 +01:00
Matt Kilgore
fb277df3b0 Change Extenders properties to private (#1958) 2020-03-17 22:37:17 +01:00
dependabot[bot]
a854fa8bcb Bump acorn from 6.4.0 to 6.4.1 in /js (#2065)
Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/6.4.0...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-03-17 22:29:36 +01:00
Franz Liedke
bc69588785 CI: Fix broken build on GitHub Actions
The MySQL service is no longer started by default on these agents.

See https://github.blog/changelog/2020-02-21-github-actions-breaking-change-ubuntu-virtual-environments-will-no-longer-start-the-mysql-service-automatically/.
2020-03-17 22:23:11 +01:00
flarum-bot
a2d1245e90 Bundled output for commit 090b05736a [skip ci] 2020-03-09 12:41:19 +00:00
Daniël Klabbers
090b05736a showing start user in class list now 2020-03-09 13:39:26 +01:00
Franz Liedke
4b45ce0a58 Add a baseline test for the middleware extender
Refs #2017.
2020-03-06 15:05:16 +01:00
Franz Liedke
9f8ee7dc94 Fix typo 2020-03-06 15:05:15 +01:00
Franz Liedke
4413848c11 Apply fixes from StyleCI
[ci skip] [skip ci]
2020-03-06 13:55:39 +00:00
Matt Kilgore
9212330ac2 Test Middleware extender (#2017) 2020-03-06 14:55:21 +01:00
Daniël Klabbers
455d070599 start using a dev stability version constant during the cycle 2020-03-05 10:50:30 +01:00
Franz Liedke
84ae88794f Remove deprecated ConfigureMiddleware Event (#2032) 2020-03-04 23:02:05 +01:00
Franz Liedke
ec3e9c722b Remove deprecated Flarum\Util\Str class 2020-03-04 22:59:14 +01:00
Franz Liedke
2e6cd584aa Remove mail settings backwards compatibility layer 2020-03-04 22:58:15 +01:00
Franz Liedke
27b0d1802e Merge branch 'refs/heads/v0.1.0-beta.12'
# Conflicts:
#	composer.json
2020-03-04 22:56:37 +01:00
Daniël Klabbers
2c02702d60 updated core developers in authors 2020-03-03 15:47:00 +01:00
Daniël Klabbers
9c3a016123 Update Application.php
updated version constant for b12
2020-03-03 15:38:15 +01:00
Alexander Skvortsov
0d208dc443 Drop support for PHP 7.1 (#2014)
* Updated PHP requirement to 7.2

* Set wikimedia less version to 1.8

* Indentation fix on composer json

* Revert "Set wikimedia less version to 1.8"

This reverts commit 22d862fd98.
2020-02-27 00:52:03 +01:00
Franz Liedke
e7c71ec445 Re-add mail settings backwards compatibility layer 2020-02-26 23:11:22 +01:00
Franz Liedke
46e2e17c3c Require new mail driver methods, remove BC layer 2020-02-26 22:56:09 +01:00
Alexander Skvortsov
f574f97174 Removed support for SES Mail Driver (#2011) 2020-02-26 22:36:27 +01:00
Alexander Skvortsov
674303b997 Remove Zend compatability bridge (#2010) 2020-02-26 22:29:44 +01:00
Franz Liedke
0fba2c0c0a Re-add util class and mark it as deprecated
This would be the only breaking change in beta.12. Let's stick to our
backwards compatibility promise / intentions as much as possible, even
if we assume the class has not been used anywhere.

This BC layer will be removed again for beta.13.

Refs #1975.
2020-02-26 22:14:23 +01:00
Franz Liedke
0666448ef5 Prepare changelog for beta.12 release 2020-02-26 21:10:52 +01:00
Matt Kilgore
08e40bc693 Force fixed version of text formatter 2020-02-25 11:27:59 +01:00
Franz Liedke
eaf1767008 Merge pull request #2002 from flarum/fl/extender-tests
Start testing extenders
2020-02-14 18:47:58 +01:00
flarum-bot
9f1eca555f Bundled output for commit 72fd32dbf6 [skip ci] 2020-02-14 14:57:19 +00:00
Clark Winkelmann
72fd32dbf6 Add disabled prop to the Select component (#1978) 2020-02-14 15:56:04 +01:00
Clark Winkelmann
d5ebbab3a7 Rename dead is_activated references with the new is_email_confirmed (#1974) 2020-02-14 15:34:32 +01:00
Matt Kilgore
17257aacaf Updates s9e/text-formatter to 2.x (#1982)
No additional changes required, tested with fof/formatting extension.
2020-02-14 12:34:40 +01:00
flarum-bot
f87c8c6dcd Bundled output for commit f9556d9d6a [skip ci] 2020-02-10 22:55:40 +00:00
D Mata
f9556d9d6a Update AvatarEditor.js onchange to oninput (#1570)
onchange does not work in IE11 and other IE browsers. This change works with all modern browsers as well.
2020-02-10 23:54:41 +01:00
Franz Liedke
fdfc6c0de2 CI: Test on PHP 7.4 as well
If we're lucky, this should fail right now, due to #1980.
2020-02-09 06:46:33 +01:00
Franz Liedke
64e4132c92 Switch to Wikimedia's less.php fork
The original library is no longer maintained. The fork supports PHP 7.4.
2020-02-09 06:46:33 +01:00
Franz Liedke
4b78a3114f Try to fix installer in PHP 7.4 2020-02-09 06:46:33 +01:00
Franz Liedke
c01eea58b6 Start testing Route extender 2020-02-08 00:04:32 +01:00
Franz Liedke
19cb74c856 Integration tests: Allow registering extenders 2020-02-07 23:29:14 +01:00
Franz Liedke
27bcdb949b Integration tests: Add lazy server helper
This allows sending requests directly in an integration test, without
having *explicitly* booted the app.
2020-02-07 23:28:37 +01:00
Franz Liedke
94fc460240 Integration tests: Create app lazily when needed
This will allow registering extenders in test scenarios. Previously,
this would not have had any effect as the app would have booted already.
2020-02-07 23:22:22 +01:00
flarum-bot
fc59f0fdd8 Bundled output for commit b91e903284 [skip ci] 2020-02-07 14:35:37 +00:00
Franz Liedke
b91e903284 Merge pull request #1938 from flarum/ds/1255-throttling-bypass-permission
Add permission to bypass throttling
2020-02-07 15:34:25 +01:00
David Sevilla Martín
711e775de7 Add permission to bypass throttling 2020-02-07 15:30:09 +01:00
flarum-bot
736e90d423 Bundled output for commit 2f3d9995d1 [skip ci] 2020-02-07 11:18:30 +00:00
Franz Liedke
2f3d9995d1 Fix race condition in post preview
The post composer could have been closed in between scheduling and
executing the callback.

Fixes flarum/org#58.
Refs #1881.
2020-02-07 12:17:11 +01:00
flarum-bot
ac14f84a9a Bundled output for commit 1d7641cbb0 [skip ci] 2020-02-07 11:06:58 +00:00
Franz Liedke
1d7641cbb0 Merge pull request #1921 from flarum/ds/1763-handle-incomplete-email-configuration
Improve handling of incomplete mail configuration
2020-02-07 12:05:41 +01:00
Franz Liedke
dce36cbeed New extender for error handling (#1970)
This extender implements several methods for extending the new error
handling stack implemented in #1843.

Most use-cases should be covered, but I expect some challenges for more
complex setups. We can tackle those once they come up, though. Basic
use-cases should be covered.

Fixes #1781.
2020-01-31 14:01:12 +01:00
flarum-bot
7e1087cba5 Bundled output for commit 8877bf97c4 [skip ci] 2020-01-31 12:34:20 +00:00
Franz Liedke
8877bf97c4 Merge pull request #1975 from flarum/fl/194-better-slugs
Use Laravel's slugger for basic transliteration
2020-01-31 13:32:55 +01:00
flarum-bot
7e74f5a03c Bundled output for commit 02ceed4fed [skip ci] 2020-01-26 22:38:29 +00:00
Clark Winkelmann
02ceed4fed Fix the "reply posted" alert empty body 2020-01-26 23:37:19 +01:00
Franz Liedke
27f159f6b8 Remove unnecessary use statement 2020-01-26 20:21:19 +01:00
ozzzzzzzam
499f33fbb6 Remove forum title from confirmation email subject (#1613)
The forum title is already used as the display name for the sender email address, so having it in the subject is just a duplication and waste of space.
2020-01-25 14:35:47 +01:00
Matthew Kilgore
8dd3bd420b Additional functionality for Middleware extender
Implements the remove, insertBefore, insertAfter and replace
functionality for middlewares.

The IoC container now holds one array of middleware (bindings) per
frontend stack - the extender operates on that array, before it is
wrapped in a middleware "pipe".

Fixes #1957, closes #1971.
2020-01-24 21:20:33 +01:00
Franz Liedke
2ca3188eff Add BC layer for mail driver configuration
By commenting out the new methods on the `DriverInterface` and checking
for these methods' existence before calling them, old implementations in
extensions will not break right away.

This will be removed after beta.12 is released, giving extension authors
about two months time to update their extensions.
2020-01-24 18:04:16 +01:00
Franz Liedke
f275bcdd2c Clarify the use-case of the JS slug helper 2020-01-24 17:42:14 +01:00
Franz Liedke
64c702aaf7 Use Laravel's slugger for basic transliteration
This is better than the current system, as it adds transliteration rules
for special characters, rather than just throwing all of them away.

For languages that cannot be transliterated to ASCII in a reasonable
manner, more possible improvements are outlined in #194.
2020-01-24 17:40:09 +01:00
Franz Liedke
833ea4e06e Connect labels with their form fields 2020-01-24 15:41:26 +01:00
Franz Liedke
5643ee649b Style validation errors 2020-01-24 15:41:26 +01:00
Franz Liedke
97b2db84c6 Mail drivers: Separate definition from validation 2020-01-24 15:41:26 +01:00
David Sevilla Martin
4fea25959c Change implementation to add validation rules, of which 'required' is shown in the frontend 2020-01-24 15:41:25 +01:00
David Sevilla Martin
8b70cec6a1 Add required fields, incomplete configuration warning, and null transport 2020-01-24 15:41:25 +01:00
flarum-bot
a330a8fa28 Bundled output for commit 02899d4f68 [skip ci] 2020-01-22 23:02:59 +00:00
David Sevilla Martín
02899d4f68 Add Content for User page, preload user & throw 404 accordingly (#1901) 2020-01-23 00:01:26 +01:00
Franz Liedke
76f7d566b2 Convert another test
Test the request, not a controller (implementation detail). This also
focuses on the observable behavior instead of hacking our way into the
middleware pipeline in order to observe internal behavior.

The authenticated user is now determined by looking at the API response
to compare permissions and (non-)existing JSON keys.
2020-01-22 23:39:41 +01:00
David Sevilla Martín
e296bbf0aa Initial template for Stale bot configuration (#1841) 2020-01-18 02:06:36 +01:00
Julian Berger
0a4ee93fde Get translations from fallback catalogues (#1961) 2020-01-17 23:37:50 +01:00
Franz Liedke
1e7fbf1ed9 Add backwards compatibility layer for mail drivers
Support the old format (a simple list of available fields), in addition
to the new format (a map from field names to their types + metadata).

This will be removed after beta.12 is released.
2020-01-14 11:45:44 +01:00
Franz Liedke
1170d5c2cf Document changes in mail driver interface 2020-01-14 11:44:29 +01:00
flarum-bot
fcbbedd884 Bundled output for commit 4c89e2eb77 [skip ci] 2020-01-10 17:18:42 +00:00
Vladimir Vinogradov
4c89e2eb77 Add Mailgun region setting
Fixes #1834.
2020-01-10 18:17:04 +01:00
Franz Liedke
809f353c52 Ensure page parameters are always integers 2020-01-09 00:45:50 +01:00
Matt Kilgore
d7a5a6ad14 Change Zend namespace to Laminas (#1963)
Also ensure backwards compatibility for extensions that use the Zend framework but don't explicitly require it.
2020-01-06 22:29:34 +01:00
luceos
ca0c52d60a Apply fixes from StyleCI
[ci skip] [skip ci]
2020-01-05 21:28:46 +00:00
Daniël Klabbers
2325e33e38 Update LICENSE 2020-01-05 22:28:27 +01:00
Matt Kilgore
aba291c542 Middleware extender (#1952) 2019-12-12 09:22:04 +01:00
flarum-bot
9b00244454 Bundled output for commit c1878fe29b [skip ci] 2019-12-10 14:40:37 +00:00
Franz Liedke
c1878fe29b Update Webpack 2019-12-10 15:38:56 +01:00
Franz Liedke
43c551929b Catch more exceptions during boot process
This extends our boot exception handling block to also catch and format
all exceptions that could be thrown while building our request handler,
i.e. the middleware stack handling requests.

The only exceptions that would now not be handled in this way could be
raised by Zend's `RequestHandlerRunner` and its delegates, which we
should be able to rely on.

Exceptions on request execution will be handled by the error handler in
the middleware stack.

Fixes #1607.
2019-12-07 01:16:48 +01:00
w-4
840e740309 Fix update page with custom base path (#1947)
Calling UpdateHandler causes RouteNotFoundException when basepath is not /.
2019-12-04 23:37:33 +01:00
Franz Liedke
babb36d375 Link to security policy from README 2019-12-04 21:51:53 +01:00
Franz Liedke
25b9d88469 FUNDING.yml does not inherit 2019-12-04 21:42:40 +01:00
Franz Liedke
b5c2285167 Add a custom FUNDING.yml file for this repository
Let's hope GitHub inherits the lines from our default community health
files at https://github.com/flarum/.github.
2019-12-04 21:41:41 +01:00
Daniël Klabbers
beaaa21f58 Update CHANGELOG.md 2019-12-02 10:36:41 +01:00
Daniel Klabbers
8a1bcf30d2 releasing beta 11.1 2019-12-02 09:28:48 +01:00
Franz Liedke
ff384569f8 Fix implementations of settings repo interface 2019-12-01 22:10:58 +01:00
Daniel Klabbers
f64a253450 Revert "7.4 release, forcing tests to work with them"
This reverts commit da5628d125.
2019-11-29 13:01:51 +01:00
Daniel Klabbers
da5628d125 7.4 release, forcing tests to work with them 2019-11-29 13:00:34 +01:00
David Sevilla Martín
a9c18c4753 Update Application version string to beta 11 2019-11-28 11:40:42 +01:00
Franz Liedke
d492579638 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-11-28 00:16:50 +00:00
Franz Liedke
19188e3eda Update copyright claims in LICENSE 2019-11-28 01:14:16 +01:00
Daniel Klabbers
8cc44a695f preparing the changelog for beta 11, part 2 2019-11-26 13:23:09 +01:00
Daniel Klabbers
7bb8b66596 preparing the changelog for beta 11 2019-11-26 12:59:29 +01:00
Clark Winkelmann
40f709e7c6 Fix tests to include expectation count and run user saving events 2019-11-26 10:13:18 +01:00
Clark Winkelmann
264ff9f7bb Add unit test for AvatarUploader 2019-11-26 10:13:18 +01:00
Clark Winkelmann
308f2c9efd Fix avatar files not being deleted. Fixes #1918 2019-11-26 10:13:18 +01:00
flarum-bot
2a8ed53934 Bundled output for commit 17c86b82bf [skip ci] 2019-11-24 19:01:17 +00:00
w-4
17c86b82bf history back function fix
it shouldn't check for canGoBack again after the array pop()
2019-11-24 13:59:51 -05:00
Daniel Klabbers
63b039a800 incorrect ability used, drop prefix discussion. 2019-11-22 08:17:02 +01:00
Daniel Klabbers
213045aa03 test only on the hidePosts policy ability 2019-11-22 08:17:02 +01:00
Daniel Klabbers
6d10dbe9af resume chain in query builder 2019-11-22 08:17:02 +01:00
Daniël Klabbers
4adf342ce3 [review] using orWhere to allow any where to follow in extensions 2019-11-22 08:17:02 +01:00
Daniël Klabbers
b150636906 fixes #1827
- set default statement to block access
- added tests to confirm all scenarios work as intended
2019-11-22 08:17:02 +01:00
Franz Liedke
4f1adba387 Automatically set up Mockery for unit tests
- Use provided PhpUnit listener to enforce verification of expectations.
- Include Mockery's trait to auto-close Mockery after each test.
2019-11-21 00:51:11 +01:00
Franz Liedke
879b801600 Actually return null
Nullable return types require an explicit null return value; not
returning or returning without value is the "void" type.
2019-11-21 00:46:01 +01:00
David Sevilla Martin
c712d23e9c Add test for discussion posts being deleted on discussion delete from DB 2019-11-18 09:23:53 +01:00
David Sevilla Martin
d69c4035d9 Fix failing tests 2019-11-18 09:23:53 +01:00
datitisev
b83adbccfd Apply fixes from StyleCI
[ci skip] [skip ci]
2019-11-18 09:23:53 +01:00
David Sevilla Martin
7b6c666e7b Remove 'or' from 'orWhereNotExists' 2019-11-18 09:23:53 +01:00
David Sevilla Martin
8b9f03e998 Add discussion_id foreign key to posts table 2019-11-18 09:23:53 +01:00
flarum-bot
e69f8965c7 Bundled output for commit 6d2b50722a [skip ci] 2019-11-15 14:10:15 +00:00
Clark Winkelmann
6d2b50722a Pass event to KeyboardNavigatable whenCallback (#1922)
This way the callback can know which key is pressed.
2019-11-15 15:08:36 +01:00
Daniël Klabbers
99a05900b1 Fix the queue:restart command (#1932)
Adding a proxy callStatic on our simple implementation of the Manager class allows passing through calls like `forever()` to the underlying cache driver instance.
2019-11-15 15:01:31 +01:00
Franz Liedke
cc5e586d38 Add a docblock 2019-11-13 21:19:21 +01:00
Daniël Klabbers
17074b8aab only show queue commands if using another driver than sync 2019-11-13 13:17:09 +01:00
flarum-bot
406c8ff834 Bundled output for commit 1ba4a0b87e [skip ci] 2019-11-12 19:27:29 +00:00
Daniël Klabbers
1ba4a0b87e Fix existing Post component classes being dropped 2019-11-12 20:26:07 +01:00
flarum-bot
36017f89fe Bundled output for commit 1f2566c32c [skip ci] 2019-11-11 12:00:45 +00:00
Daniël Klabbers
1f2566c32c Improved naming of class for post by actor.
Made class list for post extensible by using a separate method.
2019-11-11 12:59:26 +01:00
flarum-bot
0c74927eab Bundled output for commit 19ecd968c6 [skip ci] 2019-11-11 11:15:09 +00:00
Matthew Kilgore
19ecd968c6 Removed LESS changes 2019-11-11 12:13:36 +01:00
Matthew Kilgore
fc64660f5d Set border to left side only 2019-11-11 12:13:36 +01:00
Matthew Kilgore
d5d769ebb1 Added border around post made by active user 2019-11-11 12:13:36 +01:00
flarum-bot
f5ee37b394 Bundled output for commit 54c5c09693 [skip ci] 2019-11-09 13:51:55 +00:00
David Sevilla Martin
54c5c09693 Cleanup some code and fix alert dismiss not working 2019-11-09 08:50:24 -05:00
Moritz Stueckler
c87ebaef08 feat: re-add debug button/modal
Fixes #1687
2019-11-09 08:50:24 -05:00
David Sevilla Martin
9c0d921f49 Fix Modal width on <768px screens not occupying the whole page 2019-11-06 17:48:00 -05:00
flarum-bot
d7bdc173a4 Bundled output for commit 937354512b [skip ci] 2019-10-28 15:37:34 +00:00
Daniël Klabbers
937354512b Update User.js
Use recommended `anonymous`, see https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/crossOrigin
2019-10-28 16:35:45 +01:00
J.C.Ködel
2dedfe4b92 Fix Color Thief cross origin bug
When users have external avatar urls (for instance: in a SSO environment where the avatar is provided by another domain), color thief fails to get the avatar dominant color because the canvas would be tainted. 

Following the instructions here (https://lokeshdhakar.com/projects/color-thief/ on the "Does it work if the image is hosted on another domain?"), adding an `image.crossOrigin = 'Anonymous';` solves the issue.

Tested on my forum which before suffered from a JS error and works fine (without this fix, the canvas remain in the `body` while an script error is thrown by color thief)
2019-10-28 16:35:45 +01:00
Franz Liedke
9f6ec80432 Revert search performance regression
We decided it is better to have a less intelligent search (that does not
match search terms in titles) for some people than a bad-performing
search for everyone.

We will revisit the search performance topic in the next release cycle,
possibly with larger changes around indexing.

Refs #1738, #1741, #1764.
2019-10-26 15:41:39 +02:00
Daniël Klabbers
aa31b8307d improve queue error handling 2019-10-18 13:13:30 +02:00
Daniël Klabbers
dc06d5b5c9 added return type hint to memory cache 2019-10-08 15:51:19 +02:00
Daniël Klabbers
2c867d2292 add type hinting to settings repository 2019-10-08 15:39:01 +02:00
luceos
b09ac3f3f8 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-10-07 09:56:10 +02:00
Daniël Klabbers
21f54c5562 added ability to re-use existing error handling stack 2019-10-07 09:56:10 +02:00
David Sevilla Martin
a0ace316e8 Alias 'flarum.queue.connection' to Queue contract 2019-10-05 16:14:27 -04:00
Tariq Hussein
6c96c932e0 Fixes #1877 Replace getIdsForUsername() with subquery instead. (#1878) 2019-10-02 01:04:01 +02:00
flarum-bot
522e41aa71 Bundled output for commit bbd891965f [skip ci] 2019-10-01 21:50:25 +00:00
Madalin Tache
bbd891965f Update window size (#1894)
This small change attempts to fix #1727, as i just got my eye on it and figured i could simply fix it while seeing it.
2019-10-01 23:48:54 +02:00
flarum-bot
0f43445a90 Bundled output for commit 7a684660e9 [skip ci] 2019-10-01 21:39:07 +00:00
David Sevilla Martín
7a684660e9 Enable scrollbars in login button popups (#1900)
Fixes #1716
2019-10-01 23:37:42 +02:00
Daniël Klabbers
12dc4fff57 works towards #1789 by allowing event subscribing (#1810) 2019-10-01 11:12:46 +02:00
Franz Liedke
1b5a200781 Amend the existing rel attribute of links
...instead of overwriting. This will play more nicely with extensions.

Refs #859.
2019-09-26 23:02:39 +02:00
Franz Liedke
1bdf7764a9 Stop opening external links in new tabs
We accept that this may be desired by forum owners and will offer an
extension to enable this feature. By default, we will not make any
assumptions and simply adopt the web's and browsers' default behavior.

Fixes #859.
2019-09-26 23:01:24 +02:00
Franz Liedke
3417c0cbee Cleanup code from #1876
- Extract a method for email address generation
- Consistent types
- No docblocks for types where superfluous
- Tweak console output
- Don't inherit from integration test's base class in unit test
2019-09-24 01:00:22 +02:00
Stefan Totev
738ca405fe Normalize Base URL during installation
- Fix base url when is appended with a script filename
- Add default base url http://flarum.local when CLI wizard used
- Remove some code duplication
- Add minor improvement to the UX when CLI wizard used
- Add tests
- Extract base url normalisation into its own value object
2019-09-24 00:26:51 +02:00
Matteo Contrini
09609a9f20 Change rel for external links to nofollow ugc (#1884) 2019-09-23 23:37:49 +02:00
Daniël Klabbers
fb0a875c6d added author Daniel Klabbers 2019-09-16 10:37:51 +02:00
David Sevilla Martín
74b6b9935b Prepare beta.10 release (#1885)
* Update Application version string to beta 10
* Add beta.10 changelog
2019-09-16 09:28:17 +02:00
Franz Liedke
3b5691ee28 Restore beta.9 behavior of assertCan()
In flarum/core#1854, I changed the implementation of `assertCan()` to be
more aware of the user's log-in status. I came across this when unifying
our API's response status code when actors are not authenticated or not
authorized to do something.

@luceos rightfully had to tweak this again in ea84fc4, because the
behavior changed for one of the few API endpoints that checked for a
permission that even guests can have.

It turns out having this complex behavior in `assertCan()` is quite
misleading, because the name suggests a simple permission check and
nothing more.

Where we actually want to differ between HTTP 401 and 403, we can do
this using two method calls, and enforce it with our tests.

If this turns out to be problematic or extremely common, we can revisit
this and introduce a method with a different, better name in the future.

This commit restores the method's behavior in the last release, so we
also avoid another breaking change for extensions.
2019-09-14 21:32:00 +02:00
Franz Liedke
18593e0d7d Add a test for viewUserList guest permission
This test would have failed without commit ea84fc4. Next, I will revert
that commit and most of my PR #1854, so we need this test to ensure the
API continues to behave as desired.
2019-09-14 21:30:09 +02:00
Franz Liedke
40e1b61fe6 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-09-14 18:57:28 +00:00
Franz Liedke
95dcb45d65 Convert more controller tests to feature tests 2019-09-14 13:09:56 +02:00
Franz Liedke
bd989df769 Update vulnerable JS dependencies 2019-09-13 15:26:10 +02:00
Franz Liedke
538136153c Send a HTTP 401 for incorrect login credentials
This fixes a regression from #1843 and #1854. Now, the frontend again
shows the proper "Incorrect login details" message instead of "You
do not have permission to do that".
2019-09-13 15:03:03 +02:00
Franz Liedke
c330662241 Convert another controller test to feature test
Decouple from implementation, test closer to HTTP...
2019-09-13 14:58:45 +02:00
flarum-bot
588cbaee2d Bundled output for commit a9557c399a [skip ci] 2019-09-12 22:36:12 +00:00
David Sevilla Martín
a9557c399a Fix errors caused by deletion alert when deleting users (#1883)
Refs #1788

TypeError: t.showDeletionAlert is not a function
  at onSuccess(./src/forum/utils/UserControls.js:104:12)

Also, don't override 'this' param with user object for editAction
2019-09-13 00:34:05 +02:00
Daniël Klabbers
14e7bc73ee moved the artisan binary override and commented some of the bindings for queue 2019-09-12 09:11:12 +02:00
flarum-bot
edc579fa6f Bundled output for commit 119831e51c [skip ci] 2019-09-11 22:16:20 +00:00
David Sevilla Martin
119831e51c Fixes an issue where deleting a nonexistent model would error instead of resolving gracefully 2019-09-11 18:14:37 -04:00
Daniël Klabbers
2aee020c14 prevent constant to be duplicated during tests 2019-09-11 12:20:35 +02:00
Daniël Klabbers
f20696210e Merge branch 'master' of github.com:flarum/core 2019-09-11 11:59:10 +02:00
Daniël Klabbers
ea84fc4836 Fixes an issue where permission checks aren't made for guest users,
due to the gate being accessed after the check whether the user
is registered/signed in.
2019-09-11 11:58:27 +02:00
luceos
5ff04d0c68 Apply fixes from StyleCI
[ci skip] [skip ci]
2019-09-11 09:43:46 +00:00
Daniël Klabbers
e2ec52c28c Fixes the queue listen command. We might need to rectify this implementation before stable. 2019-09-11 11:42:52 +02:00
Daniël Klabbers
6196081bdf Fixes an issue where a different cache driver is used and Formatter
attempts to load the s9e Renderer from the wrong cache. It has
to be saved locally so that it can be properly loaded using
the spl auto register functionality.
2019-09-10 12:33:25 +02:00
Franz Liedke
6d8e6583c8 Fix instructions in PR template 2019-09-10 00:18:04 +02:00
flarum-bot
c2b0060852 Bundled output for commit 24964b94bf [skip ci] 2019-09-09 21:37:54 +00:00
David Sevilla Martín
24964b94bf Mark notification as read without visiting discussion (#1874) 2019-09-09 23:36:06 +02:00
flarum-bot
2b624c935d Bundled output for commit 2e647cdda8 [skip ci] 2019-09-09 21:07:00 +00:00
David Sevilla Martín
2e647cdda8 Fix error thrown if textarea doesn't exist in TextEditor (#1852)
* Prevent textarea not existing from causing errors to be thrown

* Replace [0] with .length
2019-09-09 17:05:11 -04:00
Daniël Klabbers
ba175144f4 listen and restart currently fail in the queue, see #1879 2019-09-09 15:47:56 +02:00
flarum-bot
e9af36ab47 Bundled output for commit 8b3913339a [skip ci] 2019-09-08 17:33:39 +00:00
Matthew Kilgore
8b3913339a Fix the new edit user permission label (#1870) 2019-09-08 13:31:57 -04:00
David Sevilla Martín
3cced4156f Add DB prefix to PHP tests (#1855)
* Add test job with PHP 7.3, MySQL & custom prefix

* Add prefix MariaDB test

* Add PHP 7.4 to tests

* Remove PHP 7.4 from tests

This reverts commit 270cba2f5f.
2019-09-08 13:28:39 -04:00
David Sevilla Martín
e88a9394ed Add back defaults for language and direction attributes (#1860) 2019-09-05 08:28:52 +02:00
flarum-bot
ba73c59601 Bundled output for commit 0191babb05 [skip ci] 2019-09-05 00:34:59 +00:00
Franz Liedke
0191babb05 Optimize ScrollListener performance
Listen to "scroll" event and throttle callback executions instead
of actively polling for changes to the scroll position.

Fixes #1222.
2019-09-05 02:17:09 +02:00
Franz Liedke
ed51f9ff0a Fix failing test 2019-09-05 00:07:40 +02:00
Franz Liedke
0a2bdbaa09 Debug mode: Include stacktrace in JSON-API errors
Refs #1843, #1865.
2019-09-04 23:35:32 +02:00
Franz Liedke
26229db1fd Refactor JSON-API error formatter 2019-09-04 23:30:22 +02:00
Franz Liedke
1aef3162be Apply fixes from StyleCI (#1867)
[ci skip] [skip ci]
2019-09-04 01:44:59 +02:00
Franz Liedke
dcf88df0c7 Restore error details in JSON-API error formatter
Fixes #1865. Refs #1843.
2019-09-04 01:44:22 +02:00
Franz Liedke
3eb28dfb16 Convert controller test to request test
This further decouples these tests from the implementation (i.e. which
controller are we calling?).
2019-09-04 01:27:24 +02:00
Matteo Contrini
1d43371fa9 Allow formatting post content without a request (#1848) 2019-09-04 00:12:28 +02:00
Matthew Kilgore
4df455cf04 Add Edit User permission to permissions grid (#1859) 2019-09-03 23:54:38 +02:00
Franz Liedke
2c43ccf66c Merge pull request #1854 from flarum/fl/1641-fix-status-codes
Error handling: Fix status codes
2019-09-02 16:33:48 +02:00
dependabot[bot]
1d010efbca Bump lodash from 4.17.11 to 4.17.15 in /js (#1863)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.15)

Signed-off-by: dependabot[bot] <support@github.com>
2019-08-28 09:11:25 +02:00
dependabot[bot]
2135d5908e Bump mixin-deep from 1.3.1 to 1.3.2 in /js (#1862)
Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
- [Commits](https://github.com/jonschlinkert/mixin-deep/compare/1.3.1...1.3.2)

Signed-off-by: dependabot[bot] <support@github.com>
2019-08-28 09:06:38 +02:00
Franz Liedke
9640dd6419 Remove unnecessary dependency
Refs #1773.
2019-08-22 10:04:38 +02:00
Franz Liedke
98464a8a33 Remove superfluous ForbiddenException
It has the same effect as the PermissionDeniedException, so let's
just use that.

Refs #1641.
2019-08-22 00:06:26 +02:00
Franz Liedke
2b6535525b When signups are prohibited, respond with HTTP 403 2019-08-21 23:48:24 +02:00
Franz Liedke
b60617b849 Move authentication check into assertCan() method
This will cause the right error (HTTP 401) to be thrown whenever
we're checking for a specific permission, but the user is not even
logged in. Authenticated users will still get HTTP 403.
2019-08-21 23:48:03 +02:00
Franz Liedke
0836d99e83 Remove unnecessary indirection 2019-08-21 00:06:32 +02:00
Franz Liedke
279c7df9b9 Document permission check methods 2019-08-21 00:06:31 +02:00
Franz Liedke
04bcf1eef6 Fix inconsistent status codes
HTTP 401 should be used when logging in (i.e. authenticating) would make
a difference; HTTP 403 is reserved for requests that fail because the
already authenticated user is not authorized (i.e. lacking permissions)
to do something.
2019-08-21 00:06:31 +02:00
Franz Liedke
70e98f810c Travis: Remove deploy key 2019-08-21 00:06:16 +02:00
David Sevilla Martín
3851d805f7 Move to GitHub Actions (#1853) 2019-08-21 00:05:04 +02:00
Franz Liedke
085468382a Error handling: Document another interface 2019-08-20 22:20:11 +02:00
Franz Liedke
7dbdd8c024 Rename method 2019-08-20 20:08:01 +02:00
Franz Liedke
ad25307e68 Error handling: Tweak Reporter interface
Because reporters are used for exceptions we were not able to handle, it
makes sense to simply pass the exception, not the "handled error".
2019-08-20 20:07:56 +02:00
Franz Liedke
6c454b8279 Error handling: Document classes and interfaces 2019-08-20 20:07:52 +02:00
Franz Liedke
9f15e9ba86 Error handling: Rename renderers to formatters
Refs #1641.
2019-08-20 20:07:47 +02:00
Franz Liedke
41009dba74 Remove obsolete queue config 2019-08-19 22:33:32 +02:00
Daniël Klabbers
a045f8bef9 Queue support (#1773)
Implementation of clean queue handling, by default sync is used
2019-08-19 21:44:06 +02:00
Franz Liedke
689d767f82 Don't fail when extend.php doesn't return an array
Refs #1607.
2019-08-16 12:29:31 +02:00
Franz Liedke
77fff9fde8 #1607: Show more details when catching boot errors 2019-08-16 12:13:47 +02:00
Franz Liedke
c6c1ae32e6 Bubble up exception for invalid confirmation token
This way, the error handler can simply be amended to deal with this
exception type with a dedicated error message or page.

Refs #1337.
Closes #1528.
2019-08-14 19:47:56 +02:00
Franz Liedke
bdac88b573 Determine error view and message based on type
...not based on status code.

To simplify this logic, we now use the same error "type" both when
routes are not found and specific models are not found. One exception is
ours, one is from Laravel, but for the purposes of error handling they
should be treated the same.

Fixes flarum/core#1641.
2019-08-14 19:47:56 +02:00
flarum-bot
31ee65be93 Bundled output for commit 29df6b60be [skip ci] 2019-08-14 06:41:45 +00:00
Franz Liedke
29df6b60be Tweak translation keys, always use full keys
Makes them easier to grep when editing / removing.

Refs #1750, #1788.
2019-08-14 08:34:36 +02:00
Franz Liedke
1e6f175379 Extract real method
Refs #1750, #1788.
2019-08-14 08:34:14 +02:00
flarum-bot
065ff3456f Bundled output for commit 37e0a5579b [skip ci] 2019-08-13 21:02:10 +00:00
Tobias Karlsson
37e0a5579b Improve feedback on user deletion
Fixes #1750, #1777
2019-08-13 22:56:24 +02:00
Franz Liedke
cd9aa0096e Merge pull request #1843 from flarum/fl/1641-exception-handling
Implement new error handling stack
2019-08-13 22:45:46 +02:00
Franz Liedke
d06493c61e Support multiple error reporters
The error handling middleware now expects an array of reporters.
Extensions can register new reporters in the container like this:

    use Flarum\Foundation\ErrorHandling\Reporter;

    $container->tag(NewReporter::class, Reporter::class);

Note that this is just an implementation detail and will be hidden
behind an extender.
2019-08-10 11:04:12 +02:00
Franz Liedke
9f71e2c3cb Remove old error handler, middleware and tests 2019-08-10 00:26:24 +02:00
Franz Liedke
81a8736ba9 API Client: Use new error handling mechanism 2019-08-10 00:26:24 +02:00
Franz Liedke
57ce25301d Use new error handler middleware 2019-08-10 00:26:24 +02:00
Franz Liedke
cfbaa84fbc Wire up new error handling stack 2019-08-10 00:26:23 +02:00
Franz Liedke
3417f5a77e Make existing extensions compatible with new stack 2019-08-10 00:26:22 +02:00
Franz Liedke
1035636d0f Implement new error handling stack
This separates the error registry (mapping exception types to status
codes) from actual handling (the middleware) as well as error formatting
(Whoops, pretty error pages or JSON-API?) and reporting (log? Sentry?).

The components can be reused in different places (e.g. the API client
and the error handler middleware both need the registry to understand
all the exceptions Flarum knows how to handle), while still allowing to
change only the parts that need to change (the API stack always uses the
JSON-API formatter, and the forum stack switches between Whoops and
pretty error pages based on debug mode).

Finally, this paves the way for some planned features and extensibility:
- A console error handler can build on top of the registry.
- Extensions can register new exceptions and how to handle them.
- Extensions can change how we report exceptions (e.g. Sentry).
- We can build more pretty error pages, even different ones for
  exceptions having the same status code.
2019-08-10 00:26:22 +02:00
Franz Liedke
d00fc2c49d Remove obsolete constructor parameter
This was removed in commit 484c6d2e.
2019-08-10 00:16:21 +02:00
flarum-bot
f3b889a665 Bundled output for commit c5122bf5d5 [skip ci] 2019-08-08 23:12:56 +00:00
Franz Liedke
c5122bf5d5 a11y: Try to make screenreaders read tooltips
Refs #1835.
2019-08-08 22:40:30 +02:00
David Sevilla Martín
5ed55195e1 Add canonical URL to discussion list (#1814) 2019-08-08 00:01:25 +02:00
Franz Liedke
8604ea3020 Bypass CSRF token check when using access tokens
Fixes #1828.
2019-08-01 22:53:31 +02:00
Franz Liedke
2648e960a7 Make exception message dynamic as well 2019-08-01 22:25:28 +02:00
Daniël Klabbers
f0dff95d62 Merge branch 'master' of github.com:flarum/core 2019-07-31 17:10:47 +02:00
Daniël Klabbers
894db01ad8 Allows configuration of where the language files live. So that
language packs can optionally decide for themselves if they want
to use a different directory.
2019-07-31 17:10:13 +02:00
Franz Liedke
bd04023359 Determine default route after extensions
Fixes #1819.
2019-07-30 00:56:29 +02:00
Franz Liedke
f357434a72 PHPUnit: Get rid of deprecated annotation
Refs #1795.
2019-07-30 00:09:10 +02:00
Daniël Klabbers
c2586586c4 fixes #1695, take into consideration is_private with counts on User stats 2019-07-28 20:59:12 +02:00
Daniël Klabbers
06cd062a1b fixed ci, make green again; mysql service wasnt booted 2019-07-27 22:24:39 +02:00
Franz Liedke
1502fc98d8 Prevent MySQL search operators from taking effect
We do not want to inherit MySQL's fulltext query language, so let's
just drop all non-word characters from the search term.

Fixes #1498.
2019-07-23 23:55:06 +02:00
Franz Liedke
ed97989ca2 Revert "Remove deprecated bootstrap.php fallback"
This reverts commit f8061bbca1.

We will keep this fallback in place, to avoid unnecessary breakage of
backwards compatibility for extension authors.

Removal is planned for the final 0.1 release.
2019-07-14 22:22:06 +02:00
Franz Liedke
7f1048352d Clean up database query
- Use existing `selectRaw()` method to avoid using the global `app()`
  helper as a service locator, which hides dependencies.
- Do the same for the join.
- The `Expression` is necessary to prevent the aliased column from being
  prefixed with the database table prefix, if configured.
2019-07-11 22:35:19 +02:00
dependabot[bot]
d2700961ba Bump lodash-es from 4.17.11 to 4.17.14 in /js (#1818)
Bumps [lodash-es](https://github.com/lodash/lodash) from 4.17.11 to 4.17.14.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.14)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-11 09:21:17 +02:00
Daniël Klabbers
b2dbb0439c fixed class property hint for event post content attribute 2019-07-09 08:31:48 +02:00
Daniël Klabbers
085c924a07 fix return type hint for event post content attribute 2019-07-09 08:30:10 +02:00
David Sevilla Martín
f31f02d4cc Set Whoops middleware HTTP status to error code (#1648)
* Use error code for HTTP status, defaults to 500
* Use logic from HandleErrorsWithView, make sure status is valid
2019-07-07 14:57:40 +02:00
Daniël Klabbers
797f6eea50 moved GetDisplayName event to User namespace (#1768) 2019-07-06 19:27:44 +02:00
Franz Liedke
9fb3a31b51 Get rid of unnecessary method 2019-07-06 02:25:06 +02:00
Franz Liedke
f8061bbca1 Remove deprecated bootstrap.php fallback
Closes #1557.
2019-07-06 02:11:09 +02:00
Franz Liedke
de67927ef2 Travis: Allow PHP 7.4 to fail for now
We are currently experiencing issues due to Mockery not yet being 100%
compatible with PHP.

See https://github.com/mockery/mockery/pull/980.
2019-07-06 01:56:54 +02:00
Franz Liedke
8c841c3266 Update test libraries 2019-07-06 01:49:55 +02:00
Franz Liedke
2f656146a7 Travis: Test against the upcoming PHP 7.4 2019-07-06 01:30:59 +02:00
Franz Liedke
d66d2aa26e Convert more helpers in tests 2019-07-06 01:30:59 +02:00
Franz Liedke
f4c0d4ba87 Type hint contract, not implementation 2019-07-06 01:30:58 +02:00
Franz Liedke
646bd40bca Use Laravel's class-based Str and Arr helpers
Starting with version 5.9, the global funtions will be deprecated.

* https://laravel-news.com/laravel-5-8-deprecates-string-and-array-helpers
* https://github.com/laravel/framework/pull/26898
2019-07-06 01:30:58 +02:00
Franz Liedke
307b912019 Issue templates: Remove vulnerability information
GitHub now automatically displays this information (or rather, links to
the Security Policy) at the issue type selection page.
2019-07-06 00:08:55 +02:00
Franz Liedke
cbc896eba7 Use class constant instead of strings 2019-07-06 00:03:25 +02:00
Franz Liedke
cc4e4a068b Add descriptions to custom Composer scripts 2019-07-05 23:34:23 +02:00
David Sevilla Martín
a720f6f651 Update Application version string to beta 9 (#1784) 2019-07-05 12:37:02 +02:00
flarum-bot
54d7c0d3b6 Bundled output for commit b5876d9f31 [skip ci] 2019-06-27 19:23:54 +00:00
David Sevilla Martín
b5876d9f31 Merge pull request #1803 from flarum/ds/1777-previous-route-default
Visit home page if previous route does not exist when going back in history
2019-06-27 15:17:41 -04:00
David Sevilla Martín
25ef4c10bd Update CHANGELOG.md 2019-06-27 15:07:53 -04:00
David Sevilla Martín
985b87da6c Visit home page if no previous route exists
Fixes #1777
2019-06-27 14:58:05 -04:00
Daniël Klabbers
a6aa28566c added changelog item for mediumText fix in posts.content 2019-06-24 14:57:13 +02:00
Daniël Klabbers
e3340ba3e1 Merge branch 'master' of github.com:flarum/core 2019-06-24 14:55:05 +02:00
Daniël Klabbers
590b311570 fixes #1801, increasing the size of posts.content to mediumText correctly 2019-06-24 14:53:56 +02:00
Daniël Klabbers
935a968257 fixed tests on master, missing views directory and suppressing notices from tempnam when storing files in tmp 2019-06-24 13:00:36 +02:00
Daniël Klabbers
fe558eb0ba Merge branch 'master' into advisory-fix-1 2019-06-24 12:53:37 +02:00
Daniël Klabbers
fda9cba4ce Merge branch 'master' of github.com:flarum/core 2019-06-24 10:49:39 +02:00
Daniël Klabbers
89f6cfd949 removed link to home, go back, which is always the case with csrf token invalidation 2019-06-24 10:49:31 +02:00
Daniël Klabbers
803582c437 Apply fixes from StyleCI (#1800)
[ci skip] [skip ci]
2019-06-24 09:15:15 +02:00
Franz Liedke
8e86d38804 Merge pull request from GHSA-3wjh-93gr-chh6
* Integration tests: Memoize request handler as well

This is useful to send HTTP requests (or their PSR-7 equivalents)
through the entire application's middleware stack (instead of
talking to specific controllers, which should be considered
implementation detail).

* Add tests for CSRF token check

* Integration tests: Configure vendor path

Now that this is possible, make the easy change...

* Implement middleware for CSRF token verification

This fixes a rather large oversight in Flarum's codebase, which was that
we had no explicit CSRF protection using the traditional token approach.

The JS frontend was actually sending these tokens, but the backend did
not require them.

* Accept CSRF token in request body as well

* Refactor tests to shorten HTTP requests

Multiple tests now provide JSON request bodies, and others copy cookies
from previous responses, so let's provide convenient helpers for these.

* Fixed issue with tmp/storage/views not existing, this caused tmpname to notice.
Fixed csrf test that assumed an access token allows application access, which is actually api token.
Improved return type hinting in the StartSession middleware

* Using a different setting key now, so that it won't break tests whenever you re-run them once smtp is set.
Fixed, badly, the test to create users etc caused by the prepareDatabase flushing all settings by default.

* added custom view, now needs translation
2019-06-24 09:14:38 +02:00
Daniël Klabbers
fd66722945 added custom view, now needs translation 2019-06-22 19:40:20 +02:00
Daniël Klabbers
ce42b5e035 Using a different setting key now, so that it won't break tests whenever you re-run them once smtp is set.
Fixed, badly, the test to create users etc caused by the prepareDatabase flushing all settings by default.
2019-06-18 17:45:29 +02:00
Daniël Klabbers
bfd3a667dd Fixed issue with tmp/storage/views not existing, this caused tmpname to notice.
Fixed csrf test that assumed an access token allows application access, which is actually api token.
Improved return type hinting in the StartSession middleware
2019-06-18 17:22:23 +02:00
Daniël Klabbers
b669490d33 Update CHANGELOG.md
clarifying reason for change on the `like` fix
2019-06-13 09:13:31 +02:00
Franz Liedke
ba956f51ac Update changelog 2019-06-13 01:03:39 +02:00
Franz Liedke
c126b95451 Refactor tests to shorten HTTP requests
Multiple tests now provide JSON request bodies, and others copy cookies
from previous responses, so let's provide convenient helpers for these.
2019-06-13 00:13:59 +02:00
Franz Liedke
7f7484e790 Accept CSRF token in request body as well 2019-06-13 00:13:58 +02:00
Franz Liedke
5d64056e89 Implement middleware for CSRF token verification
This fixes a rather large oversight in Flarum's codebase, which was that
we had no explicit CSRF protection using the traditional token approach.

The JS frontend was actually sending these tokens, but the backend did
not require them.
2019-06-13 00:13:58 +02:00
Franz Liedke
e927254e99 Add tests for CSRF token check 2019-06-13 00:13:57 +02:00
Franz Liedke
8061bfd74a Integration tests: Configure vendor path
Now that this is possible, make the easy change...
2019-06-13 00:13:57 +02:00
Franz Liedke
4c309d2ad7 Integration tests: Memoize request handler as well
This is useful to send HTTP requests (or their PSR-7 equivalents)
through the entire application's middleware stack (instead of
talking to specific controllers, which should be considered
implementation detail).
2019-06-13 00:13:57 +02:00
Franz Liedke
54876cfbd6 Integration tests: Fix test setup 2019-06-13 00:13:38 +02:00
Franz Liedke
9e2b796a7c Fix syntax error 2019-06-13 00:11:57 +02:00
Franz Liedke
7f5bd1e96b Apply fixes from StyleCI (#1793)
[ci skip] [skip ci]
2019-06-12 23:50:21 +02:00
Franz Liedke
5e1680c458 Introduce a vendor path
This lets us or anyone modify the path from where dependencies (usually
installed into /vendor by Composer) are loaded. We need to be able to
tweak this in our integration tests, where the application code under
test needs access to certain dependencies.
2019-06-12 23:48:22 +02:00
Franz Liedke
6e26b988bd Inject app, not container, to avoid global helpers 2019-06-12 23:48:22 +02:00
Daniël Klabbers
2e8d4e4b6b Update CHANGELOG.md
added fix for js compiler tmp path fix to changelog
2019-06-12 17:18:21 +02:00
Daniël Klabbers
14bede2847 Merge branch 'master' of github.com:flarum/core 2019-06-12 16:47:15 +02:00
Daniël Klabbers
54660ebd63 fixed issue with the Js compiler being unable to use the system tmp directory, using the one in storage is much safer across different operating systems 2019-06-12 16:46:53 +02:00
Daniël Klabbers
1a62b7e07a Update CHANGELOG.md
fixed missing link markdown
2019-06-12 00:43:57 +02:00
Daniël Klabbers
4b04c0e0ce Update CHANGELOG.md
added missing changelog item for #1738
2019-06-12 00:43:09 +02:00
Daniël Klabbers
4d45ce389b Update CHANGELOG.md
referenced incorrect (parent) commit in changelog
2019-06-12 00:38:54 +02:00
Daniël Klabbers
d2674fb309 patched constraint for components/font-awesome, fixes #1790 2019-06-11 20:22:35 +02:00
Annim Banerjee
5eb69e1f59 Updated names to match components in fontawsome (#1791)
fa-* named components are not present, hence updated to matching names.
2019-06-11 20:17:59 +02:00
Franz Liedke
f42142979d Load LESS variables via path traversal
Since these files are part of the same package, there is no need
to assume a Composer context to load these from. Instead, we can
just load them via the path relative to the current PHP file.

This assumption may break in certain environments, and it is
already broken when running (integration) tests.
2019-06-09 00:19:06 +02:00
Franz Liedke
5f79d3b499 This method should be private 2019-06-09 00:19:05 +02:00
Franz Liedke
8e4d97260f Do not rely on extensions_enabled being present
This mostly simplifies setup in complex integration tests.
2019-06-09 00:19:05 +02:00
Daniël Klabbers
ee3640e160 remove use of like which might cause unwanted side effects (#1787) 2019-06-03 12:04:17 +02:00
Franz Liedke
bd584802e5 Update changelog 2019-06-01 20:12:30 +02:00
flarum-bot
f4dd045326 Bundled output for commit 24522943f6 [skip ci] 2019-06-01 18:10:13 +00:00
Franz Liedke
24522943f6 Update insecure jQuery version
Thanks, GitHub security alerts!
2019-06-01 20:03:07 +02:00
Franz Liedke
56fde28e43 Restore "originalUri" request attribute
This is helpful when Flarum is installed in subfolders.

Fixes #778.
2019-06-01 12:51:05 +02:00
Franz Liedke
1c1d661bdd Use the settings repository's default value
Updates commit bf2c5a5564.
2019-05-24 20:11:34 +02:00
Franz Liedke
d3be186fb6 Update changelog 2019-05-24 20:11:31 +02:00
Daniël Klabbers
8f8cc558be Update SECURITY.md
fixed typo
2019-05-23 11:15:55 +02:00
Franz Liedke
5ea9e1cf5e Add a security policy 2019-05-23 11:10:53 +02:00
Toby Zerner
99a6066f96 Merge pull request #1779 from clarkwinkelmann/fix-userpage-card-dropdown
Fix dropdown icon not showing in UserCard when on UserPage
2019-05-02 19:21:39 +09:30
Toby Zerner
8b7db726dc Merge pull request #1780 from clarkwinkelmann/remove-notification-id
Remove notification id from serializer attributes
2019-05-02 19:20:42 +09:30
Clark Winkelmann
7a44086bf3 Remove notification id from serializer attributes 2019-05-01 23:05:25 +02:00
Clark Winkelmann
12fdfc9b54 Fix dropdown icon not showing in UserCard when on UserPage
The rule hiding the icon in the UserHero was too broad and applied to UserCard in the list of posts as well
The float rule was redundant
2019-05-01 22:54:13 +02:00
Clark Winkelmann
ecc3b5e227 Remove post id from serializer attributes (#1775) 2019-04-19 21:37:14 +02:00
Daniël Klabbers
bf2c5a5564 This small fix prevents that the forum frontend breaks whenever
custom_less is NULL or unavailable in the database. We cannot rely
on this value to exist or is incorrectly set to null and thus
completely bricking the app.
2019-04-12 14:10:20 +02:00
Toby Zerner
d3a5c91845 Update changelog 2019-03-24 12:26:02 +10:30
Toby Zerner
e17bb0b433 Fix is:unread gambit 2019-03-24 12:24:44 +10:30
flarum-bot
c4ba41f850 Bundled output for commit 0c4de6f163 [skip ci] 2019-03-20 21:09:11 +00:00
Franz Liedke
0c4de6f163 Fix storing dynamic mail settings
Refs #1169.
2019-03-20 22:02:06 +01:00
flarum-bot
cd313952c7 Bundled output for commit 5154d7e5a6 [skip ci] 2019-03-19 09:06:21 +00:00
Franz Liedke
ef57b443c1 Apply fixes from StyleCI (#1761)
[ci skip] [skip ci]
2019-03-19 09:59:09 +01:00
Franz Liedke
5154d7e5a6 Allow configuring all drivers via frontend (#1169)
This includes an API endpoint for fetching the list of possible
drivers and their configuration fields. In the future, this can
be extended to include more meta information about each field.
2019-03-19 09:56:20 +01:00
Franz Liedke
2bd40b50c7 Remove dead code
Probably a leftover from copy-pasting the BasicsPage.
2019-03-17 19:02:46 +01:00
Franz Liedke
c50d58d0f4 Add drivers for Mailgun, Mandrill, SES (#1169) 2019-03-16 12:58:35 +01:00
Franz Liedke
8c65316961 Rely on default contribution guidelines
See https://help.github.com/en/articles/creating-a-default-community-health-file-for-your-organization.
2019-03-16 12:32:29 +01:00
flarum-bot
0a818cfdf3 Bundled output for commit a21052c903 [skip ci] 2019-03-15 17:01:09 +00:00
Franz Liedke
57204c6ed0 Fix last commit 2019-03-15 17:57:11 +01:00
Franz Liedke
a21052c903 Mail settings: Only show necessary fields (#1169) 2019-03-15 17:54:14 +01:00
Franz Liedke
441ebacfd7 Apply fixes from StyleCI (#1760)
[ci skip] [skip ci]
2019-03-13 21:32:18 +01:00
Franz Liedke
46acfb6c23 Implement mail driver classes (#1169)
This adds an interface for mail drivers to implement, defining several
methods that we need throughout Flarum to configure, validate and use
the various email drivers we can support through Laravel.

More mail drivers can be added by `extend()`ing the container binding
"mail.supported_drivers" with an arbitrary key and the name of a class
that implements our new `DriverInterface`.

This will ensure that drivers added by extensions can be properly built
and validated, even in the frontend.
2019-03-13 21:31:19 +01:00
Daniël Klabbers
9910e884fc Allow fallback to check for bound mail drivers (#1757) 2019-03-12 19:45:42 +01:00
Franz Liedke
d292aaabf8 Fix another documentation link
Forgotten in #1699, closes #1736.
2019-03-07 00:33:25 +01:00
Franz Liedke
d822a6f84c Apply fixes from StyleCI (#1756)
[ci skip] [skip ci]
2019-03-07 00:22:15 +01:00
Franz Liedke
26c3bcdb74 Add regression test for #1738
This should ensure we can always search for search terms that appear
either only in the subject or only in the text of discussions.
2019-03-07 00:21:43 +01:00
bdumaspilhou
33deea4791 Fixes #1738 : Search Title within discussions (#1741) 2019-03-07 00:20:37 +01:00
flarum-bot
20227a2201 Bundled output for commit 0493682dba [skip ci] 2019-03-03 19:45:38 +00:00
Franz Liedke
0493682dba Travis: Fix build job 2019-03-03 20:39:30 +01:00
Franz Liedke
49dda87e86 npm audit fix 2019-03-03 20:29:50 +01:00
Franz Liedke
d959d08561 NPM: Update bootstrap package
The old version had a vulnerability.

See https://nvd.nist.gov/vuln/detail/CVE-2019-8331.
2019-03-03 20:27:14 +01:00
Franz Liedke
e8ab49abc1 Merge pull request #1743 from flarum/fl/test-structure
Improve test suite structure
2019-03-03 20:17:35 +01:00
flarum-bot
296677b5fc Bundled output for commit f3931b537c [skip ci] 2019-02-18 07:51:00 +00:00
Daniël Klabbers
f3931b537c Copied over logic from EditTagModal to allow additional attributes to be send
to the API based on additional fields rendered by extending the fields.
2019-02-18 08:43:47 +01:00
Franz Liedke
d0ba4e5268 Update changelog 2019-02-14 23:40:18 +01:00
Daniël Klabbers
654ab4cc29 prefixes indices when installing too 2019-02-05 09:50:15 +01:00
Daniël Klabbers
e0becd0c7b Capsule manager (#1744)
Refactored to use the Capsule Database manager for setting up the
Flarum (mysql) connection.

This will introduce the reconnector automatically, fixing #1740
2019-02-04 23:31:12 +01:00
Franz Liedke
ed43ad9c3f Properly wrap error bag in session
Second part of fixing #1683.
2019-02-03 21:16:43 +01:00
Franz Liedke
4611abe5db Fix error redirect when resetting passwords
This was an oversight from the large database column renamings.

Fixes #1683.
2019-02-03 21:06:47 +01:00
Franz Liedke
df0bd52283 Add helpful (?) output to test setup script 2019-02-03 20:39:33 +01:00
Franz Liedke
d387a9ff02 travis: Configure setup for integration tests 2019-02-03 20:39:33 +01:00
Franz Liedke
5556df54f9 Setup Composer commands for testing and setup 2019-02-03 20:39:33 +01:00
Franz Liedke
cf746079ed Make integration tests independent
This creates a dedicated test suite for integration tests. All of them
can be run independently, and there is no order dependency - previously,
all integration tests needed the installer test to run first, and they
would fail if installation failed.

Now, the developer will have to set up a Flarum database to be used by
these tests. A setup script to make this simple will be added in the
next commit.

Small tradeoff: the installer is NOT tested in our test suite anymore,
only implicitly through the setup script. If we decide that this is a
problem, we can still set up separate, dedicated installer tests which
should probably test the web installer.
2019-02-03 20:39:32 +01:00
Franz Liedke
4d10536d35 Move integration tests to separate directory
Again, we do all of this to prepare for creating "real" test suites for
each type of tests.
2019-02-01 19:01:12 +01:00
Franz Liedke
ba16ebe61f Extract pure unit tests so that they can run fast
- Move to separate directory (base for a separate test suite)
- Inherit directly from PhpUnit
- Configure test suite with dedicated XML file
2019-02-01 19:01:09 +01:00
Franz Liedke
6484dc4982 Merge pull request #1617 from flarum/fl/installer-cleanup
Split up the installer logic
2019-02-01 17:43:59 +01:00
Franz Liedke
1a9f1f7a3d Use Collection class rather than collect() helper 2019-02-01 14:12:29 +01:00
Franz Liedke
4d1411e2a8 Improve problem description for wrong PHP version 2019-02-01 13:00:25 +01:00
Franz Liedke
968152b740 DatabaseConfig: Implement Arrayable contract 2019-02-01 13:00:07 +01:00
Franz Liedke
af185fd3d1 Fix tests 2019-02-01 10:33:21 +01:00
Franz Liedke
ed9591c16f Installer: Support reverting asset publication 2019-01-31 22:43:07 +01:00
Franz Liedke
8ad326941f Migrator: Fix resetting core migrations 2019-01-31 22:42:35 +01:00
Franz Liedke
8e4f02d994 Fix table name in migration 2019-01-31 22:01:05 +01:00
Franz Liedke
8ae85bc49f Remove obsolete dropForeign() migration
Forgotten in commit 5a04635e7a.
2019-01-31 22:00:41 +01:00
Franz Liedke
7ff9a90204 Check MariaDB version, update MySQL constraint
See flarum/docs#43.
2019-01-31 21:52:10 +01:00
Franz Liedke
f4fb1ab272 Simplify DataProviderInterface
Instead of passing all these objects / arrays from one object to the
next, simply pass an Installation instance around for configuration.
2019-01-31 21:52:10 +01:00
Franz Liedke
484c6d2edb Extract DatabaseConfig class with validation 2019-01-31 21:52:09 +01:00
Franz Liedke
8b68ff6232 Extract AdminUser class that enforces invariants 2019-01-31 21:52:09 +01:00
Franz Liedke
0a59b7164e Move password confirmation validation to frontends
Since this is not strictly speaking a domain invariant, but rather
specific to the user interface where passwords are not displayed, and
should therefore be entered twice to prevent mistakes going unnoticed,
this stuff should be checked in the frontend, not in the install steps.

Next step: Ensure that all domain-specific validation is done in the
installer's domain layer. This will ensure these validations cannot be
forgotten, and keep the frontends DRY.
2019-01-31 21:52:08 +01:00
Franz Liedke
0879829dc4 Use dedicated temporary variable instead of array 2019-01-31 21:52:08 +01:00
Franz Liedke
78ba3bd854 Combine building and storing config in one step 2019-01-31 21:52:08 +01:00
Franz Liedke
44c91099cd Get rid of DefaultsDataProvider
Since we do not provide a development VM anymore, it does not make sense
to have "default" credentials etc.

To reproduce something similar, I'd suggest using a YAML or JSON file
together with the `--file` option.
2019-01-31 21:52:07 +01:00
Franz Liedke
4585f03ee3 Switch to a whitelist for enabling extensions 2019-01-31 21:52:07 +01:00
Franz Liedke
bc9e8f68f1 Move default settings to install step
The various installation "frontends" (such as GUI and console) can now
provide custom overrides, if they want to.
2019-01-31 21:52:06 +01:00
Franz Liedke
f5a21584c2 Collapse namespace imports 2019-01-31 21:52:06 +01:00
Franz Liedke
e0a508a765 Catch pipeline's own exception 2019-01-31 21:52:06 +01:00
Franz Liedke
89e018a4f0 Simplify PrerequisiteInterface
I went with a return type of Collection, because it is easier to call
methods such as isEmpty() directly on those objects.
2019-01-31 21:52:05 +01:00
Franz Liedke
de6001f4cf Fix the test setup and installer tests
We are still testing the installation logic, but not testing the
actual CLI task. I would love to do that, but IMO we first need to
find a way to do this fully from the outside, by invoking and
talking to the installer through the shell.

Because acceptance tests are easier to do when fully decoupled from
the application. (After all, they are intended to save us from
breaking things when changing code; and we cannot prove that when
we change the tests at the same time.)

It might be easier to start with acceptance tests for the web
installer, though.
2019-01-31 21:52:05 +01:00
Franz Liedke
790d5beee5 Split up the installer logic
This is probably the most complicated way I could find to fix #1587.

Jokes aside, this was done with a few goals in mind:
- Reduce coupling between the installer and the rest of Flarum's
  "Application", which we are building during installation.
- Move the installer logic to several smaller classes, which can then
  be used by the web frontend and the console task, instead of the
  former hacking its way into the latter to be "DRY".
- Separate installer infrastructure (the "pipeline", with the ability
  to revert steps upon failure) from the actual steps being taken.

The problem was conceptual, and would certainly re-occur in a similar
fashion if we wouldn't tackle it at its roots.

It is fixed now, because we no longer use the ExtensionManager for
enabling extensions, but instead duplicate some of its logic. That is
fine because we don't want to do everything it does, e.g. omit
extenders' lifecycle hooks (which depend on the Application instance
being complete).

> for each desired change, make the change easy (warning: this may be
> hard), then make the easy change

- Kent Beck, https://twitter.com/kentbeck/status/250733358307500032

Fixes #1587.
2019-01-31 21:52:04 +01:00
flarum-bot
abf224bb0a Bundled output for commit c7d2e165d7 [skip ci] 2019-01-25 04:46:37 +00:00
Daniël Klabbers
c7d2e165d7 Fixes #1686
- further cleaned up the toggle action
- there's no way to remove the redraws because then the jquery isn't being fired properly
2019-01-25 05:37:45 +01:00
Toby Zerner
0ab9facc4b Make the Request available to the Formatter\Rendering event (#1721)
This is important because extensions may wish to render post content
differently depending on Request factors such as the actor. For example,
an attachments extension might wish to hide attachments from guests.

This solution is a bit of a hack-job for now, but soon when we refactor
the API layer to use tobscure/json-api-server, and also refactor the
Formatter layer, it can be revised.
2019-01-22 23:33:49 +01:00
Daniël Klabbers
9b68bbe44e Merge branch 'master' of github.com:flarum/core 2019-01-16 11:59:04 +01:00
Daniël Klabbers
862404f052 update symfony/console, because illuminate/console needs a higher version 2019-01-16 11:58:42 +01:00
flarum-bot
b9a93f3440 Bundled output for commit c67fb2d4b6 [skip ci] 2019-01-16 09:05:46 +00:00
Daniël Klabbers
c67fb2d4b6 fixes #1686, unable to edit user password 2019-01-16 09:58:22 +01:00
Daniël Klabbers
1b2d4f1e1d set prefixing indices to be done automatically, now that illuminate can take care of that 2019-01-15 20:49:33 +01:00
Daniël Klabbers
54fdc40d87 further revert #96e2824 2019-01-15 20:49:06 +01:00
Daniël Klabbers
390148456c reverts #96e2824 2019-01-15 20:39:38 +01:00
Daniël Klabbers
167059027e Increasing test coverage (#1711)
* added a few more tests, renamed singular to plural to match controller

* increase error reporting

* removed debugging and wait for tests
2019-01-01 21:02:18 +01:00
Franz Liedke
208bad393f Mail: Add an array of supported drivers
This can be used for e.g. validation, or a dropdown in the frontend.
It can also be extended by extensions, such as flagrow/mail-drivers.

Refs #1169.
2018-12-20 13:36:08 +01:00
Franz Liedke
8a93f8b6b6 Apply fixes from StyleCI (#1714)
[ci skip] [skip ci]
2018-12-20 13:13:58 +01:00
Franz Liedke
9db04a4e19 Register service providers alphabetically
Order should not matter - and this is the only one that can
realistically stay consistent.
2018-12-20 13:13:04 +01:00
Franz Liedke
ac5e26a254 Use a custom service provider for email configuration 2018-12-20 13:10:30 +01:00
Daniël Klabbers
9794a08f39 updated constraint for 5.7 (#1698) 2018-12-20 08:20:52 +10:30
Franz Liedke
ababb8ebef Don't resolve services when binding listeners
Refs #1578.
2018-12-19 22:47:58 +01:00
Franz Liedke
cb3baf9955 Apply fixes from StyleCI (#1713)
[ci skip] [skip ci]
2018-12-19 22:42:54 +01:00
Franz Liedke
dbe8cba14e Avoid unnecessary event subscribers
Refs #1578.
2018-12-19 22:27:32 +01:00
Franz Liedke
9fe671c9bb Fix UpdateServiceProvider
- Shorten registration of routes
- Do not resolve view factory before booting
2018-12-19 22:17:44 +01:00
Franz Liedke
0e5f334a0b Locale: Don't resolve manager just to configure it
Refs #1578.
2018-12-19 22:07:31 +01:00
Franz Liedke
e4514d8413 Shorten registration of routes 2018-12-19 21:57:59 +01:00
Franz Liedke
1080d25561 Frontends: Populate default routes only when they are resolved 2018-12-19 21:55:58 +01:00
Franz Liedke
ba594de13a Make site extenders run after extensions
Fixes #1708.
2018-12-19 21:30:29 +01:00
Daniël Klabbers
209d13affd add 7.3 to travis (#1710) 2018-12-19 18:09:36 +01:00
Daniel Klabbers
671fdec8d0 fixes #1695, post comment count is incorrectly calculated based on all posts, including events 2018-12-19 15:07:32 +01:00
Daniel Klabbers
9eca9192ca fixes a notice due to the forum variable not being defined before compacting 2018-12-19 11:40:48 +01:00
Franz Liedke
3468bdf511 Run local extenders before booting service providers
We still need to discuss the priority of local extenders vs. those
from enabled extensions, but let's first fix the actual bug.

Refs #1708.
2018-12-18 11:16:57 +01:00
Franz Liedke
54503d2c29 API: Populate default routes only when they are resolved
Refs #1708.
2018-12-18 10:33:01 +01:00
Franz Liedke
565131e2a7 Allow passing strings (names of invokable classes) to Formatter extender
In preparation for fixing #1703.
2018-12-15 12:05:17 +01:00
Toby Zerner
f0da3cf304 Remove obsolete binding 2018-12-14 11:28:11 +10:30
Franz Liedke
6acc91577d Apply fixes from StyleCI (#1701)
[ci skip] [skip ci]
2018-12-14 01:48:19 +01:00
Franz Liedke
3e0cd3a21f Use class constant to get qualified class names 2018-12-14 01:47:54 +01:00
Franz Liedke
5c9fa4c62d Get rid of docblocks that don't add information 2018-12-13 23:08:49 +01:00
Franz Liedke
4b00f7996b Early returns 2018-12-13 23:06:59 +01:00
Kirill
b58380e224 Fix incorrect docs link (#1699) 2018-12-13 20:19:13 +01:00
Franz Liedke
b0e996e7ff Merge pull request #1697 from flarum/fl/1578-speed-up-extenders
Do not resolve services in extenders
2018-12-13 10:33:00 +01:00
Franz Liedke
b41d9fb0e7 Inject dependencies when firing events, not before
The event subscriber approach means that dependencies have to be
injected (and thus instantiated, along with all *their* dependencies) at
the time of registering event listeners - even when events are never
fired within a request's lifecycle.

This is unnecessary and causes more classes than necessary to be loaded.

In this case, we can explicitly register event listeners that will
resolve their dependencies when the event is fired, not before.

Refs #1578.
2018-12-13 02:01:50 +01:00
Franz Liedke
ed02eed88f Do not resolve services when extending them
Refs #1578.
2018-12-13 01:58:54 +01:00
David Sevilla Martín
c761802900 Fix DELETE /api/extensions/* returning 500 (#1580)
* Use extension string as parameter for ::disable & ::uninstall

* Remove repeated 'ExtensionManager::disable' call

* Fix StyleCI
2018-12-13 00:16:03 +01:00
Arda Çebi
16eb1fa63b Profile group badge overlapping fix (#1506) 2018-12-12 22:24:30 +01:00
Franz Liedke
0ceb8d64df Update changelog 2018-12-10 22:52:50 +01:00
Franz Liedke
9712eccb03 Add an issue template for security vulnerabilities 2018-12-10 22:43:03 +01:00
David Sevilla Martín
9684fbc4da Add 'hasPermission' helper to Group (#1688)
* Add Group@hasPermission helper

* Improve performance of method
2018-12-10 22:32:21 +01:00
Franz Liedke
67f9375d47 Fix incorrect column name for registration token
Oversight from the database renamings, I suppose.

Fixes #1691.
2018-12-09 23:17:04 +01:00
Toby Zerner
0d16fac001 Performance: Actually make use of the translator cache
We had added a `storage/locale` directory to our skeleton, but we had
forgotten to hook it up with the translator. Enabling caching saves
parsing that locale YAML files on every pageload which should be good
for performance.

The locale cache will be cleared whenever an extension that uses the
`Locales` or `LanguagePack` extenders is enabled/disabled. If debug
mode is ON, then the caching mechanism will automatically check if any
of the loaded YAML files are dirty and update accordingly.
2018-12-07 09:38:08 +10:30
Toby Zerner
a8f5ca8d97 Add another commit 2018-12-07 09:13:44 +10:30
Franz Liedke
bbe62f400f Release version 0.1.0-beta.8.1 2018-12-06 00:47:38 +01:00
Franz Liedke
fc5977f86f Do not create tables as InnoDB automatically, rely on connection default
As argued in #1675, this makes us slightly less reliant on MySQL.
2018-12-06 00:34:43 +01:00
Toby Zerner
796b57753d Don't output empty html tag attributes
From https://discuss.flarum.org/d/17817-meta-description-is-empty/8
ref #1677
2018-12-04 09:47:49 +10:30
Toby Zerner
88e43cc694 Fix empty meta description tag. Fixes #1677 2018-12-04 09:28:24 +10:30
Toby Zerner
6370f7ecff Set the default engine in the installer
The installer doesn't use DatabaseServiceProvider, so we need to set
the default engine in the config here too.

Fixes #1675
2018-12-04 09:12:19 +10:30
Toby Zerner
d9d7027ed0 Fix oopsie in fb6b51b1cf 2018-12-04 08:54:33 +10:30
flarum-bot
1106a2e3a3 Bundled output for commit b7f666525c [skip ci] 2018-12-02 22:26:12 +00:00
Toby Zerner
b7f666525c Update changelog 2018-12-03 08:51:27 +10:30
Toby Zerner
40dc6ac604 Fix discussion list scroll position not being maintained when hero is not visible 2018-12-03 08:50:54 +10:30
Toby Zerner
15e1a154e5 Add changelog 2018-12-02 08:08:44 +10:30
Franz Liedke
57d5846b64 Migrations: Fix dropping foreign keys
Passing an array to dropForeign does not mean dropping multiple indices,
but rather dropping a key on multiple tables.

Passing a string means that this string will be interpreted as index
name, not as name of the indexed column. Passing an array with one
string is therefore correct, in order to benefit from automatic index
name generation.
2018-11-30 14:02:37 +01:00
Franz Liedke
fb6b51b1cf Set InnoDB for DB connection and new tables
Refs #1661.
2018-11-29 23:21:58 +01:00
Franz Liedke
57f73c9638 Installer: Fix invalid join time of admin user
Fixes #1664.
2018-11-29 22:56:56 +01:00
Franz Liedke
7705a2b7d7 Fix search with database prefix
wrap() only adds a table prefix when referencing a column with a table
name (such as `foo.bar`) - when only a single identifier is provided, it
is assumed to be a column name, which does not need a prefix.

Fixes #1659.
2018-11-29 22:50:32 +01:00
Franz Liedke
f591585d02 Fix live output in ResetCommand
This was forgotten in 9e487b4.

Fixes #1663.
2018-11-29 22:04:01 +01:00
Franz Liedke
45afc33eb0 Fix code style and doc block 2018-11-29 21:31:12 +01:00
Daniël Klabbers
213fd62be3 Up the version (#1582) 2018-11-29 00:34:49 +01:00
Franz Liedke
66607a5674 Always invalidate all user email tokens
Reported by B. Dhiyaneshwaran of Geek Freak.
2018-11-29 00:33:42 +01:00
Toby Zerner
546b4f01ac Merge pull request #1656 from flarum/tz/fix-index-names
Fix index names in migrations
2018-11-27 22:32:17 +10:30
Toby Zerner
96e282458b Fix index names in migrations
This can be reverted when we upgrade to Laravel 5.7.
2018-11-27 12:19:13 +10:30
David Sevilla Martín
24ff8899a0 Throw FileNotFoundException when FileSource path does not exist
Closes #1649.
2018-11-22 23:40:38 +01:00
David Sevilla Martín
1b32c7cc51 Fix frontend extender using old container & wrong class 2018-11-22 21:17:32 +01:00
Franz Liedke
6c2a4a5ff7 Remove obsolete property accessor in User model
The locale field does not exist, and the accessor code was broken.

Closes #1653.
2018-11-22 21:12:25 +01:00
Toby Zerner
2d31a6f72e Clearer delineation of installation pointer 2018-11-22 18:37:00 +10:30
Toby Zerner
9115b9e28f Include LESS mixins and variables in all frontend compilers 2018-11-22 12:09:50 +10:30
Toby Zerner
3bff2e0f5c Consolidate ControllerRouteHandler into RouteHandlerFactory
Also allow closure to be passed for frontend content when creating routes
2018-11-22 12:09:50 +10:30
Toby Zerner
edaca3160e Refactor frontend code to allow for extension of assets
- Simpler class naming:
    Frontend\CompilerFactory → Frontend\Assets
    Frontend\HtmlDocumentFactory → Frontend\Frontend
    Frontend\HtmlDocument → Frontend\Document

- Remove AssetInterface and simply collect callbacks in Frontend\Assets
  instead

- Remove ContentInterface because it serves no purpose (never type-
  hinted or type-checked)

- Commit and add asset URLs to the Document via a content callback
  instead of in the Document factory class itself

- Add translations and locale assets to Assets separate to the assets
  factory, as non-forum/admin asset bundles probably won't want them

- Update Frontend Extender to allow the creation of new asset bundles

- Make custom LESS validation listener a standalone class instead of
  extending RecompileFrontendAssets
2018-11-22 12:09:50 +10:30
flarum-bot
9e63f32105 Bundled output for commit b074f47298 [skip ci] 2018-11-21 21:38:27 +00:00
Toby Zerner
f3a5a89e12 Apply fixes from StyleCI (#1651)
[ci skip] [skip ci]
2018-11-22 08:04:41 +10:30
Toby Zerner
b074f47298 Fix build errors by updating webpack-cli 2018-11-22 08:04:08 +10:30
Toby Zerner
2ef66ac716 Add "clear cache" button to admin 2018-11-22 08:03:43 +10:30
Toby Zerner
6654894da1 Fix old session method name 2018-11-22 07:24:44 +10:30
Toby Zerner
41544c8529 Fix positioning of hamburger menu unread indicator 2018-11-22 07:24:01 +10:30
Toby Zerner
53d1b87daf Revert "Configure external links before dispatching event"
This reverts commit 4c55d278b6.

Fixes #1650
2018-11-22 07:21:16 +10:30
Toby Zerner
c11e4720d9 Change watch command to dev 2018-11-21 18:31:54 +10:30
Toby Zerner
c73d03a427 Make npm package private, update deps 2018-11-21 18:31:24 +10:30
Toby Zerner
d0d6c52839 Remove sudo: false
See https://blog.travis-ci.com/2018-11-19-required-linux-infrastructure-migration
2018-11-21 18:27:12 +10:30
Toby Zerner
9585d448d2 Update README, CONTRIBUTING 2018-11-21 18:26:32 +10:30
Toby Zerner
04d46b9925 Remove copyright year from LICENSE
So we don't have to worry about keeping it updated
2018-11-21 18:24:59 +10:30
Toby Zerner
c3b2d8e7d8 Typehint Frontend extender arguments 2018-11-16 15:19:51 +10:30
Toby Zerner
62a40036d0 Fix empty JS files not actually being empty 2018-11-16 15:17:57 +10:30
Daniël Klabbers
2764ad87cc up the font-awesome dependency (#1642)
new version of components/font-awesome was tagged, let's up the minimum to allow for more icons:

https://packagist.org/packages/components/font-awesome
2018-11-14 17:12:27 +01:00
Toby Zerner
2c1be86857 Only say that we're migrating an extension if it has migrations 2018-11-14 16:41:36 +10:30
Toby Zerner
b26eb8e609 Publish core assets when migrating 2018-11-14 16:41:07 +10:30
Toby Zerner
1f0bf33cfb Fix extension names not being displayed when running migrations 2018-11-14 16:28:00 +10:30
Toby Zerner
6fadc0b653 New heading styles 2018-11-14 13:57:31 +10:30
flarum-bot
0255393108 Bundled output for commit b474843cc2 [skip ci] 2018-11-14 01:11:59 +00:00
Toby Zerner
b474843cc2 Clear the search loading indicator after pressing Enter 2018-11-14 11:38:28 +10:30
Toby Zerner
7e95b80341 Drastically improve search performance
The previous approach of joining the posts table into the main search
query was not scaling well. Searches on discuss.flarum.org were taking
~1.5 seconds which – a significant improvement over the pre-beta 8
search, but still not acceptable.

This new approach uses a much more efficient subquery join. Searches
on discuss.flarum.org now take mere milliseconds. The search result
ranking strategy has been further refined as well so that discussions
are ranked by the collective relevance of their posts.
2018-11-14 11:19:39 +10:30
Toby Zerner
18b90d16e3 Allow users to hide their own posts just as they can edit them
This fixes a regression introduced by #1466.
2018-11-14 09:33:28 +10:30
flarum-bot
64a7e8ac3a Bundled output for commit e8b8cd0078 [skip ci] 2018-11-13 21:41:20 +00:00
David Sevilla Martín
e8b8cd0078 Move EditUserModal fields into an ItemList to make more extendable (#1593) 2018-11-14 08:00:43 +10:30
Toby Zerner
3c8262ccde Fix incorrect regex modifier, causing JS to become malformed is some cases 2018-11-14 06:45:14 +10:30
Franz Liedke
68c6638fb5 Merge pull request #1633 from flarum/tz/improve-logging
Improve logging
2018-11-13 11:03:24 +01:00
Toby Zerner
105dd093fe Remove fileinfo dependency
As per https://github.com/flarum/docs/issues/14#issuecomment-365972062
2018-11-13 17:16:47 +10:30
Toby Zerner
920802e5ae Log errors when debug mode is on too 2018-11-13 07:47:01 +10:30
flarum-bot
882c4aa105 Bundled output for commit b826f9ce36 [skip ci] 2018-11-12 10:35:23 +00:00
Toby Zerner
b826f9ce36 Trigger input event when text is programmatically inserted 2018-11-12 17:21:37 +10:30
Toby Zerner
c13dfa2228 Add a toolbar area to the TextEditor component
This is to be used for formatting buttons and the like. Although it is
displayed in the controls area at the moment, it is conceptually
different and may be relocated to the top of the text editor in the
future.
2018-11-12 17:21:15 +10:30
Toby Zerner
bf3934d16f Improve appearance of text editor buttons
- Change preview icon to Font Awesome Regular instead of Solid
- Give the preview button a tooltip
- Change submit button icon to paper plane (shown on mobile)
- Tweak mobile header button touch target
- Scroll overflowing text editor controls horizontally
2018-11-12 17:19:37 +10:30
flarum-bot
a08068b112 Bundled output for commit 60149fbe15 [skip ci] 2018-11-12 01:14:08 +00:00
Toby Zerner
60149fbe15 Merge pull request #1634 from clarkwinkelmann/fix-scrubber-index
Fix scrubber index exceeding post count
2018-11-12 11:40:29 +10:30
Clark Winkelmann
13c593cbaa Fix notification isRead value not being updated in API update response (#1635) 2018-11-12 00:14:13 +01:00
Toby Zerner
f7a320bcca Boot new application instance before enabling extensions. fixes #1587 (#1631) 2018-11-12 00:01:17 +01:00
Franz Liedke
b980c6fb7d Remove unused default constructor 2018-11-11 23:52:47 +01:00
Clark Winkelmann
0f9118fe2b Clean PostStreamScrubber code 2018-11-11 19:03:22 +01:00
Clark Winkelmann
95f0edcd80 Fix scrubber index not limited to max items count when bypassing view() 2018-11-11 19:00:51 +01:00
Toby Zerner
222e3c3fe2 Log errors that occur in the API stack
This takes place only in the FallbackExceptionHandler. Having a custom
exception handler implies that a friendly message is displayed in the
API response, in which case we can bet that the exception won't need to
be "debugged" per se.
2018-11-11 18:00:57 +10:30
Toby Zerner
903c1e329d Stop logging errors that use a custom view
Having a custom view implies that a friendly message is displayed to
the user, in which case we can bet that the exception won't need to be
"debugged" per se.
2018-11-11 17:57:55 +10:30
Toby Zerner
295a007cd5 Catch Throwables so that we handle internal PHP errors too 2018-11-11 17:54:19 +10:30
flarum-bot
66404e1f61 Bundled output for commit bf8bc0222f [skip ci] 2018-11-11 06:35:34 +00:00
Toby Zerner
64e43ec9a4 Apply fixes from StyleCI (#1632)
[ci skip] [skip ci]
2018-11-11 17:01:34 +10:30
Toby Zerner
bf8bc0222f Delete associated notifications when deleting discussions, posts, and users. fixes #1380 2018-11-11 16:59:24 +10:30
Toby Zerner
6d14d0c39b Perform visibility checks on notification subjects at the query level
This will prevent a notification from being seen by a user if its
subject is deleted or undergoes some kind of permission change (eg.
a discussion is moved into a private tag)

ref #1380
2018-11-11 16:58:08 +10:30
Toby Zerner
17fdc0ebe0 Consolidate Post visibility logic into the PostPolicy
A post can only be seen if the discussion in which it resides can be
seen. The logic for this belongs in the policy, not the model.
2018-11-11 16:54:15 +10:30
Toby Zerner
9de786d1e6 Fix notification list not displaying "empty" message 2018-11-11 16:46:54 +10:30
Toby Zerner
b92ae61294 Always allow users to see their own account. fixes #1626 2018-11-11 14:25:21 +10:30
Franz Liedke
e99f7fcdac Fix leak of private information when updating users
Fixes #1628.
2018-11-09 12:02:26 +01:00
Franz Liedke
009ddcdb63 Add regression test for email crawling vulnerability
Refs #1628.
2018-11-09 12:02:26 +01:00
Franz Liedke
d021dc2399 Move trait to base test class
This way, its properties can be overwritten in subclasses of
`ApiControllerTestCase`. This isn't allowed when those subclasses
use the trait directly.
2018-11-09 12:02:21 +01:00
Daniël Klabbers
1fff5dbbbc add security address in issue template as well (#1630)
as per suggestion by @CDK2020, let's also add an important statement in the issue template
2018-11-09 10:02:20 +01:00
Daniël Klabbers
4de5accfc1 add security email address in flarum/core readme (#1629)
Let's make the security email address even more visible.
2018-11-08 23:41:51 +01:00
Daniël Klabbers
bb0fc165af [b8] master token fix (#1622)
* fixed not being able to use master token because id column no longer holds key
* added flexibility of user_id column
* added tests to confirm the api keys actually work as intended
2018-11-07 22:34:09 +01:00
flarum-bot
fb185f70cd Bundled output for commit f283f0c7bd [skip ci] 2018-11-07 21:20:16 +00:00
Franz Liedke
3b630cb03e Restore horizontal overflow for permission grid
Refs #1627.
2018-11-07 22:17:16 +01:00
Clark Winkelmann
f283f0c7bd Use ItemList for EditGroupModal fields (#1625) 2018-11-07 22:15:19 +01:00
David Sevilla Martín
4b915c688c Remove overflow from .PermissionsPage-permissions (#1627) 2018-11-06 22:41:21 +01:00
Toby Zerner
83e99ed5a5 Merge pull request #1623 from flarum/luceos-patch-1
Update AccessToken.php
2018-11-02 07:12:23 +10:30
Daniël Klabbers
a09894a906 Update AccessToken.php
Fixes phpdoc while working on #1622
2018-11-01 10:56:45 +01:00
flarum-bot
1c7d2c3d27 Bundled output for commit 7db6cfac3f [skip ci] 2018-10-31 13:35:47 +00:00
Daniël Klabbers
7db6cfac3f Update EditGroupModal.js
fixed placeholder icon name fa 4 style to fa 5 style with `fas fa-bolt`
2018-10-31 14:28:50 +01:00
Daniël Klabbers
c446c5cc61 fixes author gambit when used with fulltext search, added test to cover (#1620)
* fixes author gambit when used with fulltext search, added test to cover

* Apply fixes from StyleCI

[ci skip] [skip ci]
2018-10-29 23:01:25 +01:00
flarum-bot
bd10ebff24 Bundled output for commit 104d3982fe [skip ci] 2018-10-28 21:00:22 +00:00
Toby Zerner
104d3982fe Fix regression in admin routing in subdirectory. fixes #1606
Because admin routing uses the "hash" strategy, the base path does not
need to be taken into account.
2018-10-29 07:25:17 +10:30
Franz Liedke
a1948e7bb8 Fix installation in subdirectory
Fixes #1604.
2018-10-26 00:27:35 +02:00
Franz Liedke
4775535421 Fix tests 2018-10-24 22:38:47 +02:00
Franz Liedke
2392e06c0e Apply fixes from StyleCI (#1616)
[ci skip] [skip ci]
2018-10-24 22:20:15 +02:00
Franz Liedke
e3e10a8fc3 Allow setting all paths when instantiating Site
Fixes #1592.
2018-10-24 22:19:09 +02:00
flarum-bot
b4dbab5df1 Bundled output for commit f062f69f00 [skip ci] 2018-10-24 20:06:14 +00:00
Clark Winkelmann
f062f69f00 Update Font Awesome icons page link (#1615) 2018-10-24 21:20:49 +02:00
Toby Zerner
0e3b0fc5a0 Update forgotten column name 2018-10-23 20:52:09 +10:30
Franz Liedke
21b3737dc2 Merge pull request #1608 from flarum/fl/1602-extend-frontend-document
New extender for adding variables to HtmlDocument payload
2018-10-21 22:34:22 +02:00
Franz Liedke
4ed1d0aaee New extender for adding variables to HtmlDocument payload
Fixes #1602.
2018-10-21 20:45:19 +02:00
Franz Liedke
86b26ce2fb Tweak ContentInterface so that callables can be used as well 2018-10-21 20:41:45 +02:00
Toby Zerner
eafc637475 Prevent long words/content from stretching the discussion list width 2018-10-21 14:47:41 +10:30
Daniël Klabbers
a03f243ca5 Fixes logging in with access token (#1605)
Seems the created_at column has no default value. This was always the case, at least that's what I can tell from a clean install and no migrations changing that default value.

```
$table->timestamp('created_at');
```
2018-10-21 01:21:34 +02:00
Toby Zerner
5f5e1c512c Load extensions in the configured order 2018-10-20 22:21:39 +10:30
Toby Zerner
a4d540f74b Don't require paths to be set in config - use sensible defaults 2018-10-18 19:27:03 +10:30
Tristian Kelly
c23af9550e Broader system font stack (#1600) 2018-10-17 23:55:41 +02:00
David Sevilla Martín
8fd3e8908c Align search icon on search bar (#1599) 2018-10-16 20:40:39 +02:00
David Sevilla Martín
cc95faa07d Add migration to add 'fa fa-' to group icons (#1597)
* Add migration to add 'fa fa-' (FA v4 shim) to group icons

* StyleCI

* Change prefix to `fas fa-`
2018-10-10 00:39:19 +02:00
flarum-bot
f1add1798b Bundled output for commit 9fa7258325 [skip ci] 2018-10-09 22:32:47 +00:00
Franz Liedke
81f6ce220e Merge pull request #1594 from datitisev/item-list
Allow ItemList method chaining (add, merge, remove, replace)
2018-10-10 00:28:03 +02:00
Franz Liedke
9fa7258325 Merge pull request #1598 from flarum/dk/log-rotation
adds log rotation, reducing file size per log file and easier to delete
2018-10-10 00:27:39 +02:00
Daniël Klabbers
4841661ee2 adds log rotation, reducing file size per log file and easier to delete 2018-10-09 19:54:52 +02:00
David Sevilla Martín
7b34636636 Allow ItemList method chaining (add, merge, remove, replace) 2018-10-05 19:30:14 -04:00
Franz Liedke
8474dfd6e2 Consistent use of private instead of protected
See discussion in 5b821b21b1 (r30752077).
2018-10-04 09:08:43 +02:00
flarum-bot
737d33826e Bundled output for commit 3006f58274 [skip ci] 2018-09-29 23:59:11 +00:00
Toby Zerner
3006f58274 The document JS payload attribute was previously renamed to apiDocument 2018-09-30 09:24:25 +09:30
Toby Zerner
d3a5e2451a Merge pull request #1581 from flarum/fl/1463-extension-install-hooks
Extension enable/disable hooks
2018-09-29 08:19:26 +09:30
Franz Liedke
f03c954dcc Extensions do not need to know whether they are enabled 2018-09-26 23:34:33 +02:00
Franz Liedke
3b70b9e76e Let extensions take care of flushing the formatter cache 2018-09-26 23:11:27 +02:00
Franz Liedke
b823a9df47 migrate: Use existing public API to filter extensions 2018-09-26 23:03:48 +02:00
Franz Liedke
8621500501 Use early returns to flatten methods 2018-09-26 22:59:48 +02:00
Franz Liedke
f48101dc04 Add a new extender interface for extension lifecycle hooks 2018-09-26 22:56:25 +02:00
Franz Liedke
3c827d2fce Tweak extender interface in preparation for adding more methods 2018-09-26 22:36:36 +02:00
Charlie
1f0e9b6280 Update ExtensionPage Style (#1560) 2018-09-26 17:00:27 +09:30
Franz Liedke
bf61753361 Merge pull request #1577 from flarum/tz/database-indices
Database indices
2018-09-24 23:49:23 +02:00
flarum-bot
70cb2f6f2e Bundled output for commit 1736fe3f58 [skip ci] 2018-09-23 00:46:47 +00:00
Toby Zerner
1736fe3f58 Clean up PostsUserPage placeholder 2018-09-23 10:12:12 +09:30
flarum-bot
ae81c4f0f1 Bundled output for commit 8c679c715c [skip ci] 2018-09-22 22:01:38 +00:00
David Sevilla Martín
8c679c715c Allow admins to see last online text (#1540)
* Allow admins to see last online text

* Use viewLastSeenAt permission

* Move permission to UserSerializer, removed from ForumSerializer

* Remove extra comma from ForumSerializer to keep diff clean

* Add permission to new seed migration
2018-09-22 23:55:53 +02:00
Toby Zerner
4236f3d49e Merge pull request #1576 from datitisev/user-posts-page
Make user posts page similar to discussion page, add empty text
2018-09-23 07:22:08 +09:30
Sajjad Hashemian
e3afb38427 fix empty base url (#1453) 2018-09-22 21:58:18 +02:00
David Sevilla Martín
26a5b107bd Make user posts page similar to discussion page, add empty text 2018-09-22 14:02:14 -04:00
Franz Liedke
aa70441632 Fix installation command, part 2 2018-09-22 17:45:38 +02:00
David Sevilla Martín
0fb9aa3940 Align icons & text in SideNav and Dropdown (#1544) 2018-09-22 21:35:45 +09:30
flarum-bot
b6a60721e2 Bundled output for commit fe868af224 [skip ci] 2018-09-22 04:58:46 +00:00
Clark Winkelmann
fe868af224 Clean composer promises (#1439)
* Remove unused login promise code

* Make promise usage consistent across composer action methods
2018-09-22 14:25:19 +09:30
flarum-bot
0984979403 Bundled output for commit fcb97b256f [skip ci] 2018-09-22 04:19:52 +00:00
Toby Zerner
5dfb9b474c Auth token and avatarUrl security improvements (#1514)
* Remove AbstractOAuth2Controller

There is no reason to provide an implementation for a specific oAuth2
library in core; it's not generic enough (eg. auth-twitter can't use it).

This code could be moved into another package which auth extensions
depend on, but it's a negligible amount of relatively simple code that
I don't think it's worth the trouble.

* Introduce login providers

Users can have many login providers (a combination of a provider name
and an identifier for that user, eg. their Facebook ID).

After retrieving user data from a provider (eg. Facebook), you pass the
login provider details into the Auth\ResponseFactory. If an associated
user is found, a response that logs them in will be returned. If not, a
registration token will be created so the user can proceed to sign up.
Once the token is fulfilled, the login provider will be associated with
the user.
2018-09-22 13:48:27 +09:30
Toby Zerner
fcb97b256f Add migration helper to drop columns 2018-09-22 13:45:41 +09:30
Toby Zerner
4429cf4eba Merge pull request #1513 from flarum/tz/1419-restrict-own-permissions
Make "own" permissions depend on the user's ability to reply
2018-09-22 12:22:03 +09:30
Toby Zerner
c54f739484 Make "own" permissions depend on the user's ability to reply
Permission to rename/hide/edit one's own discussion/post is only granted
if the user has permission to reply to the discussion. This makes sense
if you think of these actions as forms of "replying" to a discussion.

Fixes #1419 because suspended users do not have permission to reply to
discussions, therefore they will not be granted these "own" permissions.
2018-09-22 12:15:46 +09:30
Franz Liedke
6c0d73afa0 Fix tests 2018-09-22 00:40:19 +02:00
Franz Liedke
1cd8ec6873 Display only exception messages during booting
By not letting PHP render the stack trace, we prevent displaying
sensitive information (such as the database credentials). Instead,
we display a simple line with the exception message.

In the console, the full exception can still be shown, as that is
a tool only for forum admins anyway.

Fixes #1421.
2018-09-21 23:33:28 +02:00
Franz Liedke
4ed1c7a1bb Boot Flarum app in Server classes
This is in preparation for fixing #1421 - it allows us to
encapsulate the exception handling in the server classes, so that
we can keep the skeleton (flarum/flarum) lean.
2018-09-21 23:30:14 +02:00
Franz Liedke
c67f673819 Remove references to deleted property 2018-09-21 12:29:16 +02:00
flarum-bot
7917ce130e Bundled output for commit 2b174b17fc [skip ci] 2018-09-21 05:07:46 +00:00
Toby Zerner
2b174b17fc Fix tests 2018-09-21 14:32:41 +09:30
Toby Zerner
550d35e86f Apply fixes from StyleCI (#1574)
[ci skip] [skip ci]
2018-09-21 14:28:02 +09:30
Toby Zerner
64686ef7a9 Remove the "debug" button from request error alerts
Using the browser's console to debug failed requests is much more powerful
2018-09-21 14:27:39 +09:30
Toby Zerner
5ce702a5d0 Make registration errors still work properly when debug mode is on 2018-09-21 14:18:17 +09:30
flarum-bot
fdf5fdbaf3 Bundled output for commit 184ffcd991 [skip ci] 2018-09-21 02:30:05 +00:00
Toby Zerner
184ffcd991 Sort user discussion list properly 2018-09-21 11:55:00 +09:30
flarum-bot
ba946237e4 Bundled output for commit 8ec0578ddf [skip ci] 2018-09-21 02:09:25 +00:00
Toby Zerner
8ec0578ddf Fix installation command 2018-09-21 11:32:46 +09:30
Toby Zerner
c34fcecf03 Update TextFormatter deprecated API 2018-09-21 11:23:24 +09:30
Toby Zerner
9e487b4e41 Live output of migrator notes 2018-09-21 11:22:51 +09:30
Toby Zerner
986d811a16 Fix notifications crash
When loading notifications, $this->type was null and thus array_get
was returning an array instead of null. I assume this issue was
introduced in a Laravel version upgrade? Anyway, this fixes it.
2018-09-21 11:22:26 +09:30
Toby Zerner
c32af6559e Fix group badge misalignment if there is no group icon 2018-09-21 11:20:54 +09:30
Toby Zerner
07298e165d Use default system font instead of Open Sans 2018-09-21 11:20:17 +09:30
Toby Zerner
c15bbc9c5e Add "tiny" preset for LoadingIndicator
This is used in various places but had not been added since presets were
removed from Spin.js in a recent version upgrade.
2018-09-21 11:19:32 +09:30
Toby Zerner
6c8c525e57 Fix regression introduced by #1543
The Page component's config method wasn't being called, therefore the
bodyClass would not be applied.
2018-09-21 11:17:54 +09:30
Toby Zerner
93dfb6dec9 Revert "Frontend extender: Remove route registration"
This reverts commit 4770a5c906.
2018-09-21 09:05:45 +09:30
Toby Zerner
750d9d05a6 Use container events as an alternative to the ConfigureMiddleware event (#1462)
By moving the DispatchRoute middleware into an `afterResolving`
callback, this will allow a new Middleware extender to add a `resolving`
callback to the appropriate container binding, removing the need for the
ConfigureMiddleware event.

The ConfigureMiddleware event has been deprecated and should be removed
in beta 9.
2018-09-16 21:21:13 +02:00
Franz Liedke
0ce289be4c Travis: Add table prefix to build matrix (#1568)
Fixes #1564.
2018-09-16 20:59:40 +02:00
flarum-bot
7fcf556f13 Bundled output for commit 68afdd21ae [skip ci] 2018-09-16 18:51:11 +00:00
Franz Liedke
68afdd21ae Merge pull request #1344 from flarum/1236-database-changes
Database changes
2018-09-16 20:44:29 +02:00
Toby Zerner
54aa9ee3cf Add database indices. closes #127 2018-09-15 14:32:51 +09:30
Toby Zerner
5635bd26f9 Fix query error 2018-09-15 12:44:59 +09:30
Toby Zerner
622bf26510 Inline permissions migration 2018-09-15 12:40:32 +09:30
Franz Liedke
2367a45c18 Use instance variable directly instead of passing it around 2018-09-07 01:40:31 +02:00
Franz Liedke
4770a5c906 Frontend extender: Remove route registration
This can be achieved using the Route extender, which is more
flexible, as it does not necessary connect the URL with the current
frontend's router.

(Example use-case: The ext-embed frontend will be a new frontend,
however any routes using this frontend will be part of the forum
route group.)

Refs #851.
2018-09-07 01:40:31 +02:00
Franz Liedke
c61badd754 Frontend extender: Route to correct frontend
So far, we always added routes configured via this extender to the
forum frontend. Not correct.
2018-09-07 01:02:13 +02:00
Franz Liedke
14393ec53e RouteHandlerFactory: Refactor frontend parameter
By passing in just the frontend identifier, we can hide some of the
implementation details, in this case the identifier of the Frontend
instance in the IoC container.
2018-09-07 01:00:56 +02:00
Franz Liedke
96045ca390 flarum info: Try to fix STDERR redirection for Windows
See the following articles for more information:
- https://www.24k.com.sg/blog-27.html
- https://support.microsoft.com/en-us/help/110930/redirecting-error-messages-from-command-prompt-stderr-stdout

Refs #1562.
2018-09-07 00:25:26 +02:00
Franz Liedke
eb228dd7b9 flarum info: Extract extension table to function 2018-09-04 00:38:08 +02:00
Franz Liedke
092e5b9d23 flarum info: Tweak output styling 2018-09-04 00:32:54 +02:00
David Sevilla Martín
7e3980744e InfoCommand improvements (#1562)
* Ignore error output of 'git rev-parse HEAD'
* Organize extension information in a table
2018-09-04 00:24:07 +02:00
Franz Liedke
85c965afbc Use correct method from contract 2018-09-03 23:55:16 +02:00
David Sevilla Martín
43fc2c0952 Add 'oldUsername' to User\Event\Renamed (#1563) 2018-09-03 22:42:30 +02:00
Franz Liedke
5a9b47cdf7 Apply fixes from StyleCI (#1561)
[ci skip] [skip ci]
2018-09-01 23:35:37 +02:00
Franz Liedke
5374f8a352 flarum info: Display warning when in debug mode
Refs #1421.
2018-09-01 16:57:44 +02:00
Franz Liedke
5f5af894ab Load per-site extenders, if available
Closes #1559.
2018-09-01 16:27:52 +02:00
Franz Liedke
d7c283a48f Frontend extender: Work without extension, too 2018-09-01 16:15:02 +02:00
flarum-bot
c5a3715701 Bundled output for commit 710c63ba6a [skip ci] 2018-08-25 10:56:59 +00:00
Toby Zerner
710c63ba6a Update JS tooling 2018-08-25 20:18:59 +09:30
Toby Zerner
5142c639c1 Rename user methods 2018-08-24 22:13:06 +09:30
Toby Zerner
eb3232dfc9 Missed a spot 2018-08-24 22:13:06 +09:30
Toby Zerner
72d46bc461 Fix up Notification model 2018-08-24 22:13:06 +09:30
Toby Zerner
9792576464 Rename notification.sender 2018-08-24 22:13:06 +09:30
Toby Zerner
5c0c2d1c40 Rename notification.time 2018-08-24 22:13:05 +09:30
Toby Zerner
ce39bc9070 Rename user.newNotificationsCount 2018-08-24 22:13:05 +09:30
Toby Zerner
37ffd04b3f Rename user.unreadNotificationsCount 2018-08-24 22:13:05 +09:30
Toby Zerner
d8d2de438f Rename user.readTime 2018-08-24 22:13:05 +09:30
Toby Zerner
70058652b5 Rename user.isActivated 2018-08-24 22:13:05 +09:30
Toby Zerner
d9d8162684 Rename user.lastSeenTime 2018-08-24 22:13:05 +09:30
Toby Zerner
2ee10bb49f Rename user.commentCount 2018-08-24 22:13:05 +09:30
Toby Zerner
64abbde8b2 Rename user.discussionsCount 2018-08-24 22:13:05 +09:30
Toby Zerner
ca93c8c609 Rename post.hideUser 2018-08-24 22:13:05 +09:30
Toby Zerner
8248ba2f7a Rename post.editUser 2018-08-24 22:13:05 +09:30
Toby Zerner
dd65801d57 Rename post.hideTime 2018-08-24 22:13:05 +09:30
Toby Zerner
07c08ca798 Rename post.editTime 2018-08-24 22:13:05 +09:30
Toby Zerner
ae75f21b6b Rename post.time 2018-08-24 22:13:05 +09:30
Toby Zerner
d47c406d9c Rename discussion.repliesCount 2018-08-24 22:13:05 +09:30
Toby Zerner
29cef23404 Rename discussion.hideUser 2018-08-24 22:13:05 +09:30
Toby Zerner
a7ffed6778 Rename discussion.readNumber 2018-08-24 22:13:05 +09:30
Toby Zerner
9074f7e592 Rename discussion.readTime 2018-08-24 22:13:05 +09:30
Toby Zerner
99e5013ac3 Rename discussion.hideTime 2018-08-24 22:13:05 +09:30
Toby Zerner
1e9d9b8322 Rename discussion.lastTime 2018-08-24 22:13:05 +09:30
Toby Zerner
568006fe73 Rename discussion.startTime 2018-08-24 22:13:05 +09:30
Toby Zerner
4756bf1daf Rename discussion.lastPostedUser 2018-08-24 22:13:05 +09:30
Toby Zerner
8ecb67d49d Rename discussion.startUser 2018-08-24 22:13:05 +09:30
Toby Zerner
e241518506 Rename discussion.startPost 2018-08-24 22:13:05 +09:30
Toby Zerner
cbd0643540 Rename discussion.participantsCount 2018-08-24 22:13:05 +09:30
Toby Zerner
7716944616 Rename discussion.commentsCount 2018-08-24 22:13:05 +09:30
Toby Zerner
e135b7830e Fix installer 2018-08-24 22:12:45 +09:30
Toby Zerner
950ab30c29 Fix reset password 2018-08-24 21:54:46 +09:30
Toby Zerner
582054c61c Merge branch 'master' into 1236-database-changes 2018-08-24 21:07:00 +09:30
Toby Zerner
280d51e678 Merge pull request #1555 from flarum/fl/sites
Rewrite sites / app
2018-08-24 18:21:05 +09:30
Toby Zerner
e9ed935ed1 Revert method name 2018-08-24 17:09:22 +09:30
Toby Zerner
809b161d71 Merge branch 'master' into 1236-database-changes 2018-08-24 17:03:50 +09:30
Toby Zerner
6bc434c918 Remove user_user table
Since there is currently no core code that facilitates use of this table,
we are removing it for now. It can be re-added in a subsequent PR.
2018-08-24 15:15:40 +09:30
Franz Liedke
4c8908c005 Rename extension's bootstrap.php to extend.php
...while supporting the old name for a while.

Fixes #1556.
Refs #1557.
2018-08-24 00:08:56 +02:00
Franz Liedke
2d4dc02ca1 Pass container into apps, adapt path matching 2018-08-23 22:17:37 +02:00
Franz Liedke
869ec54bd0 Load middleware stacks lazily
This way, the forum middleware does not need to be loaded for
API requests, and vice-versa.
2018-08-22 09:20:47 +02:00
Franz Liedke
59b1ca9b7c Implement request handler for maintenance mode 2018-08-22 09:20:00 +02:00
Franz Liedke
7439069fe2 Use more honest method names 2018-08-22 07:58:50 +02:00
Franz Liedke
973fbcf17b Instantiate DispatchRoute manually
Since we are already providing the first and only argument
manually, we might as well instantiate the object manually.
Same effect, same coupling, less code.
2018-08-22 07:58:50 +02:00
Franz Liedke
034000ea0b Fix tests after sites refactoring 2018-08-22 07:58:50 +02:00
Franz Liedke
fb5740926a Split SessionServiceProvider from UserServiceProvider
This lets us register the former during installation, where the
latter is not yet registered.

That, in turn, means we can finally re-enable the StartSession
middleware in the installer app, which we need to log in the new
admin user when installation is complete.
2018-08-22 07:58:50 +02:00
Franz Liedke
32ad926cbc One BusServiceProvider is enough 2018-08-22 07:58:50 +02:00
Franz Liedke
626d16de6f Use zend-httphandlerrunner for marshalling requests and returning responses
Since Diactoros 1.8, the emitter and server classes have been
deprecated. They can be replaced by using this new package
directly.
2018-08-22 07:58:50 +02:00
Franz Liedke
0222692c53 Console Installer: Rely less on service providers
Most things we need, we can instantiate directly.

This means we have to do less tweaking in service providers that
are meant to provide services to a complete Flarum application
(that has already been installed properly), to make them work with
the uninstalled app.

The uninstalled app (the "installer") can now do only the
bootstrapping it needs to build a light-weight web and console
application, respectively.
2018-08-22 07:58:50 +02:00
Franz Liedke
b4b72fe62f Get rid of some Application methods
These are not necessary to be available so broadly. In fact, they
seem to make it too easy to use them, which has lead to some sub-
optimal architecture decisions.

Their equivalents have been moved to the classes where used.
2018-08-22 07:58:50 +02:00
Franz Liedke
5b821b21b1 Split up Site into several classes
Depending on the state of the Flarum installation (installed, not
installed, currently upgrading, maintenance mode), we should enable
different sets of service providers.

For example, during installation we should not resolve a setting
repository from the container. This new architecture lets us do so,
but we can easily (and cleanly) register a different implementation
during installation.

This should prevent problems such as #1370 in the future.
2018-08-22 07:58:50 +02:00
Franz Liedke
7a6e208554 Split up HandleErrors middleware into distinct classes
These are completely distinct functionalities, toggled through the
system-wide debug flag. By moving the selection of the middleware
to use to the place where the middleware pipe is built, we make
the middleware itself be unaware of these flags. The two classes
are more focused on what they are doing, with the constructor
dependencies clearly representing their requirements.

In addition, this means we can just use the HandleErrorsWithWhoops
middleware in the installer, which means we do not need to worry
about how to inject a SettingsRepositoryInterface implementation
when flarum is not yet set up.
2018-08-22 07:58:50 +02:00
flarum-bot
3a0e982df1 Bundled output for commit 6057151c29 [skip ci] 2018-08-22 00:08:57 +00:00
David Sevilla Martín
6057151c29 Fix PR issues from #1496 (#1553)
* Remove `+` added from copying a diff somewhere

* Fix font-size
2018-08-22 09:34:18 +09:30
flarum-bot
fcb9a049e9 Bundled output for commit 190bcb5e9a [skip ci] 2018-08-21 21:21:28 +00:00
Arda Çebi
190bcb5e9a Add descriptions and optimize extensions page (#1496) 2018-08-21 23:16:02 +02:00
flarum-bot
e72ac76997 Bundled output for commit 62e7a7188c [skip ci] 2018-08-19 21:48:23 +00:00
David Sevilla Martín
62e7a7188c Add a permission check to the Search sources (#1527) 2018-08-19 23:43:49 +02:00
David Sevilla Martín
ca16a23383 Installer: add check for file existence & fix path resolving (#1397) 2018-08-19 23:40:37 +02:00
Toby Zerner
195f77ff10 Apply fixes from StyleCI (#1551)
[ci skip] [skip ci]
2018-08-18 12:13:40 +09:30
Toby Zerner
5f83285442 Add extension JS as a file to allow sourcemap detection
Fixes #1538
2018-08-18 12:13:17 +09:30
Franz Liedke
c16ddf24f2 Add tokenizer to PHP extension requirements
Refs flarum/flarum.github.io#73.
2018-08-14 22:53:12 +02:00
flarum-bot
394fc4232e Bundled output for commit fd36d18729 [skip ci] 2018-08-14 20:19:39 +00:00
David Sevilla Martín
fd36d18729 Change tab title after renaming discussion (#1543)
* Change tab title after renaming discussion

* Uncommit dist

* Uncommit package-lock.json

* Fix for VDOM

* Move setTitle into DiscussionPage#config
2018-08-14 22:15:47 +02:00
Daniël Klabbers
2e16b0ce2e Update PULL_REQUEST_TEMPLATE.md (#1545)
* Update PULL_REQUEST_TEMPLATE.md

Added clarification about bundled PRs.

* Update PULL_REQUEST_TEMPLATE.md
2018-08-14 22:08:16 +02:00
flarum-bot
af47558ec2 Bundled output for commit 641079b3fe [skip ci] 2018-08-14 19:50:55 +00:00
Edward Betts
641079b3fe Correct spelling mistakes. (#1546) 2018-08-14 21:46:53 +02:00
David Sevilla Martín
df0f4e8462 Fix post composer width bug on profile (#1541) 2018-08-14 06:44:28 +09:30
flarum-bot
da0adf83ae Bundled output for commit 0452838802 [skip ci] 2018-08-13 21:07:47 +00:00
David Sevilla Martín
0452838802 ModalManager: Fix issue when app.current is not defined (#1530) 2018-08-14 06:33:39 +09:30
David Sevilla Martín
40e4c0acdd Fix wrong permission in UserPolicy#find (#1536) 2018-08-13 06:45:56 +09:30
Charlie
ef9ed7f4fa Dispatch the Deserializing event in Admin Content (#1532)
* Dispatch the Deserializing event

* Apply fixes from StyleCI (#1)
2018-08-11 17:15:11 +09:30
Franz Liedke
24fd2f32c7 Service Provider: Move loadViewsFrom() to boot()
This method relies on the "view" being bound in the IoC container.
This is only guaranteed after all register() methods have run, thus
it should be done in boot().
2018-08-03 00:53:39 +02:00
Franz Liedke
076288db21 Update zend-diactoros constraint
See security advisory ZF2018-01:
https://framework.zend.com/security/advisory/ZF2018-01
2018-08-02 23:15:24 +02:00
Clark Winkelmann
df7e24cba6 Update urls with their current canonical versions (#1524) 2018-08-02 17:39:06 +02:00
Toby Zerner
5438aea759 Apply fixes from StyleCI
[ci skip] [skip ci]
2018-08-01 03:55:21 +00:00
Toby Zerner
e46ce861dc Change TIMESTAMP columns to DATETIME manually 2018-08-01 13:24:55 +09:30
flarum-bot
01d8bd5344 Bundled output for commit 7f5080d9d5 [skip ci] 2018-07-24 15:44:53 +00:00
Toby Zerner
7f5080d9d5 Merge pull request #1520 from sijad/spinner-config
configure spinner only once
2018-07-25 01:08:50 +09:30
Sajjad Hashemian
640b93af36 configure spinner only once 2018-07-24 19:25:09 +04:30
Franz Liedke
cfc207f255 Apply fixes from StyleCI (#1518)
[ci skip] [skip ci]
2018-07-23 16:25:12 +02:00
Franz Liedke
d4a80eae5d Replace Assets with Frontend extender
This extender allows registering both assets and simple GET routes
with frontend instances.

See #851.
2018-07-23 16:24:00 +02:00
Toby Zerner
254d5d0c5b Fix group/permission seeding
Updating the Migration::addPermission helper table name means we need
to move the seed migration to after the table rename migration. We also
add a sanity check for each permission's group since the foreign key
will fail if the group doesn't exist. Of course, the only way to make
sure groups are seeded before permissions is to move them into another
migration.
2018-07-21 23:02:44 +09:30
Toby Zerner
1709d4ef2c Remove file accidentally added in merge 2018-07-21 22:09:14 +09:30
Toby Zerner
baeaa73597 Wrap column names; use whereColumn where possible 2018-07-21 22:02:54 +09:30
Toby Zerner
677a7dd2d3 Merge branch 'master' into 1236-database-changes
# Conflicts:
#	src/Forum/Controller/IndexController.php
#	src/User/UserMetadataUpdater.php
2018-07-21 21:37:49 +09:30
Toby Zerner
c562302161 Don't save in the model 2018-07-21 21:28:44 +09:30
Toby Zerner
d42f33971a Fix user list sorting 2018-07-21 18:39:32 +09:30
Toby Zerner
aa4c4b07bd Revert notifications_from table
I didn't think this change through and it's going to be too difficult
to implement right now. It can wait until we do the notifications
revamp. For now reverting back to the old structure, with the
`sender_id` column renamed to `from_user_id`.
2018-07-21 18:35:50 +09:30
Toby Zerner
420bb2efc8 Apply fixes from StyleCI
[ci skip] [skip ci]
2018-07-21 07:52:21 +00:00
Toby Zerner
ed57d6e51c Clean up attribute assignment 2018-07-21 17:22:03 +09:30
Toby Zerner
b4f6c4be1f Specify ambiguous column names 2018-07-21 17:21:37 +09:30
Toby Zerner
ff7f7681c7 Use Eloquent's latest and oldest 2018-07-21 17:21:08 +09:30
Toby Zerner
7d0813bce4 Fix some incorrect attribute names 2018-07-21 17:20:43 +09:30
Toby Zerner
4f259425b0 Fix entity deletion
Foreign keys take care of most of this for us!
2018-07-21 17:18:40 +09:30
Toby Zerner
22fadb7f9c Fix API key generation 2018-07-21 17:14:15 +09:30
Toby Zerner
d0115de771 No need for deleted_at in notifications table 2018-07-21 17:13:51 +09:30
Toby Zerner
9d790c18d6 Change TIMESTAMP columns to DATETIME 2018-07-21 17:12:51 +09:30
Toby Zerner
6f3eb3f335 Fix discussion and post list sorting 2018-07-21 17:10:02 +09:30
Toby Zerner
2d667d885d Fix email confirmation links 2018-07-21 17:08:11 +09:30
Toby Zerner
0fb81958cb Clean up Eloquent definitions 2018-07-21 17:06:42 +09:30
Toby Zerner
87bba2186e Fix to ensure we can rename columns in tables with enums
See https://github.com/laravel/framework/issues/1186
2018-07-21 15:26:12 +09:30
Toby Zerner
93b9513df2 Fix column names 2018-07-21 15:24:51 +09:30
Toby Zerner
fb6b2d05b1 Fix table name 2018-07-21 15:24:33 +09:30
Toby Zerner
fe73cf3237 Clean up migrations
* Make filenames and order more consistent

* Split foreign keys into their own migrations, add statements to ensure
  data integrity prior to adding them

* Add renameColumns helper, use other helpers where possible
2018-07-21 15:23:37 +09:30
Daniel Klabbers
c7efbba0da resetting to short annotation for dropping foreign key constraint, as per docs, must use array notation for this to work 2018-07-20 09:35:16 +02:00
Daniel Klabbers
be266a73cd fixed another foreign key drop with incorrect name 2018-07-20 09:24:42 +02:00
Daniel Klabbers
e1a282e0e1 forgot to name a few constraints properly on the dropForeign statement 2018-07-20 09:23:03 +02:00
Daniel Klabbers
5a04635e7a decided to leave the posts.discussion_id foreign key constraint to discussions out for now 2018-07-20 08:41:01 +02:00
flarum-bot
7d59b4da7e Bundled output for commit 6a6b9ac6b1 [skip ci] 2018-07-20 03:13:58 +00:00
Daniël Klabbers
f89c111f13 Update PULL_REQUEST_TEMPLATE.md (#1505) 2018-07-20 12:39:50 +09:30
Toby Zerner
6a6b9ac6b1 Use flexbox for sideNav. fixes #1408 2018-07-20 12:34:43 +09:30
Toby Zerner
cbe328cdc5 Revert Chrome image rendering tweak
The Chrome bug appears to have been fixed:
https://bugs.chromium.org/p/chromium/issues/detail?id=562162

This CSS rule makes images look very ugly in Safari, so removing it.

ref #1259
2018-07-20 12:03:49 +09:30
Toby Zerner
7b802a76ba Dissociate .sideNav--horizontal from @expand-side-nav 2018-07-20 11:38:42 +09:30
Daniel Klabbers
90792abf10 added constraints, discussions_first_post_id_foreign blocks here 2018-07-19 10:36:46 +02:00
Daniel Klabbers
5139ce647e instead of changing fulltext, use medium text schema builder change on posts.content 2018-07-19 09:52:20 +02:00
Daniel Klabbers
8779e40ec5 remove migration (initially was intended) to change settings.value to longblob 2018-07-19 09:45:29 +02:00
Daniel Klabbers
1e372f3881 split up the migration to create and seed notifications_from 2018-07-19 09:22:34 +02:00
Daniel Klabbers
b2e873ba7b undo carbon change as proposed in review 2018-07-19 09:15:59 +02:00
David Sevilla Martín
d6414cfb44 Properly set comments_count and discussions_count (#1436) 2018-07-17 19:02:37 +02:00
Franz Liedke
85ceda0b0b Remove another unused parameter 2018-07-16 15:48:48 +02:00
Franz Liedke
dc7c31e1c2 Remove incorrect attribute 2018-07-16 15:48:48 +02:00
Franz Liedke
177ac74596 Apply fixes from StyleCI (#1508)
[ci skip] [skip ci]
2018-07-16 15:13:21 +02:00
Franz Liedke
c76d9e1298 Move initial permission setup to migrations
Refs #1466.
2018-07-16 15:12:46 +02:00
Franz Liedke
dee54a008f Apply fixes from StyleCI (#1507)
[ci skip] [skip ci]
2018-07-16 01:44:50 +02:00
Franz Liedke
551ca23267 Discussion HTML: Add a canonical URL
Refs #358 and #1140.
2018-07-16 01:43:06 +02:00
Franz Liedke
3d845d5730 Discussion HTML: Fix generation of next/prev URLs 2018-07-16 01:42:36 +02:00
Franz Liedke
9b03f8c71a Make post filtering work with database prefixes 2018-07-16 01:22:13 +02:00
Franz Liedke
665f241348 Add migration for new hidePosts permission
Refs #1387 and #1466.
2018-07-16 00:41:55 +02:00
Franz Liedke
ce90d2bbdd Installer: Get rid of an instance variable
Leftover from PR #1405.
2018-07-16 00:33:32 +02:00
Franz Liedke
6e5b0f5289 Formatter: Tweak minifier setup
See discussion in PR #1457.
2018-07-14 22:57:20 +02:00
Sajjad Hashemian
fba31995b1 Upgrade text formatter (#1457)
* upgrade TextFormatter

* remove finalize options

* cleanup JsCompiler

* simplify Formatter

* refactor Formatter cache

* minify formatter js

* remove Closure Compiler
2018-07-14 22:22:14 +02:00
flarum-bot
604c789ee8 Bundled output for commit 034b82f4d4 [skip ci] 2018-07-14 20:19:52 +00:00
AFR
034b82f4d4 Create new hidePosts permission (#1466) 2018-07-14 22:15:40 +02:00
Daniel Klabbers
9be13cb1cd Revert "Update PULL_REQUEST_TEMPLATE.md"
This reverts commit 823f0263ae.
2018-07-13 10:34:09 +02:00
Daniël Klabbers
823f0263ae Update PULL_REQUEST_TEMPLATE.md
adding a requirement list
adding related required changes
added comment description
2018-07-13 10:32:57 +02:00
Toby Zerner
fb9a89f67f Use box-shadow instead of border for notifications badge
fixes #1481
closes #1500
2018-07-13 17:39:47 +09:30
Franz Liedke
7f63923aa0 Merge pull request #1503 from flarum/dk/1480
Update feature-request.md
2018-07-10 20:50:57 +02:00
Daniël Klabbers
73f8922553 Update feature-request.md 2018-07-10 06:26:29 +02:00
Daniel Klabbers
2c15597ec9 reset the relation table naming from groups_users to adhere to laravel convention group_user 2018-07-09 11:53:59 +02:00
Daniël Klabbers
7e43de25a6 Update feature-request.md
fixes #1480

This is a suggestion to improve clarification of what a feature request on our issue tracker should entail.

Changes made:

- uppercased "IMPORTANT" instead of a "Note" to clarify the importance of the comment
- removed the "serious" related information, because users often have no scale to rate seriousness against
- brought more attention to approval by a core developer or argumentation and implementation by moving that to the front
2018-07-09 10:54:37 +02:00
Franz Liedke
d42205a8ff Update doctrine/dbal version constraint
This update is needed to fix MariaDB compatibility.
See #1211.
2018-07-09 00:14:57 +02:00
Franz Liedke
00bc8fc0bc Composer: Reorder dependencies
[ci skip]
2018-06-30 23:46:10 +02:00
flarum-bot
c17af492a9 Bundled output for commit 0e73785498 [skip ci] 2018-06-30 03:05:06 +00:00
Toby Zerner
0e73785498 Frontend refactor (#1471)
Refactor Frontend + Asset code

- Use Laravel's Filesystem component for asset IO, meaning theoretically
  assets should be storable on S3 etc.

- More reliable checking for asset recompilation when debug mode is on,
  so you don't have to constantly delete the compiled assets to force
  a recompile. Should also fix issues with locale JS files being
  recompiled with the same name and cached.

- Remove JavaScript minification, because it will be done by Webpack
  (exception is for the TextFormatter JS).

- Add support for JS sourcemaps.

- Separate frontend view and assets completely. This is an important
  distinction because frontend assets are compiled independent of a
  request, whereas putting together a view depends on a request.

- Bind frontend view/asset factory instances to the container (in
  service providers) rather than subclassing. Asset and content
  populators can be added to these factories – these are simply objects
  that populate the asset compilers or the view with information.

- Add RouteHandlerFactory functions that make it easy to hook up a
  frontend controller with a frontend instance ± some content.

- Remove the need for "nojs"

- Fix cache:clear command

- Recompile assets when settings/enabled extensions change
2018-06-30 12:31:12 +09:30
Daniel Klabbers
0f5ddc1c43 phpversion minimum requirement changed in wrong location for installation 2018-06-28 11:40:34 +02:00
Daniel Klabbers
eaf98ccfc5 Revert "have install command demand php 7.1 too"
This reverts commit 9c7cc0548e.
2018-06-28 11:39:19 +02:00
Daniel Klabbers
9c7cc0548e have install command demand php 7.1 too 2018-06-28 11:23:04 +02:00
luceos
cf80cf86e5 Apply fixes from StyleCI
[ci skip] [skip ci]
2018-06-27 19:34:07 +00:00
Daniël Klabbers
a23dc0dfcd fixed some migration names and used helper where appropriate 2018-06-27 21:33:53 +02:00
Daniël Klabbers
54678e8d5c Merge branch 'master' into 1236-database-changes 2018-06-27 21:23:52 +02:00
Daniël Klabbers
4d2d7465ee Revert "migrating user preferences obviously works on empty table"
This reverts commit 066baed5b9.
2018-06-27 21:22:28 +02:00
flarum-bot
b78129b36b Bundled output for commit afe06ea750 [skip ci] 2018-06-27 19:17:31 +00:00
Franz Liedke
afe06ea750 Merge pull request #1456 from sijad/prevent-undefined
check class string before concat
2018-06-27 21:10:40 +02:00
Daniël Klabbers
9449fb4f1f not dropping bio due to not having a replacement 2018-06-27 21:09:32 +02:00
Sajjad Hashemian
aac194616a check class string before concat 2018-06-25 09:40:06 +04:30
Daniël Klabbers
d9b357c18e we need to leave the preferences column for now 2018-06-22 23:43:37 +02:00
Daniël Klabbers
48ac132959 Merge branch '1236-database-changes' of github.com:flarum/core into 1236-database-changes 2018-06-22 23:42:46 +02:00
Toby Zerner
b3f8379a15 Allow a single extender to be returned (#1469)
Casting an object to an array does not have the intended effect of
wrapping the object in an array. Instead we need to explicitly check
if the returned value is an array or not.
2018-06-22 18:10:54 +09:30
Daniel Klabbers
1800f4290a Merge branch 'master' into 1236-database-changes 2018-06-22 07:48:21 +02:00
flarum-bot
2234a81ee7 Bundled output for commit 805768a9e0 [skip ci] 2018-06-22 01:24:44 +00:00
Toby Zerner
805768a9e0 [WIP] JS Extender API foundation (#1468)
* Run extenders exported by extensions
* Add some basic extenders
* Patch Mithril as the very first thing so extension code can run safely
* Load the payload into the app before booting extensions
* Setup default routes before booting extensions
2018-06-22 10:49:46 +09:30
Franz Liedke
e3c2ddad2e Merge pull request #1465 from flarum/tz/formatter-extender
Rename and improve FormatterConfiguration extender
2018-06-21 10:11:35 +02:00
Toby Zerner
520e1550d1 Merge event listener registration 2018-06-20 23:37:27 +02:00
Toby Zerner
79b00cb94f Rename and improve FormatterConfiguration extender
In the future we may have multiple Formatters, so by moving the config
callback to its own instance method we can leave the constructor
available to specify which formatter (like Assets and Routes). This
format also allows for other methods to be added.

Additionally, this adds logic to automatically flush the Formatter cache
whenever the extension is enabled or disabled.
2018-06-20 23:37:27 +02:00
Toby Zerner
0bcc6e74a8 Checkout the branch before committing 2018-06-20 14:47:37 +09:30
Toby Zerner
542e8715ea git config before commit [skip ci] 2018-06-20 14:42:18 +09:30
Toby Zerner
3f683dd6ee Webpack (#1367)
* Replace gulp with webpack and npm scripts for JS compilation
* Set up Travis CI to commit compiled JS
* Restructure `js` directory; only one instance of npm, forum/admin are "submodules"
* Refactor JS initializers into Application subclasses
* Maintain partial compatibility API (importing from absolute paths) for extensions
* Remove minification responsibility from PHP asset compiler
* Restructure `less` directory
2018-06-20 13:20:31 +09:30
Toby Zerner
d234badbb2 New issue templates (#1459) 2018-06-20 11:16:48 +09:30
Daniel Klabbers
2cd77e231f Merge branch 'master' into 1236-database-changes 2018-06-19 09:57:47 +02:00
Toby Zerner
07eda60561 Fix discussion posts not being initialized correctly. Fixes #1455 2018-06-16 11:01:42 +09:30
Toby Zerner
2bc7c4134a Add comment explaining extension boot process 2018-06-15 19:25:40 +09:30
Toby Zerner
050496a20e Make ExtensionManager a singleton 2018-06-15 19:25:15 +09:30
Toby Zerner
3b87778fbb Prevent @ character used in searches from crashing MySQL 🙄 2018-06-15 19:24:23 +09:30
Toby Zerner
569e6c9a92 Escape string used in LIKE query 2018-06-15 19:19:43 +09:30
Toby Zerner
c498e68530 Use imported class name 2018-06-15 19:18:47 +09:30
Toby Zerner
305841ddd4 Add Interface suffix 2018-06-15 19:17:43 +09:30
Daniël Klabbers
066baed5b9 migrating user preferences obviously works on empty table 2018-06-12 21:33:17 +02:00
Franz Liedke
211e7681cc Merge pull request #1451 from sijad/create-token
rename TokenController to CreateTokenController
2018-06-06 11:51:50 +02:00
Sajjad Hashemian
22f2df3670 rename TokenController to CreateTokenController 2018-06-06 09:40:29 +04:30
Franz Liedke
3bf74eaf10 Merge pull request #1445 from flarum/fl/migrations-simplify-interface
Migrations: Simplify interface
2018-06-04 01:05:31 +02:00
Franz Liedke
d301d260c1 Simplify interface of migration-related classes
Mostly, we only need a database connection, instead of one of
Laravel's "connection resolvers".

Again, this makes our life easier during installation, where
we already instantiate a database connection. We can now use
that to instantiate our own Migrator class, instead of using
the IoC container to build one.
2018-06-03 23:13:49 +02:00
Franz Liedke
a1c3da9f8f Migrations: always pass a schema builder
This removes the funky auto-injection capability from migration
closures. While technically removing a feature, this means we do
not need a fully-wired IoC container e.g. during installation.

Instead, all migration closures simply receive a schema builder
object (which is what most of them were already doing anyway).
2018-06-03 23:13:35 +02:00
Daniël Klabbers
26b02adc9d Merge branch 'master' into 1236-database-changes 2018-06-03 21:51:01 +02:00
Franz Liedke
3ec32f8430 Composer: Sort dependencies 2018-06-02 15:07:23 +02:00
Daniël Klabbers
f137eb358f Update .travis.yml
remove conditional which is unnecessary
2018-05-30 10:36:00 +02:00
Franz Liedke
b91a3573db Merge pull request #1443 from flarum/fl/controller-to-handlers
Replace ControllerInterface with PSR-15 interface
2018-05-30 09:54:13 +02:00
Franz Liedke
b3d45fd6f8 Replace ControllerInterface with PSR-15 interface
The custom interface already had the same signature as the
one from the standard (except for the return type hint), so
why not use that one now? :)
2018-05-30 09:49:47 +02:00
Franz Liedke
e6b8ff856e Merge pull request #1441 from flarum/fl/psr-15
Use PSR-15 middleware standard
2018-05-29 20:26:31 +02:00
Franz Liedke
4a2aa7e892 Merge branch 'master' into fl/psr-15 2018-05-29 20:21:31 +02:00
Daniël Klabbers
b3cbc5d1bd [wip] 1211 mariadb compatibility (#1440)
fixes #1211 

As we've already upgraded our minimum requirement to 7.1 there's no current need to force a constraint on dbal 2.7+.
2018-05-29 05:51:22 +02:00
Franz Liedke
3680d88fb7 Use PSR-15 middleware standard
This finally adopts the new standardized interfaces instead of the
work-in-progress ones with the `Interop\` prefix.

Since we have now updated to PHP 7.1, we can also use Stratigility
3.0 as the middleware dispatcher.
2018-05-29 00:18:24 +02:00
Franz Liedke
5d0ebde6b8 travis: Remove PHP 7.0 from build matrix 2018-05-28 23:41:32 +02:00
Franz Liedke
0278d52cbe Require PHP 7.1
This will be the last PHP requirement upgrade for a while, at least
until stable (and therefore until the next major release).

We have decided to do this now, for the following reasons:
- We want to support MariaDB (and the compatible release of
  doctrine/dbal requires 7.1 as well).
- We prefer to upgrade to Laravel 5.6 sooner rather than later.
- Using the PSR-15 middleware standard is easier this way, as we do
  not have to switch from zend-stratigility to another PSR-15
  implementation. (Stratigility v3, which implements the final
  standard, requires 7.1.)
2018-05-28 23:21:22 +02:00
Daniël Klabbers
c293fdaec0 undo session interface change 2018-05-21 21:19:38 +02:00
Daniel Klabbers
4654c3eb50 Merge branch '1236-database-changes' of github.com:flarum/core into 1236-database-changes 2018-05-16 09:36:25 +02:00
Daniel Klabbers
68d1edb8fd new api tests uncovered more issues, fixed tokens and discussion posts 2018-05-16 09:36:04 +02:00
Daniel Klabbers
30358e98c0 merged api tests into branch 2018-05-16 09:27:01 +02:00
Daniël Klabbers
e226f81515 additional tests for api controllers (#1433)
* added CreatePostControllerTest

* added DeleteDiscussionControllerTest

* added ListDiscussionControllerTest

* added TokenControllerTest

* minor improvement to policy, no need for Carbon object there, added ShowDiscussionControllerTest

* added showDiscussionControllerTest but cant make Guests view the discussion created by a user

* viewing for guests tested, we might need factories
2018-05-16 09:25:48 +02:00
Toby Zerner
09938f8633 Merge pull request #1432 from clarkwinkelmann/patch-3
Configure external links before dispatching textformatter configuring event
2018-05-15 07:56:24 +09:30
Clark Winkelmann
4c55d278b6 Configure external links before dispatching event
This way extensions can override the link attributes
2018-05-15 00:12:33 +02:00
luceos
808e7a226a Apply fixes from StyleCI
[ci skip] [skip ci]
2018-05-14 11:50:06 +00:00
Daniel Klabbers
3e3e1cbde5 fixed more attributes to match beta 8 2018-05-14 13:49:52 +02:00
Daniel Klabbers
a9501ceae0 Merge branch 'master' into 1236-database-changes 2018-05-14 13:32:48 +02:00
Daniël Klabbers
2a721926d3 adds a few additional api controller tests (#1429)
* added CreatePostControllerTest

* added DeleteDiscussionControllerTest

* added ListDiscussionControllerTest

* Apply fixes from StyleCI

[ci skip] [skip ci]
2018-05-14 13:32:19 +02:00
Daniel Klabbers
81cb67e87c fixed the created_at issue from the policy caused by the setStartPost setting created_at to null 2018-05-14 11:52:01 +02:00
Daniel Klabbers
fd859e33be fixed several column changes found by tests 2018-05-14 11:34:24 +02:00
Daniel Klabbers
7539c25048 Merge branch 'master' into 1236-database-changes 2018-05-14 09:25:52 +02:00
Daniel Klabbers
0058067b1b merged master 2018-05-14 09:23:06 +02:00
Daniël Klabbers
3c41011548 allowing configurable flood gate (#1411)
* allowing configurable flood gate

* fixed review comments
2018-05-11 19:27:37 +09:30
Clark Winkelmann
49c643609c Use ItemList for signup and login modals (#1420)
* Remove unused imports

* Use body and footer methods

* Use ItemList for signup and login inputs
2018-05-11 18:59:58 +09:30
Charlie
4df0101f56 Update icons to "fas" (#1426)
* Update icons to "fas"

* Install icon change
2018-05-09 08:56:30 +02:00
Daniël Klabbers
b8632d693a fixes session during installation (#1418)
* fixes session during installation

* Apply fixes from StyleCI

[ci skip] [skip ci]

* styling of commented code, removed unnecessary import
2018-05-08 10:32:28 +02:00
Daniel Klabbers
684985c25c is email confirmed boolean fixed 2018-04-17 14:27:52 +02:00
Daniel Klabbers
a2927b725f went over most of the changed attributes from the other pr 2018-04-17 14:22:38 +02:00
Daniel Klabbers
efa3b62fb8 joined_at renamed to User 2018-04-17 13:25:11 +02:00
Daniel Klabbers
406be427ad tables renamed, auth_tokens and permissions 2018-04-17 12:21:55 +02:00
Daniel Klabbers
665ac178e9 restarted the branch using the already created migrations 2018-04-17 11:41:55 +02:00
Daniël Klabbers
c4a501f82a Improved foundational backend unit tests (#1405)
* part one of adding tests, updating core

* Apply fixes from StyleCI

[ci skip] [skip ci]

* we need xdebug for code coverage, and hhvm was already removed

* forgot about the sidecar for mysql completely 🤦

* gitignore removed this installed json we need to fake that we have extensions

* using reguarded closure
2018-04-17 11:15:28 +02:00
Daniel Klabbers
beec59232f we can move this file deeper into storage 2018-04-13 09:12:56 +02:00
luceos
371f33e99e Apply fixes from StyleCI
[ci skip] [skip ci]
2018-04-13 07:07:02 +00:00
Daniel Klabbers
264664ac79 added the create discussion test, also renamed some classes that seem to have been incorrectly renamed from the other testing branch 2018-04-13 09:06:42 +02:00
Daniel Klabbers
17f29f83c9 adds api controller tests 2018-04-13 07:52:39 +02:00
Daniel Klabbers
c9c8fa0fde gitignore removed this installed json we need to fake that we have extensions 2018-04-13 07:34:04 +02:00
Daniel Klabbers
45f28b6f72 forgot about the sidecar for mysql completely 🤦 2018-04-13 07:25:30 +02:00
Daniel Klabbers
3ef7843540 Merge branch 'unit-testing' of github.com:flarum/core into unit-testing 2018-04-13 07:17:53 +02:00
Daniel Klabbers
7d41c4e510 we need xdebug for code coverage, and hhvm was already removed 2018-04-13 07:17:39 +02:00
luceos
8574b57fc5 Apply fixes from StyleCI
[ci skip] [skip ci]
2018-04-13 05:13:32 +00:00
Daniel Klabbers
dcb3821777 part one of adding tests, updating core 2018-04-13 07:13:10 +02:00
Daniël Klabbers
043aa0f2d9 fixes log in without remember on master (#1402)
* fixes log in without remember on master

* Fix cookie name by removing prefix from session name rather than in CookieFactory

* Inline temp variable
2018-04-12 06:49:34 +09:30
Toby Zerner
f51e29ff4c Fix absence of variable reference 2018-04-11 10:03:51 +09:30
Franz Liedke
46f80e8d72 Do not load Laravel's SessionServiceProvider 2018-03-31 18:08:35 +02:00
Toby Zerner
29d6b3306f Merge pull request #1392 from datitisev/patch-2
Always return a promise in PostStream#update
2018-03-25 08:35:52 +10:30
David Sevilla Martín
4e2c32b108 remove extra space 2018-03-24 17:43:14 -04:00
David Sevilla Martín
92c8c616e1 Use m.deferred instead of native Promise 2018-03-24 17:43:03 -04:00
Franz Liedke
f42273e679 Merge pull request #1366 from flarum/illuminate-session
Use Illuminate Session component instead of Symfony
2018-03-24 20:42:58 +01:00
Toby Zerner
44376da57d Merge pull request #1378 from DogSports/patch-1
Fix modal title background in media phone
2018-03-24 18:57:36 +10:30
Franz Liedke
2b6ee50c58 Merge pull request #1396 from flarum/writable-path-check-fix
public path should not be writable, but base path should
2018-03-22 08:22:25 +01:00
Franz Liedke
155582831d Merge pull request #1398 from datitisev/patch-1
Fix 'Debug mode' in InfoCommand not showing
2018-03-22 08:15:21 +01:00
David Sevilla Martín
baa11acfa8 Fix "Debug mode" in InfoCommand not showing 2018-03-21 20:00:14 -04:00
David Sevilla Martín
4aad293284 Merge branch 'master' into patch-2 2018-03-21 17:02:43 -04:00
Daniël Klabbers
c60d6e9dee public path should not be writable, but base path should 2018-03-21 20:52:49 +01:00
Franz Liedke
0cf351edb9 List debug mode setting in info output 2018-03-19 23:28:05 +01:00
Franz Liedke
447ca18558 Recompile JavaScript 2018-03-19 23:21:57 +01:00
David Sevilla Martín
a70e6e639c Merge branch 'master' into patch-2 2018-03-19 18:20:11 -04:00
Franz Liedke
fdbf0c86a1 Return empty response
Without this, the new version of Stratigility complained about no
response being returned. Old versions were more graceful here, but
this is certainly more correct.
2018-03-19 23:06:27 +01:00
David Sevilla Martín
6ea60248e3 always return a promise in PostStream#update 2018-03-18 20:37:04 -04:00
Franz Liedke
8d2d987680 Split up Locale extender
Now we have two extenders:
- `Extend\LanguagePack` is the "convention over configuration" loader
  for complete language packs.
- `Extend\Locales` can be used to load files (by locale) from a given
  directory - useful for extensions that bring along their own locales
  in multiple different languages.

Refs #851.
2018-03-19 01:07:59 +01:00
Franz Liedke
bb49e24ffe Bind session handling to request lifecycle
With this change, session objects are no longer instantiated
globally, but instead created within a middleware during the
request lifecycle.

In addition, session garbage collection is integrated with
the already existing middleware for this purpose.
2018-03-18 15:58:31 +01:00
Toby Zerner
5672819549 Use Illuminate Session component instead of Symfony
Symfony's component relies on PHP's native session functionality, which
is not ideal. It automatically sets its own cookie headers, resulting in
this issue: https://github.com/flarum/core/issues/1084#issuecomment-364569953

The Illuminate component is more powerful and has a simpler API for
extension with other drivers and such, and fits in nicely with other
components we use (the majority of which are from Illuminate).
2018-03-18 14:43:44 +01:00
Franz Liedke
b4e093ab8a Ignore Composer's lockfile 2018-03-18 14:33:47 +01:00
Franz Liedke
5645bcbf9c Apply fixes from StyleCI (#1391)
[ci skip] [skip ci]
2018-03-18 13:53:44 +01:00
Franz Liedke
9d30be1617 Update Stratigility, use http-interop middleware 2018-03-18 13:52:16 +01:00
Toby Zerner
d5ef9486d0 Merge pull request #1384 from flarum/fix-hash-binding
fixes the broken hash & hash.driver ioc binding which is part of 5.6
2018-03-09 12:41:28 +10:30
Daniël Klabbers
0c5c322cb4 fixes the broken hash & hash.driver ioc binding which is part of 5.6 2018-03-08 14:25:25 +01:00
Toby Zerner
3f45d18383 Merge pull request #1382 from clarkwinkelmann/patch-2
Remove unused $lifetime variable
2018-03-07 11:42:41 +10:30
Clark Winkelmann
aba22b9119 Remove unused $lifetime variable 2018-03-07 01:30:23 +01:00
Franz Liedke
26dfc8ae21 Apply fixes from StyleCI (#1381)
[ci skip] [skip ci]
2018-03-04 01:18:49 +01:00
Franz Liedke
db7cd71f19 Move logic to Extension class
The gathering and execution of extenders can actually be done here
in the `Extension` class. This way, the `ExtensionManager` only
deals with the question of which extensions are enabled, the
`Extension` class actually extends the core application, and the
service provider simply calls a method, without having to know
about internals.
2018-03-04 01:16:50 +01:00
Toby Zerner
2967b5d106 Give Extenders information about which Extension they belong to 2018-03-04 10:13:12 +10:30
Franz Liedke
e8d915850d Fix test namespace 2018-03-04 00:04:43 +01:00
Franz Liedke
a061eda019 Change namespace of test classes
(as implemented by @luceos in his WIP PR)
2018-03-04 00:01:49 +01:00
Daniel Klabbers
cc22d1d6f8 dropped hhvm and gitter webhook 2018-03-03 23:54:37 +01:00
DogSports
9b1c338b68 Fix modal title background in media phone 2018-03-02 12:32:07 +01:00
Toby Zerner
571938a677 Update core container aliases 2018-02-24 10:37:21 +10:30
AFR
1a2df2d581 FontAwesome v5.0.6 (#1372)
* Update FontAwesome to v5.0.6

* Adapt DiscussionListItem-count icon to match FontAwesome 5 syntax

* Change icon name to match FontAwesome 5.0.6 fas icon

* Add font type prefix parameter to icon helper

* Add Enable Icon Prefix to show icon in Extension Page

* Fix invalid icon behavior

* Change icon name to match FontAwesome 5.0.6 far icon

* Use iconPrefix property on component

* Use full icon class name

* Update icon helper docblock

* Full icon class syntax
2018-02-23 23:42:00 +01:00
Marcel Pokrandt
0f554585ac add message to Dispatch exceptions (#1376)
Exceptions thrown while attempting to dispatch routes are now informing the exact value that was incorrect; url for not found routes and the method when the method was invalid.
2018-02-21 11:28:45 +01:00
Franz Liedke
0b478379fc Apply fixes from StyleCI (#1371)
[ci skip] [skip ci]
2018-02-15 16:57:18 +01:00
Franz Liedke
ba96f311a9 Refactor MIME type guessing to work without any PHP extension
Closes #1241.
2018-02-15 16:40:41 +01:00
Toby Zerner
34588a74e2 Merge pull request #1363 from clarkwinkelmann/extension-rollback
Add extension rollback command
2018-02-13 07:18:00 +10:30
Clark Winkelmann
58ffa27bfb Rename to reset and make extension an option 2018-02-11 20:03:54 +01:00
Franz Liedke
f0cea11e79 API: Provide forum info under /
Closes #875.
2018-02-11 16:40:05 +01:00
Toby Zerner
160493e725 fire -> dispatch
As per Illuminate\Contracts\Events\Dispatcher
2018-02-10 12:09:35 +10:30
Clark Winkelmann
5561e28286 Fix formatting 2018-02-09 18:42:43 +01:00
Clark Winkelmann
c9cfcee12a Fix formatting 2018-02-09 18:41:51 +01:00
Clark Winkelmann
479fafbf5c Add extension rollback command 2018-02-09 18:32:44 +01:00
Toby Zerner
aff1b9a5e4 Merge pull request #1361 from clarkwinkelmann/extendable-notification-methods
Extendable notification methods
2018-02-09 13:51:39 +10:30
Clark Winkelmann
a53d95a3d9 Fix jsdoc for notification types 2018-02-09 02:53:05 +01:00
Clark Winkelmann
ff10ed0ea9 Use an extendable ItemList for notification methods 2018-02-09 02:51:42 +01:00
Johann Rodríguez
7721288ac6 No slug? Then no '-' separator! (#1351)
* Stop using slug separator when there is no slug

* Changing as per upstream requirements
2018-02-09 07:22:50 +10:30
Toby Zerner
c3a6f7daef Remove excerpt margin on mobile 2018-02-08 07:18:29 +10:30
Toby Zerner
a4704b1e2e Fix CSS rule 2018-02-08 07:08:54 +10:30
Toby Zerner
0ab1f2cfe7 Fix regression: set actor before eager loading user state 2018-02-08 07:08:39 +10:30
Toby Zerner
322a84f516 Improve search performance (#1339)
* Improve fulltext gambit

* Only search in visible posts

This change relies on the `visibility-scoping` branch to be merged.

* Change posts table to use InnoDB engine

Doing a JOIN between an InnoDB table (discussions) and a MyISAM table
(posts) is very very (very) bad for performance. FULLTEXT indexes are
fully supported in InnoDB now, and it is a superior engine in every
other way, so there is no longer any reason to be using MyISAM.

* Use ::class

* Only search for comment posts

* Add fulltext index to discussions.title

* Fix migration not working if there is a table prefix

* Update frontend appearance

* Apply fixes from StyleCI

[ci skip] [skip ci]

* Show search result excerpts on mobile
2018-02-08 06:38:08 +10:30
Daniel Klabbers
80ec3b5e17 Improved the console configuring event to support any type of console command to be added 2018-02-07 13:58:31 +01:00
Clark Winkelmann
636e965873 Add console configuration event (#1349)
* Add console configuration event

* Fix comment formatting
2018-02-07 21:49:08 +10:30
Daniel Klabbers
419adb748b validation requires nullable now in order to allow null values to pass the validation 2018-02-02 11:38:06 +01:00
Toby Zerner
25154dabff Merge pull request #1358 from clarkwinkelmann/avatar-permission
Assert permission when updating avatar
2018-02-01 06:54:47 +10:30
Clark Winkelmann
2eae968a70 Assert permission when updating avatar 2018-01-31 16:36:42 +01:00
Toby Zerner
7651907f56 Don't break compatibility with extensions that return a function name
eg. s9e/mediaembed
2018-01-31 07:20:49 +10:30
Toby Zerner
557a65aadd Grant users permission to view empty discussions if they can edit posts
This fixes an issue where unapproved discussions (via
flarum-ext-approval) that were rejected became invisible to the user.

This solution is imperfect and some more substantial thought into how
flarum-ext-approval works is required in the future.
2018-01-30 11:14:25 +10:30
Toby Zerner
ad4bd3d001 Overhaul model visibility scoping (#1342)
* Overhaul the way model visibility scoping works

- Previously post visibility scoping required concrete knowledge of the
  parent discussion, ie. you needed a Discussion model on which you
  would call `postsVisibleTo($actor)`. This meant that to fetch posts
  from different discussions (eg. when listing user posts), it was a
  convoluted process, ultimately causing #1333.

  Now posts behave like any other model in terms of visibility scoping,
  and you simply call `whereVisibleTo($actor)` on a Post query. This
  scope will automatically apply a WHERE EXISTS clause that scopes the
  query to only include posts whose discussions are visible too. Thus,
  fetching posts from multiple discussions can now be done in a single
  query, simplifying things greatly and fixing #1333.

- As such, the ScopePostVisibility event has been removed. Also, the
  rest of the "Scope" events have been consolidated into a single event,
  ScopeModelVisibility. This event is called whenever a user must have
  a certain $ability in order to see a set of discussions. Typically
  this ability is just "view". But in the case of discussions which have
  been marked as `is_private`, it is "viewPrivate". And in the case of
  discussions which have been hidden, it is "hide". etc.

  The relevant API on AbstractPolicy has been refined, now providing
  `find`, `findPrivate`, `findEmpty`, and `findWithPermission` methods.
  This could probably do with further refinement and we can re-address
  it once we get around to implementing more Extenders.

- An additional change is that Discussion::comments() (the relation
  used to calculate the cached number of replies) now yields "comments
  that are not private", where before it meant "comments that are
  visible to Guests". This was flawed because eg. comments in non-public
  tags are technically not visible to Guests.

  Consequently, the Approval extension must adopt usage of `is_private`,
  so that posts which are not approved are not included in the replies
  count. Fundamentally, `is_private` now indicates that a discussion/
  post should be hidden by default and should only be visible if it
  meets certain criteria. This is in comparison to non-is_private
  entities, which are visible by default and may be hidden if they don't
  meet certain criteria.

Note that these changes have not been extensively tested, but I have
been over the logic multiple times and it seems to check out.

* Add event to determine whether a discussion `is_private`

See https://github.com/flarum/core/pull/1153#issuecomment-292693624

* Don't include hidden posts in the comments count

* Apply fixes from StyleCI (#1350)
2018-01-27 09:57:16 +10:30
Franz Liedke
4b1a299b3c Convert closures in arrays to Compat extenders as well
Refs #851.
2018-01-21 22:38:06 +01:00
Franz Liedke
fa14be591c Use cursor() fetching when deleting many posts
Refs #1319.
2018-01-21 21:53:48 +01:00
Franz Liedke
072f4f89cb Assets extender: Remove defaultAssets() method
See a7821a24a2 (r26990974).
2018-01-21 21:14:08 +01:00
Toby Zerner
ed3e833181 Fix docblocks 2018-01-21 08:28:15 +10:30
Toby Zerner
7f92838225 Fix Laravel 5.5 query scoping 2018-01-21 08:28:08 +10:30
Toby Zerner
2159107214 Merge pull request #1330 from clarkwinkelmann/signup-fields-locking
Prevent editing fields in sign up modal according to identification data
2018-01-12 08:38:49 +10:30
Clark Winkelmann
d357364712 Rename method and attribute, and remove unnecessary attribute filtering 2018-01-11 23:05:26 +01:00
Clark Winkelmann
26449a64fe Merge remote-tracking branch 'upstream/master' into signup-fields-locking 2018-01-11 22:54:41 +01:00
Toby Zerner
ae2e07e94c Remove use of event priorities
Event priorities are no longer in Laravel - see dbbfc62bef

Updated the AbstractPolicy terminology to reflect the new behaviour,
which is that there is no guarantee that the catch-all methods will run
after all specific methods have run globally. This behaviour is only
guaranteed within the policy.
2018-01-11 14:10:37 +10:30
Toby Zerner
801d619a36 Fix docblock return type 2018-01-11 12:11:48 +10:30
Toby Zerner
0befe041c7 Use whereRaw instead of Expression 2018-01-11 11:56:18 +10:30
Toby Zerner
1c87c33d4d Use ::class, update some typehints 2018-01-11 11:55:57 +10:30
Franz Liedke
3480a65989 Avoid calculations in views
Instead, look up existence of navigation links in the underlying
API document.
2018-01-10 20:39:53 +01:00
Franz Liedke
2979e8bc28 Use Blade's inject helper 2018-01-10 20:36:50 +01:00
Franz Liedke
8c470954eb Add pagination link for previous page 2018-01-10 20:35:07 +01:00
Franz Liedke
6913e8f0f8 Only display pagination link if necessary
Otherwise, search engines start indexing pages that aren't filled yet.

Refs #189.
2018-01-10 20:34:25 +01:00
Franz Liedke
30a04e7bf9 Don't use invokables with Container::call() 2018-01-10 19:37:18 +01:00
Franz Liedke
0af97c427c Re-introduce Compat extender
Turns out Container::call() does not work with invokable classes.
Thus, we need to wrap callables in a custom extender class to
support injecting any resolvable type-hint automatically.

Refs #851.
2018-01-10 19:32:57 +01:00
Toby Zerner
1c1cefa017 Update test namespaces 2018-01-11 01:25:10 +10:30
Franz Liedke
c6747b6910 Get rid of Compat extender
Now that we support any form of callable to be returned from the
bootstrap.php files, it is no longer needed.
2018-01-09 22:35:40 +01:00
Franz Liedke
1ce70eeb6e Turn extenders into callables
This simplifies the API and gives extension developers more
flexibility, for a) maintaining backwards compatibility, and
b) doing advanced stuff that extenders do not allow.

Note that only extenders are guaranteed to work across
different versions of Flarum (once the API surface is stable).

See the discussion in https://github.com/flarum/core/pull/1335.
2018-01-09 20:49:51 +01:00
Daniel Klabbers
714775cfed fixed two typehints on migrations repository 2018-01-09 16:28:50 +01:00
Toby Zerner
bdc1a100cd Merge pull request #1340 from clarkwinkelmann/fix-password-changed-on-reset
Dispatch user events after password reset
2018-01-09 13:35:24 +10:30
Clark Winkelmann
f3e29ab801 Dispatch user events after password reset
Previously PasswordChanged was never sent
2018-01-09 03:44:06 +01:00
Franz Liedke
26e53fc51b Tweak route registration extender: Use plural
This makes it more consistent with other existing extenders,
while also making registration of multiple routes more
comfortable for extension developers, and likely slightly
more performant. :-)
2018-01-07 19:50:49 +01:00
Franz Liedke
848293a7d5 Merge pull request #1338 from gwillem/fix-permissions
Remove execute permissions from php/less files
2018-01-07 18:30:40 +01:00
Willem de Groot
5af65dede1 Fix StyleCI spacing 2018-01-06 12:03:02 +01:00
Willem de Groot
e774baf32f Remove execute permissions from php/less files 2018-01-06 11:59:25 +01:00
Toby Zerner
2ac04aac8e Merge branch '0.1.0-beta.7' 2018-01-06 20:06:43 +10:30
Clark Winkelmann
c6aeeeb3c1 Always apply attributes from token when registering
The change introduced in #1033 transformed any identification attribute returned from an OAuth provider to just a default value.

When the identification attribute used by the provider is the email or username, this allowed the user to supply a different email or username and still getting an already-enabled account with the credentials he entered.

Skipping attributes with an existing value makes no sense here because it's a always a fresh user and values from AbstractOAuth2Controller::getIdentification() should always be enforced.
2018-01-06 20:04:42 +10:30
Toby Zerner
f247d8c2a6 Merge pull request #1335 from flarum/next-back-extenders
Start of PHP extenders API
2018-01-06 09:17:27 +10:30
Franz Liedke
0380536cb4 Add another newline before custom footer HTML 2018-01-05 23:46:38 +01:00
AFR
6dc96b38af Add Custom Footer HTML (#1315)
* Add Custom Footer HTML

Straight copy from Custom Header HTML

* Move Custom Footer HTML to exactly before `</body>` tag.

* Fix invalid class name

* Append CustomFooterHTML when preparing the view.

* Some consistency in placing the variable
2018-01-05 23:44:11 +01:00
Clark Winkelmann
9342723f64 Manage Composer height with overridable methods (#1272)
* Manage Composer height in a separate class with overridable methods

* Use a computed method

* Keep everything in Composer.js

* Drop usage of computed property for the Composer height
Because the Composer height also depends on the page height and is rarely called without position, height or page height changing anyway
2018-01-04 09:39:06 +10:30
Franz Liedke
8d049126d0 Add Route extender for registering routes with forum, admin or API 2018-01-03 23:19:45 +01:00
Franz Liedke
63be95fb8a Admin: Set up all event listeners in one place
See discussion in #1273.
2018-01-03 20:23:05 +01:00
Franz Liedke
1d47047d45 Add FormatterConfiguration extender for extensions working with TextFormatter 2018-01-03 09:42:11 +01:00
Franz Liedke
4e30ad5891 Add Assets extender for frontend extensions 2018-01-03 09:42:11 +01:00
Franz Liedke
f4ad227576 Add Locale extender for language pack extensions 2018-01-03 09:42:11 +01:00
Franz Liedke
5b6d043f80 Resolve extenders from ExtensionManager
Loading the activated extensions now means retrieving an array of
extenders (classes that implement a certain type of extension of a core
feature in Flarum).

For now, the only existing extender is the Compat extender which is used
to handle old-style bootstrappers that simply return a closure that
receives all of its dependencies via auto injection.

In the future, extensions will be able to return an array of extender
instances from their bootstrapper instead. These extender classes will
be implemented in the next step.
2018-01-03 09:42:11 +01:00
Franz Liedke
c41e58531a Deprecate remaining non-namespaced events
These will be replaced by etenders soon.
2018-01-03 09:42:11 +01:00
Franz Liedke
b760d113d2 Installation default data: Use more sensible defaults
Using .dev as a TLD for local development is discouraged, as at
least Chrome now enforces HTTPS for these domains.

As far as I know, by default, the MySQL root user does not have
a password on many platforms. I use it this way on my local
machine, and this makes it convenient to setup a local copy.
2018-01-03 09:41:46 +01:00
Franz Liedke
936f67e953 Use ::class instead of some hardcoded class names
This gives us better refactoring functionality in IDEs like
PhpStorm, and also more quickly surfaces typos through errors
about undefined classes. :)
2018-01-03 09:41:46 +01:00
Franz Liedke
3f7e7520b0 Clean up code, use PHP 7 feature :) 2018-01-03 09:41:46 +01:00
Clark Winkelmann
7ccb263926 Fix array_only usage 2018-01-02 00:27:13 +01:00
Toby Zerner
fe56f57e8f Fix order of array_first arguments
As per https://laravel.com/docs/5.3/upgrade (under "Arrays")
2018-01-02 09:48:50 +10:30
Clark Winkelmann
fa9d89d690 Prevent editing fields in sign up modal according to identification data 2018-01-02 00:13:33 +01:00
Toby Zerner
292fe06001 Re-add missing middleware 2018-01-01 10:45:26 +10:30
Toby Zerner
f2ce4e11e2 Fix class name 2018-01-01 10:34:19 +10:30
Miguel Piedrafita
47eb853bf9 Update year (#1328) 2017-12-31 20:48:23 +01:00
Toby Zerner
d807171c44 Fix URL generator usage 2017-12-29 21:29:04 +10:30
Toby Zerner
57a91c966d Fix view paths 2017-12-29 21:28:53 +10:30
Toby Zerner
0525f467c7 Fix class reference 2017-12-29 18:42:31 +10:30
Franz Liedke
b791790d2f Fix comment 2017-12-28 22:47:13 +01:00
Toby Zerner
ea353a2f2c Merge pull request #1308 from flarum/next-back
Next back > master
2017-12-28 12:13:40 +10:30
Toby Zerner
ac7d28ca58 Remove unused method 2017-12-27 16:17:35 +10:30
Toby Zerner
8a6344cfcf Fix some class names, clean up imports 2017-12-27 16:17:25 +10:30
Toby Zerner
a0621e85bf Fix order of array_first arguments
As per https://laravel.com/docs/5.3/upgrade (under "Arrays")
2017-12-26 20:38:15 +10:30
Franz Liedke
56231d61be Move garbage collection into middleware
This prevents garbage collection to randomly break the installer:
before installation, the models that are being accessed have no
database connection.

Now, the middleware is only mounted into the forum's middleware
stack. I want API requests to have stable performance, and the
forum middleware stack is only mounted when Flarum is installed.
2017-12-21 12:23:34 +01:00
Franz Liedke
c8a1a5fcfa Fix more incompatibilities with Laravel 5.5 2017-12-20 00:20:23 +01:00
Franz Liedke
8d5132fd5a Disable HandleErrors middleware during installation
Temporary measure until we have a real fix in place.
2017-12-20 00:00:23 +01:00
Franz Liedke
6efe2ee91a Fix previous commit
Prevent `flarum.config` from being bound in the container when the
software has not been installed yet.
2017-12-19 23:48:38 +01:00
Franz Liedke
bfd98e3371 DRY up loading of config 2017-12-19 23:16:06 +01:00
Toby Zerner
e9da1ba2f5 Remove Listener namespace
We may reverse this in the future, but for now just going for
consistency between domains (the majority do not use a Listener
namespace)
2017-12-19 18:59:14 +10:30
Toby Zerner
b2fe76c819 Merge pull request #1313 from flarum/analysis-qB0gYV
Apply fixes from StyleCI
2017-12-19 18:54:47 +10:30
Toby Zerner
2b8c66354d Apply fixes from StyleCI
[ci skip] [skip ci]
2017-12-19 08:24:06 +00:00
Toby Zerner
4cf481355f Fix usage of UrlGenerator in notifications 2017-12-19 18:52:27 +10:30
Toby Zerner
2ec183778c Pick up config when setting a new base path 2017-12-19 18:38:00 +10:30
Daniel Klabbers
1b94ef90ea the admin service provider also has to use the new HandleError logic 2017-12-15 09:35:02 +01:00
Daniel Klabbers
183a22b5c5 - FilesystemInterface no longer needed in User related handlers
- FilesystemInterface conditional ioc binding moved to AvatarUploader
- User::getAvatarAtribute failed to use the UrlGenerator properly
2017-12-15 09:29:20 +01:00
Daniel Klabbers
654fca9c2c fixed the BasicFoo vs FooBasic serializer definition issue, prevented for future using ::class 2017-12-15 08:29:07 +01:00
Daniel Klabbers
7be01119f5 and another.. 2017-12-15 08:15:08 +01:00
Daniel Klabbers
28d4cff156 satisfying sci isnt enough for it, lets please it further 2017-12-15 08:14:15 +01:00
Daniel Klabbers
2aba61668c - satisfying styleci
- cleared the merge conflict in the phpdoc
- changed some string class names to use ::class
2017-12-15 08:10:32 +01:00
Franz Liedke
fccadcc6ab Apply suggestions from StyleCI 2017-12-14 22:18:12 +01:00
Daniël Klabbers
f65e4dcba3 merges 5.5 and master into next-back 2017-12-14 01:00:16 +01:00
Franz Liedke
c6ce172caa Apply suggestions from StyleCI 2017-12-13 23:08:35 +01:00
Clark Winkelmann
d2f187716e Prevent saving invalid custom less (#1273)
* Prevent saving invalid custom less

* Fix formatting

* Fix formatting again

* Move custom less format check to its own listener

* Move listener to AdminServiceProvider

* Rename listener method
2017-12-13 22:39:09 +01:00
Daniël Klabbers
93aa3d77b5 re-using symfony translator 2017-12-13 21:45:55 +01:00
Toby Zerner
a0c95e6705 Filter out notifications with non-existent subjects
ref #1025 #1238. This should prevent the frontend from crashing when
opening the notifications menu, but we still need to make sure
notifications are deleted properly when subjects are deleted.
2017-12-13 15:54:16 +10:30
Toby Zerner
77c25ab725 Add infinite scrolling in the notifications list 2017-12-13 15:28:54 +10:30
Toby Zerner
3dcfe32b27 Extract admin dashboard statistics from core into an extension 2017-12-10 21:03:48 +10:30
Toby Zerner
617a76dda8 Fix PHP 7.2 warning 2017-12-10 21:02:47 +10:30
Toby Zerner
1a239ee93a Fix crash when post's user has been deleted 2017-12-10 21:02:35 +10:30
Toby Zerner
f8d065bd78 Merge pull request #1298 from sijad/remove-autolink
remove autolink
2017-12-03 08:15:31 +10:30
Sajjad Hashemian
0a654d1f31 remove autolink #1214 2017-11-30 13:38:45 +03:30
Toby Zerner
b806dc3db2 Move view logic into middleware 2017-11-29 22:25:57 +10:30
Toby Zerner
92de751154 Fix last commit 2017-11-29 22:22:14 +10:30
Toby Zerner
5b46ec801d Generate URL in the controller instead of the view 2017-11-29 22:20:06 +10:30
Toby Zerner
1ef9217f4d Basic implementation of dashboard widgets, statistics
Currently not user-customizable. Just needed to display statistics for a
client, so figured I'd make a start at this. Nothing too fancy for now,
but I'm sure some people will be happy to have this information at their
fingertips.
2017-11-29 17:19:20 +10:30
Toby Zerner
79fee3686f More precise permission check for email gambit 2017-11-29 17:02:49 +10:30
Toby Zerner
8edc8223e5 Fix admin error handling 2017-11-29 16:10:22 +10:30
Daniël Klabbers
6280fb2498 reverting translator contract 2017-11-29 06:26:48 +01:00
Toby Zerner
ba769e0c7e Preserve return URL when confirming logout 2017-11-29 13:47:00 +10:30
Toby Zerner
ea2fc1ff8a Add a "return home" link to 404 errors 2017-11-29 13:23:25 +10:30
Toby Zerner
b7c1cc5cef New design for error pages. closes #252 2017-11-29 13:03:55 +10:30
Toby Zerner
e8a4e5e0ef Add log out confirmation if CSRF token is invalid. fixes #1282 2017-11-29 13:03:16 +10:30
Toby Zerner
295193eb3c Use HtmlResponse in AbstractHtmlController 2017-11-29 12:54:11 +10:30
Toby Zerner
a065c8e6f5 Make URLs more verbose 2017-11-29 12:53:39 +10:30
Toby Zerner
9392e1bec3 New design for reset password view 2017-11-29 12:53:06 +10:30
Toby Zerner
479e44dd04 Restructure views
- Use Laravel's view namespacing rather than the full file path
- Organise views into directories
2017-11-29 12:51:24 +10:30
Daniel Klabbers
c01268d9ae must be an empty line 2017-11-27 14:19:18 +01:00
Daniel Klabbers
f4fc245df4 re-added a precious line 2017-11-27 14:18:28 +01:00
Daniel Klabbers
ac0b4cb2d2 patched up the Scope implementation as requested 2017-11-27 14:17:17 +01:00
Daniel Klabbers
55b945f129 Using Core Translator in Locale Manager, type hinted its methods and removed unnecessary phpdoc 2017-11-27 14:03:45 +01:00
Daniel Klabbers
4d9e2335c7 pleasing the angry god Circle 2017-11-27 11:05:15 +01:00
Daniel Klabbers
642332ffe2 replaced the Symfony\Component\Translation\TranslationInterface with the Illuminate\Contracts\Translation\Translator, deprecating the Symfony version 2017-11-27 10:42:16 +01:00
Daniel Klabbers
7b2663e0bc fixed alias/reference loading for translation strings 2017-11-27 10:35:57 +01:00
Daniel Klabbers
e2d61d1aeb applied laravel contract 2017-11-27 09:49:19 +01:00
Toby Zerner
7796580210 Actually list users returned from the API when searching 2017-11-20 10:37:21 +10:30
Toby Zerner
0aa74c987c Fix email gambit 2017-11-20 09:17:44 +10:30
Toby Zerner
55a09a2f57 Merge pull request #1261 from josephnle/drag-and-drop-avatar-upload
Add drag and drop avatar uploading
2017-11-13 01:33:29 +02:00
Toby Zerner
a28dbccf1a Performance: Assign parent discussions to posts so they don't have to be reloaded 2017-11-12 21:14:19 +10:30
Toby Zerner
3c80612d80 Performance: Load only basic information about post discussion/users 2017-11-11 23:15:36 +10:30
Toby Zerner
dedcbae359 Performance: Load only basic information about terminal/relevant posts 2017-11-11 22:57:41 +10:30
Toby Zerner
9cc67fe312 Performance: Cache translation catalogue to avoid reparsing YAML 2017-11-11 22:45:38 +10:30
Toby Zerner
5f7060fb4a Performance: Assign parent discussion to posts so it doesn't have to be reloaded 2017-11-11 22:44:45 +10:30
Toby Zerner
1a102766a9 Fix Composer textarea losing its height across route changes
There is a Mithril bug which causes context.retain to be ineffective for
children nodes. https://github.com/MithrilJS/mithril.js/issues/1300

Thus, we have to assume that the children nodes (like the textarea)
may be recreated and thus we need to update its height on each redraw.

fixes #948
2017-11-07 21:12:03 +10:30
Toby Zerner
abda11c6c5 Oops, recompile JS properly 2017-11-05 17:57:56 +10:30
Toby Zerner
b43fdec2e9 Recompile JS 2017-11-05 17:38:30 +10:30
Toby Zerner
3321b4e829 Give the mobile composer a bit more height 2017-11-05 17:35:13 +10:30
Toby Zerner
a8826dcd88 Remove FastClick. Fixes #1268
Turns out FastClick was causing textareas to be buggy on iOS Safari,
and it wasn't really doing any good.
2017-11-05 17:32:43 +10:30
Toby Zerner
15b573bd93 Update asset revision whenever custom LESS is changed
This should remove the need for a hard browser refresh whenever you
update the custom LESS.
2017-11-05 16:27:28 +10:30
Toby Zerner
41df32f66e Add a tooltip to the Preview button 2017-11-05 16:25:34 +10:30
Toby Zerner
094345de85 Improve mobile composer behaviour
- Don't scroll to the bottom of the discussion when selecting "Reply"
  from the menu if the composer is in full screen mode (ie. on mobile).
  ref #1271

- After posting a reply, scroll to the end of the discussion

- Reduce the textarea height - previously it was 100vh, but this doesn't
  account for the height of the iOS keyboard, so I've just arbitrarily
  chosen 300px instead. There may be a better solution for this.
  ref #1269
2017-11-05 16:25:21 +10:30
Toby Zerner
54597ee5eb Attempt fix for #1268
I believe the constant overlay of a loading div may be what's causing
the iOS cursor issues. This commit removes the fade animation so that
we can simply set display to none, which will hopefully fix the issue.
2017-11-05 16:21:18 +10:30
Toby Zerner
3be98b9f8e Make sure dropdowns don't go above the edge of the screen 2017-11-05 16:17:50 +10:30
Toby Zerner
257ee936f4 Revert color to text input type
#1074 changed the input type for these fields to "color", but it turns
out the browser support for this input type sucks (they give you a very
limited color picker, and make it hard to input hex codes).
2017-11-05 16:17:15 +10:30
Toby Zerner
1a928ca0ab Fix admin navigation not rendering
Not sure why this started happening now, but the admin navigation
dropdown wasn't receiving its children properly. This commit fixes a
flaw in our Mithril patch and allows an array of children to be passed
in the normal JSX way, rather than as an attribute.
2017-11-05 16:12:26 +10:30
Daniel Klabbers
0b1043c9d2 moved from boot to register 2017-11-02 10:52:52 +01:00
Daniel Klabbers
72c232d5a3 fixed the Bus command Handling forwarding the call to a matching Handler class 2017-11-02 10:48:33 +01:00
Franz Liedke
914b94b62d Remove user bio feature (#1214)
The feature is very limited in scope, and we hope for community
extensions to take over this feature and make it much better.
2017-11-02 01:12:49 +01:00
Lukas
1b7cb3bec2 The CookieFactory now also works if no configuration exists (#1258)
* Returning the $default value if there's no config

This is especially important for the CookieFactory which accesses
the configuration before the application is installed

* Injecting the configuration values into the CookieFactory
2017-11-02 00:51:31 +01:00
Daniël Klabbers
55b763a570 fixed renamed interface for Scope 2017-11-01 22:12:56 +01:00
Daniel Klabbers
d7306dedb7 array_build => array_map 2017-11-01 17:20:12 +01:00
Daniel Klabbers
3eede757bb fixed symfony translator now using catalogues 2017-11-01 17:07:22 +01:00
Daniel Klabbers
a8f8ca7f87 fixed an issue where the mail provider would not be able to instantiate 2017-11-01 17:01:50 +01:00
Daniel Klabbers
44e9007790 using blade @json directive to parse raw json into frontend` 2017-11-01 13:22:16 +01:00
Mark
eeed7c20e1 Fix blurry chrome image rendering for Avatar / Logo - closes #1259 (#1276)
* Fix blurry chrome image rendering for Avatar / Logo - closes #1259

* Add comments for Chrome css fix
2017-10-29 17:24:02 +01:00
Toby Zerner
40ebc13292 Only apply custom CSS and header HTML on forum, not admin 2017-10-25 13:40:57 +10:30
Toby Zerner
2754a8c867 Add LESS variable to configure expansion of sideNav dropdowns 2017-10-25 12:36:09 +10:30
Joseph
123c8bb73d Add drag and drop avatar uploading 2017-10-22 14:21:39 -07:00
Toby Zerner
f3b4d35587 Fix extractText breaking in some cases 2017-10-08 08:59:54 +10:30
Toby Zerner
42ecee42a1 Make sure components receive all children properly 2017-10-08 08:59:18 +10:30
Toby Zerner
5a43f915cb Let avatarUrl attribute delete the avatar as well 2017-10-07 20:28:15 +10:30
Toby Zerner
6a10b4484f Recompile JS 2017-10-07 20:12:15 +10:30
Toby Zerner
06aa37d2fd Use display names in avatars 2017-10-07 20:10:50 +10:30
Franz Liedke
cb92deee98 Fix namespace imports 2017-10-07 11:20:38 +02:00
Toby Zerner
bedf710768 Fix variable 2017-10-07 19:17:59 +10:30
Toby Zerner
3b1f8771c4 No need to set a remember cookie if only logging in for session 2017-10-07 17:51:30 +10:30
Toby Zerner
2dbcfe02d8 Consolidate avatar uploading, allow avatarUrl to be used when updating user 2017-10-07 17:39:27 +10:30
Daniel Klabbers
a7f3ca4b22 added new methods etc 2017-10-05 16:25:01 +02:00
Daniel Klabbers
3f9dc81874 satisfying styleci, undo mysql in travis 2017-10-05 14:02:54 +02:00
Daniel Klabbers
1c01145a14 fixed those exception handling tests 2017-10-05 13:57:31 +02:00
Daniel Klabbers
2037371886 lists > pluck 2017-10-05 13:39:41 +02:00
Toby Zerner
87bf84ef6e Allow configuring cookie attributes
I decided to put this in config.php because if cookie settings were to
be stored in the database and configured via admin UI, entering
incorrect settings could cause the admin session to be destroyed,
requiring manual database intervention to fix. But it's a good prompt
for discussion as to which kind of settings belong in config.php vs the
database. Thoughts?
2017-10-05 13:00:15 +10:30
Toby Zerner
096e552c74 Add the ApiKey model as a request attribute 2017-10-05 12:26:05 +10:30
Toby Zerner
8ccfb1aac6 Use a constant instead of a property 2017-10-05 12:25:30 +10:30
Toby Zerner
ea4d889b76 Fix post contentHtml sometimes breaking script parsing
<\/script> tags in post content would sometimes be recognized as
actually ending the script tag, even when escaped (not exactly sure
why). This is fixed by encoding the < > characters in unicode.
2017-10-05 11:48:10 +10:30
Toby Zerner
19d15d4302 Use display name as document title 2017-10-05 11:43:12 +10:30
Toby Zerner
43d8a9d0e8 Merge pull request #1251 from tweichart/path_methods
minor change for getting the path
2017-10-04 17:23:20 +10:30
Tobias Weichart
02377663ce minor change for getting the path
* should be used via x_path() methods + parameter
2017-10-04 08:38:36 +02:00
Franz Liedke
4f688fc9a2 Change order of service provider registration
Here, the order is relevant, because at this
point, the application has already been booted.
Hence, all boot() methods are called immediately,
which might depend on other service providers'
register() methods having run.

In this case, the DiscussionServiceProvider
depends on the Gate class being registered in the
container by the UserServiceProvider.
2017-10-03 18:54:07 +02:00
Franz Liedke
fddd134fa0 Inject settings repository in event listener
`$this->app` was not defined here anyway.

Refs #1032.
2017-10-03 18:54:07 +02:00
Franz Liedke
1215a1ef9b Use ::class constant instead of hardcoded strings 2017-10-03 18:54:07 +02:00
Franz Liedke
4aad7c1040 Cleanup code, typehints and class references 2017-10-03 18:54:07 +02:00
Franz Liedke
e46b3d54d1 Extract Flarum\Foundation\Site class
This class holds all information relevant to a local Flarum site,
such as paths and local configuration. From this information, it
is able to instantiate a Flarum\Foundation\Application instance,
which represents a Flarum installation's runtime.

This will also be useful for setting up e.g. multi-tenant
environments.
2017-10-03 18:54:07 +02:00
Franz Liedke
051bb5acb8 Fix code style 2017-10-03 18:54:07 +02:00
Franz Liedke
69b517ea79 Get rid of Server classes for Admin, API and Forum
The various middleware can be registered in the service provider,
and the rest of the logic can all go through one single front
controller (index.php in flarum/flarum, and Flarum\Http\Server in
flarum/core).

This will also simplify the necessary server setup, as only one
rewrite rule remains.
2017-10-03 18:54:07 +02:00
Franz Liedke
b4c7f8ca89 Move event to Flarum\User namespace 2017-10-03 18:54:07 +02:00
Franz Liedke
3ece3ca976 Move events to Flarum\Api namespace 2017-10-03 18:54:07 +02:00
Franz Liedke
9c77475985 Fix order of namespace imports 2017-10-03 18:54:06 +02:00
Franz Liedke
b72407440d Combine URL generator classes into one 2017-10-03 18:54:06 +02:00
Franz Liedke
f824dcfb53 Move more event classes to appropriate namespaces 2017-10-03 18:54:06 +02:00
Franz Liedke
78f3681fc1 Fix namespace orderings
(Thanks, StyleCI!)
2017-10-03 18:54:06 +02:00
Franz Liedke
5b0d0d9f0f Move command classes to domain namespaces
They will probably be refactored away at a later stage (when we get
rid of the command bus). Until then, this lets us remove the
Flarum\Core namespace and actually feels quite clean.
2017-10-03 18:52:50 +02:00
Franz Liedke
95dc7e71f4 Fix namespaces 2017-10-03 18:52:50 +02:00
Franz Liedke
a39ed6edec Rename listener class to DiscussionRenamedLogger 2017-10-03 18:52:50 +02:00
Franz Liedke
66f35d2530 Split up old CoreServiceProvider 2017-10-03 18:52:50 +02:00
Franz Liedke
e6e4531771 Fix class names in strings 2017-10-03 18:49:53 +02:00
Franz Liedke
e71deed8d5 Move ExtensionValidator class to Flarum\Extension namespace 2017-10-03 18:49:53 +02:00
Franz Liedke
8a16c1ecc8 Move UserState class to Flarum\Discussion namespace 2017-10-03 18:49:53 +02:00
Franz Liedke
b38ade986d Extract Flarum\Notification namespace 2017-10-03 18:49:53 +02:00
Franz Liedke
4a13cd8088 Move another trait out of obsolete Flarum\Core namespace 2017-10-03 18:49:53 +02:00
Franz Liedke
920a4071b6 Fix some incorrect automated refactorings 2017-10-03 18:49:53 +02:00
Franz Liedke
c22219ec20 Extract Flarum\Group namespace 2017-10-03 18:49:53 +02:00
Franz Liedke
11bf3e34b7 Extract Flarum\Search namespace 2017-10-03 18:49:53 +02:00
Franz Liedke
4fb38d6458 Extract new Flarum\Discussion namespace 2017-10-03 18:49:52 +02:00
Franz Liedke
66abd7ecfd Extract new Flarum\Post namespace 2017-10-03 18:47:23 +02:00
Franz Liedke
3481798875 Fix trait imports 2017-10-03 18:47:23 +02:00
Franz Liedke
9abc63aaac Move events to Flarum\Extension\Event namespace 2017-10-03 18:47:23 +02:00
Franz Liedke
6cd6a7d260 Move events to Flarum\Formatter\Event namespace 2017-10-03 18:47:23 +02:00
Franz Liedke
6c9ff72efb Finalize Flarum\Foundation namespace 2017-10-03 18:47:23 +02:00
Franz Liedke
33e3d757c3 Flatten Flarum\Http namespace 2017-10-03 18:47:23 +02:00
Franz Liedke
551e76f296 Move events to Flarum\Settings\Event namespace 2017-10-03 18:47:23 +02:00
Franz Liedke
564ea8ff73 Extract new Flarum\User namespace 2017-10-03 18:47:23 +02:00
Franz Liedke
fda8c597f4 Flarum\Frontend: Rename ConfigureWebApp event to Rendering 2017-10-03 18:45:41 +02:00
Franz Liedke
5d1564e0fc Flarum\Frontend: Fix view paths after renaming namespace 2017-10-03 18:45:41 +02:00
Franz Liedke
1f1b63363e Rename controller file 2017-10-03 18:45:41 +02:00
Franz Liedke
bdf455c0c6 Move ScopeVisibilityTrait to Database namespace 2017-10-03 18:45:41 +02:00
Franz Liedke
927e4ca3ed Restructure Flarum\Forum namespace 2017-10-03 18:45:40 +02:00
Franz Liedke
0be13d50bd Create new Flarum\Frontend namespace
It replaces the old Http\WebApp namespace and swallows other namespaces
and files, such as Flarum\Asset.
2017-10-03 18:45:40 +02:00
Franz Liedke
6268c3010f Fix serializer class names 2017-10-03 18:45:40 +02:00
Franz Liedke
acf43606a8 Register new MigrationServiceProvider 2017-10-03 18:45:40 +02:00
Franz Liedke
5ae2e9d232 Get rid of Flarum\Debug namespace 2017-10-03 18:45:40 +02:00
Franz Liedke
d897839097 Restructure Flarum\Database namespace 2017-10-03 18:45:40 +02:00
Franz Liedke
c6985ae31c Restructure Flarum\Console namespace 2017-10-03 18:45:40 +02:00
Franz Liedke
9b24fbd5e5 Restructure Flarum\Api namespace 2017-10-03 18:45:40 +02:00
Franz Liedke
5127514d35 Restructure Flarum\Admin namespace 2017-10-03 18:45:38 +02:00
Toby Zerner
eb72307a54 User display names (#1246)
* Introduce user display names

It is not uncommon for forums to be intergrated with sites where users
don't have a unique "handle" - they might just have their first name,
or a full name, which is not guaranteed to be unique.

This commit introduces the concept of "display names" for users. By
default display names are the same as usernames, but extensions may
override this and set them to something different. The important thing
is that all code should use `display_name` whenever intending to output
a human-readable name - `username` is reserved for cases where you want
to output a unique identifier (which may or may not be human-friendly).

The new "GetDisplayName" API is probably sub-optimal, but I didn't worry
too much because we can come up with something better in `next-back`.

ref #557

* Apply fixes from StyleCI

[ci skip] [skip ci]
2017-09-20 16:42:18 +09:30
Toby Zerner
f917d1438c Use ::class 2017-09-19 19:45:31 +09:30
Toby Zerner
ef89b1f6b1 Remove unnecessary else statement 2017-09-19 19:44:43 +09:30
Toby Zerner
377d439c47 😅 2017-09-19 19:13:02 +09:30
Toby Zerner
37cf95f94d Don't include post content in the "basic" serializer
Currently all of a post's replies are loaded in full whenever the post
is loaded, which is kind of overkill - we really just need to know that
they exist (and who posted them) in order to render the "X replied to
this" line.
2017-09-19 19:10:07 +09:30
Toby Zerner
c31c1ea062 Allow full URLs to be used as the avatar path
This is useful for forums integrating with an external website (eg. a
WordPress site), so they can reference existing avatars directly.

For alternative storage locations (eg. S3) the best practice will still
be to store a relative path and then configure an external base "assets
URL" (this is not currently possible - TODO).

Given this change, I think it would probably make sense to rename the
column to `avatar_url` in the upcoming batch of database naming changes
- then it can contain either a relative or an absolute URL -
@franzliedke do you agree?
2017-09-19 19:03:12 +09:30
Toby Zerner
084f74946d Allow setting the raw content of a CommentPost 2017-09-19 12:13:24 +09:30
Franz Liedke
1e8399c014 Update zend-diactoros to v1.6
This release contains a useful fix for Content-Length problems
that we have experienced before.

See https://github.com/zendframework/zend-diactoros/releases/tag/1.6.0.
2017-09-15 13:27:11 +02:00
Franz Liedke
ad153c8484 Issue template: Explanation first 2017-09-12 20:41:17 +02:00
epoxa
cbe4464178 Fix oauth controller wrong session method call (#1226) 2017-08-19 14:43:21 +09:30
zinsserzh
7df9594a04 Add isEmpty function to ItemList (#1218)
* Add isEmpty function to ItemList

* Fix coding style to be consistent.

* Recompiled app.js for both js/admin/ and js/forum/
2017-08-10 11:37:00 +09:30
Franz Liedke
c037658675 Don't hardcode admin URL
Fixes #1219.
2017-08-04 23:37:59 +02:00
Toby Zerner
287085dc25 Fix scrubber icon alignment 2017-07-30 09:17:50 +09:30
Franz Liedke
a2e0daed70 Remove faulty default value
Fixes #1210.
2017-07-27 00:55:33 +02:00
Toby Zerner
57f828b3f7 Fix user online icon spacing 2017-07-22 16:10:08 +09:30
Toby Zerner
7ec92813e3 Make dropdown menu icons a nicer fixed width 2017-07-22 16:09:51 +09:30
Toby Zerner
ce8a5b3e0f v0.1.0-beta.7 2017-07-22 12:48:58 +09:30
Toby Zerner
5faf0fcde5 And remove unused import 2017-07-22 12:31:23 +09:30
Toby Zerner
65c0b436c0 Fix missed instance of back button tooltip 2017-07-22 12:30:55 +09:30
Toby Zerner
8d76168bd4 Oops, forgot to correct test code 2017-07-22 12:29:03 +09:30
Toby Zerner
d16f4dbefa Recompile JS 2017-07-22 12:08:17 +09:30
Toby Zerner
e3e4786391 Simplify global back button
The behaviour is not overly intuitive, and the icon wasn't helping
(hamburger icon usually means "menu"). Now the back button always goes
back to the index, no matter where you are, and there's a tooltip that
says "Back to discussion list".
2017-07-22 12:08:09 +09:30
Toby Zerner
c1c7d4c73a Only display "show language selector" toggle if there is more than one language 2017-07-22 11:47:50 +09:30
Toby Zerner
8da8c9ac7d Clean up appearance of Rename Discussion modal
Also fix infinite loading if there's a validation error.
2017-07-22 11:47:04 +09:30
Toby Zerner
fb68aa88db Use default dropdown appearance for sort dropdown 2017-07-22 11:46:16 +09:30
Toby Zerner
afc597c189 Remove fa-fw class from all icons
Often it is desirable to NOT have this class applied, and it is easier
to apply its styles if needed rather than un-apply it.
2017-07-22 11:45:42 +09:30
Toby Zerner
4f3e67714e Fix incorrect migration notes for extensions without any migrations
When running migrations for an extension without any migrations (eg.
BBCode), the migration notes for the previous extension were being
displayed, because the Migrator never had a chance to clear them.
2017-07-22 11:43:50 +09:30
Toby Zerner
54be3ad3c8 Define the default moderator group ID
This allows extensions to add default permissions for moderators,
without having to hardcode in the default moderator group ID.
2017-07-22 11:41:20 +09:30
Toby Zerner
0b00d56416 Add a new migration helper for adding default permissions 2017-07-22 11:40:06 +09:30
Toby Zerner
89d4a1e849 Remove MySQL port field from visual installer
Port can still be specified by suffixing the host with a :

closes #825
2017-07-22 11:32:07 +09:30
Daniël Klabbers
43ee7b59a4 Update Client.php (#1198)
* Update Client.php

Now forwarding exceptions from client to page in case debug mode is on. Fixes #1120.

* Update Client.php

Satisfying .. the unsatisfiable.

* Update Client.php

Satisfying again.
2017-07-19 22:14:00 +02:00
David Sevilla Martín
d052f6b639 Use dropdown for discussion list order input (#1191)
* Use dropdown menu for index select input

* Fix space before `:`
2017-07-17 13:40:35 +09:30
Toby Zerner
4b47adabcf Oops, that should be in seconds not minutes 2017-07-08 22:35:11 +09:30
Toby Zerner
93140b8fa4 Remember users forever (5 years) rather than 2 weeks 2017-07-08 22:29:26 +09:30
Toby Zerner
ade2166310 Revise Remember Me checkbox appearance
Use a generic checkbox instead of a switch — it's more familiar and accessible.

Signed-off-by: Toby Zerner <toby.zerner@gmail.com>
2017-07-08 22:25:24 +09:30
Toby Zerner
a9969119d2 Merge branch 'master' of https://github.com/flarum/core 2017-07-08 21:52:01 +09:30
Toby Zerner
94a8eaec64 Update dependencies 2017-07-08 21:50:54 +09:30
Franz Liedke
8ea13dc826 Flatten implementation of SelfDemotionGuard listener
Refs #736 and #1195.
2017-07-06 21:57:47 +02:00
David Sevilla Martín
99d42372c3 Prevent yourself from locking yourself out of admin group (#1195) 2017-07-06 21:43:01 +02:00
Franz Liedke
01b56eecdb Merge pull request #1201 from Luceos/patch-3
Update AbstractSerializer.php
2017-06-23 00:02:16 +02:00
Franz Liedke
bcdcb8c20e Merge pull request #1202 from Luceos/patch-4
Update WebAppView.php
2017-06-23 00:02:02 +02:00
Daniël Klabbers
d6c99eccdb Update WebAppView.php
Added argument type hinting where absent.
2017-06-22 16:27:10 +02:00
Daniël Klabbers
01cb8ab79d Update AbstractSerializer.php
Fixes missing argument in method. Verified it has to be a string.
2017-06-22 14:28:51 +02:00
Franz Liedke
877aed215b Merge pull request #1199 from Luceos/patch-2
Update StartSession.php
2017-06-20 08:17:39 +02:00
Daniël Klabbers
57570d960e Update StartSession.php
Fixed CookieFactory typo in phpdoc.
2017-06-19 16:47:20 +02:00
Daniël Klabbers
04c4806f6f making posts and discussions private (#1153)
* flagrow/byobu#11 making posts and discussions private

* tested migrations and tested setting is_private on discussion and post manually

* added phpdoc for Post and Discussion and added the casting for these attributes

* satisfying styleci

* fixes for review

* added new private discussion event and included it in the access policy

* added new private post event and included it in the access policy
2017-05-27 14:19:15 +09:30
Davis
4c0339c30e Allow JSON to be used for Install Command (#1193)
* Allow JSON to be used for Install Command

* Return configuration as array instead of object.

* Update InstallCommand.php
2017-05-27 14:18:09 +09:30
David Sevilla Martín
e64dc4ea45 Add viewUserList permission (#1190) 2017-05-24 22:06:56 +09:30
Franz Liedke
305076814f Merge pull request #1189 from datitisev/762-exclude-files-from-distribution
Update .gitattributes to exclude files for distribution
2017-05-20 13:42:34 +02:00
David Sevilla Martin
e31edd29d2 Exclude files for distribution using .gitignore 2017-05-18 18:46:55 -04:00
David Sevilla Martín
23b423c6ce #1184 Fix /api/posts returning 500 (#1188)
* Fix ListPostsController::applyFilters not receiving array if argument not present

* Whoops! Use `[]` instead of `array()`

* Update AbstractSerializeController.php

* Update ListPostsController.php
2017-05-18 22:04:00 +02:00
Franz Liedke
1af1f472f9 Recompile dist JavaScript 2017-05-18 09:14:06 +02:00
Franz Liedke
7c86f7a34c Merge pull request #1186 from flarum/Luceos-patch-1
Update UserControls.js
2017-05-18 09:13:28 +02:00
Daniël Klabbers
14e49269d6 Update UserControls.js
Possibly c/p mistake with argument name. UserControls using argument discussion in controls method.
2017-05-17 14:07:38 +02:00
Zeokat
7837fff107 Support PNG avatars with transparent backgrounds and fix EXIF rotation (#1168)
As `orientate` requires the EXIF extension, we can only call it if the extension is installed.

Fixes #1161 and #1163.
2017-05-10 21:23:08 +02:00
Franz Liedke
3dfa6bc8cb Merge pull request #1179 from flarum/Luceos-patch-1
Update mixin.js
2017-05-09 23:07:16 +02:00
Daniël Klabbers
e47fe288fa Update mixin.js
Typo fixed
2017-05-09 13:58:07 +02:00
Franz Liedke
03e30d7d4f Merge pull request #1178 from flarum/Luceos-patch-1
Update HandleErrors.php
2017-05-09 08:57:26 +02:00
Daniël Klabbers
9836ff6c54 Update HandleErrors.php
@franzliedke forgot to make variables available to the method, just triggered this but got a warning that all three variables are undefined.
2017-05-08 16:45:58 +02:00
issyrocks12
bb1c655c90 Change to switch to fit style 2017-05-04 22:36:37 +02:00
Franz Liedke
bf20fe595a Fix incorrect sort field name
Closes #1175.
2017-05-04 21:37:03 +02:00
Franz Liedke
b5db57156b Merge pull request #1172 from tpokorra/fixDefaultLanguageSelection
Admin: fix default language selector
2017-05-02 08:37:32 +02:00
Timotheus Pokorra
a7d3bdf244 Admin: fix default language selector
the binding of the control to the value was missing
fixes #1164
2017-05-01 18:46:12 +02:00
Franz Liedke
c82f0bde61 Merge pull request #1155 from ssfinney/feature/mediumtext_for_post_content_column
Change content column from TEXT to MEDIUMTEXT
2017-04-13 08:04:05 +02:00
Stephen Finney
986102c1d3 Change content column from TEXT to MEDIUMTEXT
Fixes #1044
2017-04-09 16:12:34 -04:00
Franz Liedke
2140619c0b Prevent reverting editable user bio on click
Turns out the click handler was bound to the surrounding element
rather than the one that wraps the rendered bio when it is not
being edited.

Fixes #1145.
2017-03-17 22:14:51 +01:00
Franz Liedke
2f714a01ed Cookies: Set expires flag for remember cookies
Without this, session remembering would not work in Internet
Explorer (and Edge?).

Fixes #1127.
2017-03-14 22:25:20 +01:00
Franz Liedke
231d018de5 Add link() and setCanonicalUrl() methods to the WebAppView
These make it easier for controllers to define relationships from
the current to other pages, which is important for SEO mostly.
2017-03-13 18:08:32 +01:00
Franz Liedke
5d62231004 Fix comment typo 2017-03-13 12:52:25 +01:00
Franz Liedke
123c3a93f5 Fix indentation 2017-03-12 23:05:04 +01:00
Franz Liedke
c1eec2b261 Fix indentation 2017-03-12 23:03:46 +01:00
David Sevilla Martín
60d3d6ef99 Add option to hide the language selector (#1106)
* Added option to hide the language selector in the header
* Added `hide_language_selector` Switch to BasicsPage
* Added `hideLanguageSelector` property to ForumSerializer
* Apparently fixed the "Add Extension" button locale.... someone must not have compiled their changes :P

* Changed hideLanguageSelector (and such) to showLanguageSelector

* Change `core.admin.basics.show_language_selector_heading` to be `_label`

* Change showLanguageSelector in ForumSerializer to be boolean, default: true

* Ooops! Remove console.log 🤦‍♂️
2017-03-07 10:04:44 +10:30
Toby Zerner
7862bd32dd Merge pull request #1141 from sijad/fix-logout-redirect
prevent unsafe redirect via logout controller
2017-03-04 22:10:18 +10:30
Sajjad Hashemian
92b555a246 prevent unsafe redirect via logout controller 2017-03-04 14:51:21 +03:30
Toby Zerner
687ec6a199 Merge pull request #1131 from flarum/866/affixSidebar-resize
Affix sidebar when window is resized
2017-03-03 15:24:13 +10:30
Franz Liedke
f788a0a972 Fix nesting of rename_discussion translations
Refs flarum/flarum-ext-english#98.
2017-02-28 22:42:41 +01:00
Franz Liedke
e7bec9fe29 Merge pull request #1135 from sijad/add-noindex-header
Prevent crawlers to index nojs pages
2017-02-27 18:13:38 +01:00
Franz Liedke
57da4e24cb Rename translation key 2017-02-26 23:47:20 +01:00
Franz Liedke
7d1a22bcb5 Rename modal component 2017-02-26 23:44:57 +01:00
Sajjad Hashemian
8cc117d89d Prevent crawlers to index nojs pages 2017-02-26 19:48:33 +03:30
Franz Liedke
31ef02dc2c Compile dist JS 2017-02-17 00:19:33 +01:00
Franz Liedke
95c9ff9243 Affix sidebar when window is resized
Fixes #866.
2017-02-17 00:08:20 +01:00
Franz Liedke
9718f54683 Merge pull request #1130 from clarkwinkelmann/patch-1
Fix asset path when unpublishing
2017-02-16 09:17:32 +01:00
Clark Winkelmann
bb1e3278de Fix asset path when unpublishing 2017-02-16 01:51:33 +01:00
Franz Liedke
bbcc33b5b5 Turn a few setters/getters into public attributes
There were no type hints etc. going on, and we would have needed
the getters anyway.

See https://github.com/flarum/core/pull/1105#issuecomment-279310998.
2017-02-14 22:56:17 +01:00
Franz Liedke
30076547e5 Merge pull request #1126 from janga1997/hideCompiledDiff
Hide diff for compiled diff files
2017-02-12 17:46:12 +01:00
janga
7b710d5898 Hide diff for compiled diff files 2017-02-12 10:26:10 +05:30
Franz Liedke
d02b5c9db7 Merge pull request #1124 from Luceos/master
fixed issues with $extension visibility and typehinting
2017-02-12 00:53:50 +01:00
Daniël Klabbers
cd70819fd5 fixed issues with $extension visibility and typehinting 2017-02-11 21:14:44 +01:00
Franz Liedke
20b4619e75 Fix Stratigility deprecation, for real this time 2017-02-07 20:52:06 +01:00
Franz Liedke
fdec2fd094 Recompile dist JS 2017-02-04 00:08:16 +01:00
Franz Liedke
d7e4ae09b3 Merge pull request #1113 from oanhnn/patch-1
Correct image orientation according to Exif data
2017-02-03 23:50:04 +01:00
David Sevilla Martín
fcfc1b2a37 Add more attributes in app.blade.php and add a setDescription method. (#1105)
* Added `language` and `direction` properties to WebAppView

* Use properties `language` and `direction` in app.blade.php

* Added WebAppView::setDescription to set the meta description

* Whoops! Changed "ltr" to \'ltr\'. Thanks StyleCI :)

* Removed unnecessary `= null` for

* Changed `.. ? .. : ..` to `.. ?: ..`. Useful thing right there ;)
2017-02-03 23:09:22 +01:00
Franz Liedke
01eba18164 Merge pull request #1100 from flarum/stratigility-update
Update to Zend Stratigility 1.3
2017-02-03 22:03:55 +01:00
Franz Liedke
0dcf7d6aa9 Travis: Run tests on PHP 7.1 as well 2017-02-03 21:53:39 +01:00
Franz Liedke
015967a76c Require PHP 5.6 2017-02-03 21:53:20 +01:00
renyuneyun
3cd59e12f5 Allow to manually activate users (#1093)
* Allow to manually activate users

* Use resources instead of hard-coded strings
2017-02-03 21:13:32 +01:00
David Sevilla Martín
26d07699e9 Turn "Rename Discussion" dialog into a modal, closes #616 (#1083)
* Changed "Rename Discussion" prompt into a modal.
* Added DiscussionRenameModal component (Modal)
* Changed DiscussionControls.renameAction to use the modal (I may have removed the ability to return a promise)

* Added punycode.js back to js/forum dist

* Fixed some formatting, removed some unnecessary variables
2017-02-03 20:56:28 +01:00
Franz Liedke
b7d6ba4893 Trim lines 2017-02-03 20:28:04 +01:00
Franz Liedke
d3753d94ae Throw HTTP 403 on extension validation error
The way I read it, HTTP 405 is a generic statement about the
resource. Once a language pack is not the default, this is not
true anymore, so I figured 403 is more correct.
2017-02-03 20:25:21 +01:00
Franz Liedke
9349ed13fc Make event attributes public
Without this, reading the extension information would not be
possible for the validator.
2017-02-03 20:23:24 +01:00
Franz Liedke
91ace15f6d Merge pull request #1032 from dav-is/patch-1
Prevent deletion of default/all locale(s)
2017-02-03 20:21:19 +01:00
Franz Liedke
7c1b0bfcf2 Clarify condition
I want to make it a little more clear that we are checking exactly
for these two values. That may also help preventing further confusion
as to why we are not using empty() here.

Amendment to PR #1033.
2017-02-03 18:53:21 +01:00
Franz Liedke
542bae6277 Merge pull request #1033 from dav-is/patch-2
Prevent Overwriting of User's Attributes on Register (#897)
2017-02-03 18:51:11 +01:00
Franz Liedke
275c14ee7f Merge pull request #1009 2017-02-03 18:44:03 +01:00
Franz Liedke
bccc970231 Try to extract port from host when installing in console
The very last suggestion broght up in pull request #989.
2017-02-03 18:15:52 +01:00
Franz Liedke
da6f79b34a Ask for database port when installing via console 2017-02-03 18:15:15 +01:00
Franz Liedke
a3cbec25db Make MySQL port field optional
Last fix for pull request #989.
2017-02-03 17:56:02 +01:00
Franz Liedke
2225fdec72 Merge pull request #989 from nielstholenaar/master
Fixes #825
2017-02-03 17:51:07 +01:00
Oanh Nguyen
6a532ec14e Correct image orientation according to Exif data
When using mobile, take a photo and upload it as avatar, it's orientation is incorrect.
This commit will fix this problem.
2017-01-25 11:49:14 +07:00
Franz Liedke
9416d16ebb Clean up gambit 2017-01-03 21:22:19 +01:00
Li Ji
d6857b0fe5 Add group gambit to support search user by group name (#1073)
Add group gambit to support search user by group name

/api/users?filter[q]=group:admin
/api/users?filter[q]=group:admin,mod

refer to #256
2017-01-03 21:13:58 +01:00
Franz Liedke
2c7e7f5b39 Merge pull request #1094 from milescellar/patch-1
Make Add Extension modal's title translatable
2017-01-03 21:02:38 +01:00
Franz Liedke
b5b18dd436 Update to Zend Stratigility 1.3
* Fix dependency version constraint. (Reverts #1066.)
* Allow exceptions to be raised when dispatching middleware.
* Fix our error handler middleware (do not implement Stratigility's
  error handler interface, catch exceptions instead).

See https://docs.zendframework.com/zend-stratigility/migration/to-v2/.

Closes #1069.
2017-01-02 22:57:09 +01:00
Daniël Klabbers
4778ae5f74 Merge pull request #1099 from milescellar/patch-3
Update year
2017-01-02 08:22:43 +01:00
Miles Cellar
0936a630ef Update year 2017-01-01 22:41:35 +01:00
Franz Liedke
ec8ae6e03b Remove unnecessary method call
This is already the default value in the base SetCookie class.
2016-12-29 11:17:27 +01:00
Franz Liedke
9ffdeff608 Make StyleCI happy 2016-12-29 11:07:23 +01:00
Franz Liedke
8540932638 Clean up and document code 2016-12-28 23:01:49 +01:00
Franz Liedke
974f45e4e8 Remove unnecessary parameters 2016-12-28 23:01:27 +01:00
Miles Cellar
32ac48c6a9 Make Add Extension modal's title translatable 2016-12-27 01:52:54 +01:00
Toby Zerner
af5b86806a Merge pull request #1092 from sijad/cookie-helper
Add cookie helper
2016-12-22 20:30:46 +10:30
Sajjad Hashemian
aeef45b3cd Add cookie factory 2016-12-22 12:00:56 +03:30
Toby Zerner
8aa70de765 Merge pull request #1085 from krnch/krnch-patch-2
Cookies set with Secure flag in HTTPS mode #1084
2016-12-11 18:16:04 +10:30
karan
076a71c621 Update StartSession.php 2016-12-10 02:46:07 -05:00
Sajjad Hashemian
06c32b668d Remember checkbox (#1075)
* Add session option to Rememberer class

* Update session login function to allow send additional data

* Add Remember me checkbox

* Cleanup login modal
2016-11-29 18:02:12 +10:30
Toby Zerner
7af4b8d45f Merge pull request #1049 from JoshyPHP/TextFormatter-0.8.0
Updated s9e\TextFormatter to 0.8.1
2016-11-29 16:36:10 +10:30
Toby Zerner
cbba325a87 Add punycode. ref #1049 2016-11-29 16:35:45 +10:30
Toby Zerner
b7d7e8b18a Merge pull request #1077 from flarum/analysis-Xan0ZZ
Apply fixes from StyleCI
2016-11-29 15:46:14 +10:30
Toby Zerner
1031826a3d Apply fixes from StyleCI
[ci skip] [skip ci]
2016-11-29 05:03:53 +00:00
Toby Zerner
3612ca7aca Allow accessing the session via the actor
This is a bit sloppy (might come up with a better solution yet), but since most events provide access to the actor but not the request, this was the easiest/quickest way to allow extensions to access the session.
2016-11-28 11:45:55 +10:30
Toby Zerner
c2ee84a115 Don't rely on a successful forum API call to enable debug mode 2016-11-28 11:45:55 +10:30
Toby Zerner
060745ecb7 Support module prefixing of locale resources
In preparation for upcoming changes, allow locale resources to have a module prefix added when they are loaded from a file.
2016-11-28 11:45:55 +10:30
Toby Zerner
dd209b1747 Eager load discussion relationships
Since extensions may add nested includes, we need to make sure they are eager-loaded to avoid excessive queries. For example, when the tags extension adds "tags" and "tags.state".
2016-11-28 11:45:55 +10:30
Toby Zerner
aeb0a411b9 Add specific message for username validation 2016-11-28 11:45:55 +10:30
Toby Zerner
1ebb8bf39a Merge pull request #1074 from datitisev/specify-text-inputs-type
Added search input types to 3 inputs total, closes #726
2016-11-28 11:13:39 +10:30
David Sevilla Martin
fcdf36b3d0 Added search input types to 3 inputs total, closes #726
* Added type search to search bar (forum)
* Added CSS `box-sizing: inherit` to search <input> because bootstrap styles mess up the search box
* Added type color to both color settings in appearance (admin)
2016-11-27 19:39:47 -05:00
Toby Zerner
ab912ba1ad Update StyleCI rules 2016-11-16 15:47:12 +10:30
Toby Zerner
4b8eb5d6e4 Make reset password form look slightly nicer
(Still needs a proper makeover!)
2016-11-13 09:01:38 +10:30
Toby Zerner
0e20949eb0 Prevent notice if bootstrapping app in command line environment 2016-11-13 08:57:39 +10:30
Toby Zerner
b2c691a03d Improve password reset validation/error handling 2016-11-13 08:51:38 +10:30
Toby Zerner
dde0de046a Merge pull request #1066 from Luceos/patch-1
Update composer.json
2016-11-12 12:44:07 +10:30
Daniël Klabbers
7a9795fbc3 Update composer.json
fixes #1065 , this is a temporary fix until compatibility with 1.3.0 is guaranteed by refactoring
2016-11-12 01:20:10 +01:00
Toby Zerner
f30fac6a94 Merge pull request #1063 from sijad/default-export
Fix syntax errors when compiling js files
2016-11-08 08:03:26 +10:30
Sajjad Hashemian
1fb8092987 Fix syntax errors when compiling js files 2016-11-08 00:32:44 +03:30
Toby Zerner
ea6b943dbd Make getApp available to the public 2016-11-07 21:23:31 +10:30
Toby Zerner
b9918e6c40 Add missing parameter 2016-11-07 18:22:20 +10:30
Toby Zerner
b3e1a023c2 Add event to allow custom user password validation 2016-11-07 18:03:49 +10:30
JoshyPHP
96926a180a Updated s9e\TextFormatter to 0.8.1 2016-10-10 01:58:40 +02:00
Davis
f3bdc163fa $extension was undefined 2016-10-05 12:46:14 -05:00
Davis
0df6eee10f Change exception message 2016-10-04 15:09:43 -05:00
Davis
258a4b352d Change == to === 2016-09-13 14:48:21 -05:00
Davis
24580ced7a Wish it was automatic :/ 2016-09-13 05:56:13 -05:00
Davis
8e90d9f9e2 Anything for Stylecl's green check 2016-09-13 05:55:00 -05:00
Davis
af36ef3fa9 StyleCl and the space after <?php is annoying 2016-09-13 05:53:46 -05:00
Davis
eef63745e6 Prevent overwriting of user's attributes on register 2016-09-13 02:22:09 -05:00
Davis
c702e911b3 StyleCl is making me hate myself 2016-09-12 22:31:55 -05:00
Davis
73d2ee825b Forgot to subscribe 2016-09-12 22:31:03 -05:00
Davis
9f99610542 StyleCl FINALLY! 2016-09-12 22:28:50 -05:00
Davis
1192867c4f StyleCl 2016-09-12 22:28:03 -05:00
Davis
b048498b84 StyleCl 2016-09-12 22:27:18 -05:00
Davis
81f7a39a31 StyleCl 2016-09-12 22:26:22 -05:00
Davis
ea12bbaf48 StyleCL 2016-09-12 22:24:57 -05:00
Davis
c8122a7879 Make StyleCL Happy 2016-09-12 22:23:31 -05:00
Davis
1a5d7a337d Remove useless code 2016-09-12 22:19:47 -05:00
Davis
c29ea98d48 Add WillBe Modifiers 2016-09-12 22:17:54 -05:00
Davis
3702ffa998 Create ExtensionValidator.php 2016-09-12 19:14:30 -05:00
Davis
58f9c22375 Create ExtensionWillBeEnabled.php 2016-09-12 17:07:00 -05:00
Davis
939a1e9ca8 Forgot the extension :/ 2016-09-12 17:05:41 -05:00
Davis
736f22a31a Create ExtensionWillBeDisabled 2016-09-12 16:57:24 -05:00
David Sevilla Martin
592dd6a927 Fixed error when user is not logged in; fixed notification count not updating when clicking home link (added m.redraw) 2016-08-30 10:35:31 -04:00
David Sevilla Martin
2c5aa138cd Bringing back those "use strict";. Sorry 'bout that 2016-07-28 10:47:09 -04:00
David Sevilla Martin
53fd7b66b4 Commiting dist/app.js 2016-07-26 11:34:47 -04:00
David Sevilla Martin
a1a22aa4ce Refresh notifications with discussion list refresh
* When clicking "refresh" button for discussion list (on homepage) refresh notifications
* When clicking forum title (on homepage) refresh notifications
2016-07-26 11:25:05 -04:00
Niels Tholenaar
05c9ce335e Fixes #825 2016-06-20 12:34:41 +02:00
1100 changed files with 90072 additions and 82548 deletions

View File

@@ -15,5 +15,5 @@ indent_size = 2
[*.{diff,md}]
trim_trailing_whitespace = false
[*.php]
[*.{php,xml,ts,tsx}]
indent_size = 4

9
.gitattributes vendored
View File

@@ -1,4 +1,13 @@
.gitattributes export-ignore
.gitignore export-ignore
.gitmodules export-ignore
.github export-ignore
.travis export-ignore
.travis.yml export-ignore
.editorconfig export-ignore
.styleci.yml export-ignore
phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff

View File

@@ -1,3 +0,0 @@
# Contributing to Flarum
Howdy! We're really excited that you are interested in contributing to Flarum. Before submitting your contribution, please take a moment and read through the [Contributing Guidelines](https://github.com/flarum/flarum/blob/master/CONTRIBUTING.md).

3
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,3 @@
github: flarum
open_collective: flarum
tidelift: packagist/flarum/core

View File

@@ -1,26 +0,0 @@
> Issues on Github are meant for bug reporting. Please post feature requests on the [discussion forum](https://discuss.flarum.org/t/features).
---
> Try to complete the below form as far as you are able and are willing to share. Add a screenshot of the issue if you can.
## Bug report
- Version of Flarum: x.y.z
- Website URL where the bug is visible: http://example.com
- The webserver you are running: apache, nginx or something else
- PHP version: x.y.z
- Hosted environment: shared or vps
- Hosting provider: http://some-amazing-provider.com
## Flarum info
```
Output of "php flarum info", run this in terminal in your Flarum directory.
```
## Additional comments
Some additional information you'd like to share, eg what have you tried so far.
## Log files
```
Put any relevant logs here.
```

39
.github/ISSUE_TEMPLATE/bug-report.md vendored Normal file
View File

@@ -0,0 +1,39 @@
---
name: "🐛 Bug Report"
about: "If something isn't working as expected"
---
## Bug Report
**Current Behavior**
A clear and concise description of the behavior.
**Steps to Reproduce**
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected Behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environment**
- Flarum version: x.y.z
- Website URL: http://example.com
- Webserver: [e.g. apache, nginx]
- Hosting environment: [e.g. shared, vps]
- PHP version: x.y.z
- Browser: [e.g. chrome 67, safari 11]
```
Output of "php flarum info", run this in terminal in your Flarum directory.
```
**Possible Solution**
<!--- Only if you have suggestions or a fix for the bug -->
**Additional Context**
Add any other context about the problem here.

View File

@@ -0,0 +1,26 @@
---
name: "🚀 Feature Request"
about: "I have a suggestion (and may want to implement it!)"
---
<!--
IMPORTANT: Feature requests on this GitHub issue tracker are only accepted in case they have been approved by a core developer or contain extensive argumentation and directions for implementation. For all other feature requests, ideas and feedback please post in the Flarum Community: https://discuss.flarum.org/t/feedback.
-->
## Feature Request
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. eg. I have an issue when [...]
**Describe the solution you'd like**
A detailed description of your proposed solution. Include:
- How the feature would work/behave
- Any potential drawbacks
- Maybe a screenshot, design, or example code
**Justify why this feature belongs in Flarum's core, rather than in a third-party extension**
Consider who this change will be useful to  most Flarum forums, or just a few?
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

View File

@@ -0,0 +1,11 @@
---
name: "🙋‍ Support Question"
about: "If you have a question, please check out our forum or Discord!"
---
We primarily use GitHub as an issue tracker; for usage and support questions, please check out these resources below. Thanks!
* Flarum Community: https://discuss.flarum.org/
* Discord Chat: https://flarum.org/discord/
* Twitter: https://twitter.com/Flarum

24
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,24 @@
<!--
IMPORTANT: We applaud pull requests, they excite us every single time. As we have an obligation to maintain a healthy code standard and quality, we take sufficient time for reviews. Please do create a separate pull request per change/issue/feature; we will ask you to split bundled pull requests.
-->
**Fixes #0000**
**Changes proposed in this pull request:**
<!-- fill this out, mention the pages and/or components which have been impacted -->
**Reviewers should focus on:**
<!-- fill this out, ask for feedback on specific changes you are unsure about -->
**Screenshot**
<!-- include an image of the most relevant user-facing change, if any -->
**Confirmed**
- [ ] Frontend changes: tested on a local Flarum installation.
- [ ] Backend changes: tests are green (run `composer test`).
**Required changes:**
- [ ] Related documentation PR: (Remove if irrelevant)
- [ ] Related core extension PRs: (Remove if irrelevant)

13
.github/SECURITY.md vendored Normal file
View File

@@ -0,0 +1,13 @@
# Security Policy
## Supported Versions
During the beta phase, we will only patch security vulnerabilities in the latest beta release.
## Reporting a Vulnerability
If you discover a security vulnerability within Flarum, please send an email to security@flarum.org so we can address it promptly.
We will get back to you as time allows.
Discussions may commence internally, so you may not hear back immediately.
When reporting a vulnerability, please provide your GitHub username (if available), so that we can invite you to collaborate on a [security advisory on GitHub](https://help.github.com/en/articles/about-maintainer-security-advisories).

26
.github/stale.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
daysUntilStale: 90
daysUntilClose: 30
staleLabel: stale
exemptLabels:
- org/keep
- type/bug
- type/regression
- critical
- security
exemptAssignees: true
exemptMilestones: true
exemptProjects: true
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. We do this
to keep the amount of open issues to a manageable minimum.
In any case, thanks for taking an interest in this software and contributing
by opening the issue in the first place!
closeComment: >
We are closing this issue as it seems to have grown stale. If you still
encounter this problem with the latest version, feel free to re-open it.

16
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: JavaScript
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: flarum/action-build@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

31
.github/workflows/lint.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: Lint code
on:
push:
paths:
- 'js/src/**'
pull_request:
paths:
- 'js/src/**'
jobs:
prettier:
runs-on: ubuntu-latest
name: Lint JS code with Prettier
steps:
- uses: actions/checkout@master
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: "12"
- name: Install JS dependencies
run: npm ci
working-directory: ./js
- name: Check JS code for formatting
run: node_modules/.bin/prettier --check src
working-directory: ./js

67
.github/workflows/test.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
name: Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.2, 7.3, 7.4]
service: ['mysql:5.7', mariadb]
prefix: ['', flarum_]
include:
- service: 'mysql:5.7'
db: MySQL
- service: mariadb
db: MariaDB
- prefix: flarum_
prefixStr: (prefix)
exclude:
- php: 7.2
service: 'mysql:5.7'
prefix: flarum_
- php: 7.2
service: mariadb
prefix: flarum_
- php: 7.3
service: 'mysql:5.7'
prefix: flarum_
- php: 7.3
service: mariadb
prefix: flarum_
services:
mysql:
image: ${{ matrix.service }}
ports:
- 13306:3306
name: 'PHP ${{ matrix.php }} / ${{ matrix.db }} ${{ matrix.prefixStr }}'
steps:
- uses: actions/checkout@master
- name: Select PHP version
run: sudo update-alternatives --set php $(which php${{ matrix.php }})
- name: Create MySQL Database
run: |
sudo systemctl start mysql
mysql -uroot -proot -e 'CREATE DATABASE flarum_test;' --port 13306
- name: Install Composer dependencies
run: composer install
- name: Setup Composer tests
run: composer test:setup
env:
DB_PORT: 13306
DB_PASSWORD: root
DB_PREFIX: ${{ matrix.prefix }}
- name: Run Composer tests
run: composer test

4
.gitignore vendored
View File

@@ -1,7 +1,9 @@
/vendor
composer.lock
composer.phar
node_modules
.DS_Store
Thumbs.db
tests/_output/*
/tests/integration/tmp
.vagrant
.idea/*

View File

@@ -5,6 +5,7 @@ enabled:
disabled:
- align_double_arrow
- blank_line_after_opening_tag
- multiline_array_trailing_comma
- new_with_braces
- phpdoc_align

View File

@@ -1,35 +0,0 @@
language: php
php:
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
allow_failures:
- php: hhvm
fast_finish: true
before_script:
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi;
- composer self-update
- composer install
script:
- vendor/bin/phpunit --coverage-clover=coverage.xml
notifications:
email:
on_failure: change
webhooks:
urls:
- https://webhooks.gitter.im/e/7b9e9827a03b44a16588
on_success: always
on_failure: always
on_start: false
after_success:
- bash <(curl -s https://codecov.io/bash)
sudo: false

143
CHANGELOG.md Normal file
View File

@@ -0,0 +1,143 @@
# Changelog
## [0.1.0-beta.12](https://github.com/flarum/core/compare/v0.1.0-beta.11.1...v0.1.0-beta.12)
### Added
- Full support for PHP 7.4 (#1980)
- Mail settings: Configure region for the Mailgun driver (#1834, #1850)
- Mail settings: Alert admins about incomplete settings (#1763, #1921)
- New permission that allows users to post without throttling (#1255, #1938)
- Basic transliteration of discussion "slugs" / pretty URLs (#194, #1975)
- User profiles: Render basic content on server side (#1901)
- New extender for configuring middleware (#1919, #1952, #1957, #1971)
- New extender for configuring error handling (#1781, #1970)
- Automated tests for PHP extenders to guarantee their backwards compatibility
### Changed
- Profile URLs for non-existing users properly return HTTP 404 (#1846, #1901)
- Confirmation email subject no longer contains the forum title (#1613)
- Improved error handling during Flarum's early boot phase (#1607)
- Updated deprecated "Zend" libraries to their new "Laminas" equivalents (#1963)
### Fixed
- Update page did not work when installed in subdirectories (#1947)
- Avatar upload did not work in IE11 / Edge (#1125, #1570)
- Translation fallback was ignored for client-rendered pages (#1774, #1961)
- The success alert when posting replies was invisible (#1976)
## [0.1.0-beta.11.1](https://github.com/flarum/core/compare/v0.1.0-beta.11...v0.1.0-beta.11.1)
### Fixed
- Saving custom css in admin failed (#1946)
## [0.1.0-beta.11](https://github.com/flarum/core/compare/v0.1.0-beta.10...v0.1.0-beta.11)
### Added
- Comments have an additional class `Post--by-actor` when posted by the user (#1927)
### Changed
- Improved support for URL identification during installation (#1861)
- KeyboardNavigatable now has a callback ability (#1922)
- Links are no longer opened with target `_blank` but in the same window (#859)
- Links now have `nofollow ugc` by default as their `rel` attribute (#859, #1884)
- Improved performance of the full text gambit when searching for users (#1877)
- The Queue implementation is now available under its Illuminate contract
### Fixed
- No error handling was possible in the console/cli (#1789)
- Enable scrollbars in log in modals so it fits for GitHub (#1716)
- Reduce log in modal for SSO so it fits for Facebook (#1727)
- Deleting discussions permanently did not delete its posts (#1909)
- Fixed the queue:restart command (#1932)
- Deleted posts were visible to all visitors (#1827)
- Old avatars weren't being deleted when replaced (#1918)
- The search performance regression was reverted (#1764)
- No profile background could be set for remote images (#445)
- Back button sends to home even though it could actually go back (#1942)
- Debug button no longer visible (#1687)
- Modals on smaller screens use the whole width of the page
## [0.1.0-beta.10](https://github.com/flarum/core/compare/v0.1.0-beta.9...v0.1.0-beta.10)
### Added
- Initial queue support: Infrastructure for offloading long-running tasks (e.g. email sending) to background workers (#1773)
- Notifications can now be marked as read without visiting a discussion (#151)
- SEO: The discussion list now has a `rel="canonical"` meta tag, preventing duplicate content (#1134, #1814)
- The "Edit User" permission can now be edited in the UI (#1845)
- New status message and redirect after user deletion (#1750, #1777)
- Errors in Flarum's boot process are now presented with more detailed information (#1607)
### Changed
- Better, more detailed and extensible error handling (#1641, #1843)
- Error pages in debug mode now return the same HTTP status codes as in production (#1648)
- Tweak HTTP status codes for authentication / authorization errors (#1854)
- Already-used links from account activation emails now show a better error message (#1337)
### Fixed
- Security vulnerabilities in dependencies
- Performance: High CPU usage when scrolling in a discussion (#1222)
- Special characters crashed the search (#1498)
- Missing declarations for language and text direction in HTML output (#1772)
- Private messages were counted in user post counts (#1695)
- Extensions could not change the forum's default page (#1819)
- API requests authenticated using access tokens needed to provide a CSRF token (#1828)
- Accessibility: Screenreaders did not read the "Back to discussion list" link (#1835)
## [0.1.0-beta.9](https://github.com/flarum/core/compare/v0.1.0-beta.8.2...v0.1.0-beta.9)
### Added
- New `hasPermission()` helper method for `Group` objects ([9684fbc](https://github.com/flarum/core/commit/9684fbc4da07d32aa322d9228302a23418412cb9))
- Expose supported mail drivers in IoC container ([208bad3](https://github.com/flarum/core/commit/208bad393f37bfdb76007afcddfa4b7451563e9d))
- More test for some API endpoints ([1670590](https://github.com/flarum/core/commit/167059027e5a066d618599c90164ef1b5a509148))
- The `Formatter\Rendering` event now receives the HTTP request instance as well ([0ab9fac](https://github.com/flarum/core/commit/0ab9facc4bd59a260575e6fc650793c663e5866a))
- More and better validation in installer UIs
- Check and enforce minimum MariaDB ([7ff9a90](https://github.com/flarum/core/commit/7ff9a90204923293adc520d3c02dc984845d4f9f))
- Revert publication of assets when installation fails ([ed9591c](https://github.com/flarum/core/commit/ed9591c16fb2ea7a4be3387b805d855a53e0a7d5))
- Benefit from Laravel's database reconnection logic in long-running tasks ([e0becd0](https://github.com/flarum/core/commit/e0becd0c7bda939048923c1f86648793feee78d5))
- The "vendor path" (where Composer dependencies can be found) can now be configured ([5e1680c](https://github.com/flarum/core/commit/5e1680c458cd3ba274faeb92de3ac2053789131e))
### Changed
- Performance: Actually cache translations on disk ([0d16fac](https://github.com/flarum/core/commit/0d16fac001bb735ee66e82871183516aeac269b7))
- Allow per-site extenders to override extension extenders ([ba594de](https://github.com/flarum/core/commit/ba594de13a033480834d53d73f747b05fe9796f8))
- Do not resolve objects from the IoC container (in service providers and extenders) until they are actually used
- Replace event subscribers (that resolve objects from the IoC container) with listeners (that resolve lazily)
- Use custom service provider for Mail component ([ac5e26a](https://github.com/flarum/core/commit/ac5e26a254d89e21bd4c115b6cbd40338e2e4b4b))
- Update to Laravel 5.7, revert custom logic for building database index names
- Refactored installer, extracted Installation class and pipeline for reuse in CLI and web installers ([790d5be](https://github.com/flarum/core/commit/790d5beee5e283178716bc8f9901c758d9e5b6a0))
- Use whitelist for enabling pre-installed extensions during installation ([4585f03](https://github.com/flarum/core/commit/4585f03ee356c92942fbc2ae8c683c651b473954))
- Update minimum MySQL version ([7ff9a90](https://github.com/flarum/core/commit/7ff9a90204923293adc520d3c02dc984845d4f9f))
### Fixed
- Signing up via OAuth providers was broken ([67f9375](https://github.com/flarum/core/commit/67f9375d4745add194ae3249d526197c32fd5461))
- Group badges were overlapping ([16eb1fa](https://github.com/flarum/core/commit/16eb1fa63b6d7b80ec30c24c0e406a2b7ab09934))
- API: Endpoint for uninstalling extensions returned an error ([c761802](https://github.com/flarum/core/commit/c76180290056ddbab67baf5ede814fcedf1dcf14))
- Documentation links in installer were outdated ([b58380e](https://github.com/flarum/core/commit/b58380e224ee54abdade3d0a4cc107ef5c91c9a9))
- Event posts where counted when aggregating user posts ([671fdec](https://github.com/flarum/core/commit/671fdec8d0a092ccceb5d4d5f657d0f4287fc4c7))
- Admins could not reset user passwords ([c67fb2d](https://github.com/flarum/core/commit/c67fb2d4b6a128c71d65dc6703310c0b62f91be2))
- Several down migrations were invalid
- Validation errors on reset password page resulted in HTTP 404 ([4611abe](https://github.com/flarum/core/commit/4611abe5db8b94ca3dc7bf9c447fca7c67358ee3))
- `is:unread` gambit generated an invalid query ([e17bb0b](https://github.com/flarum/core/commit/e17bb0b4331f2c92459292195c6b7db8cde1f9f3))
- Entire forum was breaking when the `custom_less` setting was missing from the database ([bf2c5a5](https://github.com/flarum/core/commit/bf2c5a5564dff3f5ef13efe7a8d69f2617570ce6))
- Dropdown icon was not showing in user card when on user page ([12fdfc9](https://github.com/flarum/core/commit/12fdfc9b544a27f6fe59c82ad6bddd3420cc0181))
- Requests were missing the `original*` attributes, which broke installations in subfolders ([56fde28](https://github.com/flarum/core/commit/56fde28e436f52fee0c03c538f0a6049bc584b53))
- Special characters such as `%` and `_` could return incorrect results ([ee3640e](https://github.com/flarum/core/commit/ee3640e1605ff67fef4b3d5cd0596f14a6ae73c9))
- FontAwesome component package changed paths in version 5.9.0 ([5eb69e1](https://github.com/flarum/core/commit/5eb69e1f59fa73fdfd5badbf41a05a6a040e7426))
- Some server environments had problems accessing the system-wide tmp path for storing JS file maps ([54660eb](https://github.com/flarum/core/commit/54660ebd6311f9ea142f1b573263d0d907400786))
- Content length of posts.content was not migrated to mediumText in 2017 ([590b311](https://github.com/flarum/core/commit/590b3115708bf94a9c7f169d98c6126380c7056e))
- An error occurred when going to the previous route if there was no previous route found ([985b87da](https://github.com/flarum/core/commit/985b87da6c9942c568a1a192e2fdcfde72e030ee))
### Removed
- `php flarum install --defaults` - this was meant to be used in our old development VM ([44c9109](https://github.com/flarum/core/commit/44c91099cd77138bb5fc29f14fb1e81a9781272d))
- Obsolete `id` attributes in JSON-API responses ([ecc3b5e](https://github.com/flarum/core/commit/ecc3b5e2271f8d9b38d52cd54476d86995dbe32e) and [7a44086](https://github.com/flarum/core/commit/7a44086bf3a0e3ba907dceb13d07ac695eca05ea))
## [0.1.0-beta.8.1](https://github.com/flarum/core/compare/v0.1.0-beta.8...v0.1.0-beta.8.1)
### Fixed
- Fix live output in `migrate:reset` command ([f591585](https://github.com/flarum/core/commit/f591585d02f8c4ff0211c5bf4413dd6baa724c05))
- Fix search with database prefix ([7705a2b](https://github.com/flarum/core/commit/7705a2b7d751943ef9d0c7379ec34f8530b99310))
- Fix invalid join time of admin user created by installer ([57f73c9](https://github.com/flarum/core/commit/57f73c9638eeb825f9e336ed3c443afccfd8995e))
- Ensure InnoDB engine is used for all tables ([fb6b51b](https://github.com/flarum/core/commit/fb6b51b1cfef0af399607fe038603c8240800b2b), [6370f7e](https://github.com/flarum/core/commit/6370f7ecffa9ea7d5fb64d9551400edbc63318db))
- Fix dropping foreign keys in `down` migrations ([57d5846](https://github.com/flarum/core/commit/57d5846b647881009d9e60f9ffca20b1bb77776e))
- Fix discussion list scroll position not being maintained when hero is not visible ([40dc6ac](https://github.com/flarum/core/commit/40dc6ac604c2a0973356b38217aa8d09352daae5))
- Fix empty meta description tag ([88e43cc](https://github.com/flarum/core/commit/88e43cc6940ee30d6529e9ce659471ec4fb1c474))
- Remove empty attributes on `<html>` tag ([796b577](https://github.com/flarum/core/commit/796b57753d34d4ea741dbebcbc550b17808f6c94))

View File

@@ -0,0 +1,26 @@
### Changes
* Mithril
- See changes from v0.2.x @ https://mithril.js.org/migration-v02x.html
- Kept `m.prop` and `m.withAttr`
- Actual Promises are used now instead of `m.deferred`
* Component
- Use new Mithril lifecycle hooks (`component.config` is gone)
- When implementing your own, you *must* call `super.<hook>(vnode)` to update `this.attrs`
- `component.render` now doesn't use the current state instance
- this is because of how Mithril v2 works
- now calls mithril on the component class (not instance) and its props
* Translator
- Added `app.translator.transText`, automatically extracts text from `translator.trans` output
* Utils
- Changed `computed` util to require multiple keys to be passed as an array
- `SubtreeRetainer` now has an `update` method instead of `retain`, and its output is used in `onbeforeupdate` lifecycle hook
- `Evented` util is now a class instead of an object
- `formatNumber` now uses `Number.prototype.toLocaleString` with the current application locale, and supports passing an options object (eg. for currency formatting - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/resolvedOptions#Description)
* Modals
- `app.modal.show` now takes the Modal _class_ (not instance) and optional props (`app.modal.show(ForgotPasswordModal, props)`)
#### Forum
* Forum Application
- Renamed to `Forum`
- `app.search` is no longer global, extend using `extend`

View File

@@ -1,6 +1,7 @@
The MIT License (MIT)
Copyright (c) 2014-2016 Toby Zerner
Copyright (c) 2019-2020 Stichting Flarum (Flarum Foundation)
Copyright (c) 2014-2019 Toby Zerner (toby.zerner@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,7 +1,35 @@
# Flarum Core
<p align="center"><img src="https://flarum.org/img/logo.png"></p>
This repository contains Flarum's core code. If you want to set up a forum, visit the [main Flarum repository](http://github.com/flarum/flarum).
<p align="center">
<a href="https://travis-ci.org/flarum/core"><img src="https://travis-ci.org/flarum/core.svg" alt="Build Status"></a>
<a href="https://packagist.org/packages/flarum/core"><img src="https://poser.pugx.org/flarum/core/d/total.svg" alt="Total Downloads"></a>
<a href="https://packagist.org/packages/flarum/core"><img src="https://poser.pugx.org/flarum/core/v/stable.svg" alt="Latest Stable Version"></a>
<a href="https://packagist.org/packages/flarum/core"><img src="https://poser.pugx.org/flarum/core/license.svg" alt="License"></a>
</p>
## About Flarum
**[Flarum](https://flarum.org/) is a delightfully simple discussion platform for your website.** It's fast and easy to use, with all the features you need to run a successful community. It is designed to be:
* **Fast and simple.** No clutter, no bloat, no complex dependencies. Flarum is built with PHP so its quick and easy to deploy. The interface is powered by Mithril, a performant JavaScript framework with a tiny footprint.
* **Beautiful and responsive.** This is forum software for humans. Flarum is carefully designed to be consistent and intuitive across platforms, out-of-the-box.
* **Powerful and extensible.** Customize, extend, and integrate Flarum to suit your community. Flarums architecture is amazingly flexible, with a powerful Extension API.
## Installation
This repository contains Flarum's core code. If you want to set up a forum, visit the [Flarum skeleton repository](https://github.com/flarum/flarum).
## Contributing
Flarum is open-source and we would love your help building it! Please read the [Contributing Guide](https://github.com/flarum/flarum/blob/master/CONTRIBUTING.md) to learn how you can help.
Thank you for considering contributing to Flarum! Please read the **[Contributing guide](https://flarum.org/docs/contributing.html)** to learn how you can help.
## Security Vulnerabilities
If you discover a security vulnerability within Flarum, please send an e-mail to [security@flarum.org](mailto:security@flarum.org). All security vulnerabilities will be promptly addressed. More details can be found in our [security policy](https://github.com/flarum/core/security/policy).
## License
Flarum is open-source software licensed under the [MIT License](https://github.com/flarum/flarum/blob/master/LICENSE).

View File

@@ -2,62 +2,86 @@
"name": "flarum/core",
"description": "Delightfully simple forum software.",
"keywords": ["forum", "discussion"],
"homepage": "http://flarum.org",
"homepage": "https://flarum.org/",
"license": "MIT",
"authors": [
{
"name": "Toby Zerner",
"email": "toby.zerner@gmail.com"
},
{
"name": "Franz Liedke",
"email": "franz@develophp.org"
},
{
"name": "Daniel Klabbers",
"email": "daniel@klabbers.email",
"homepage": "https://luceos.com"
},
{
"name": "David Sevilla Martin",
"email": "me+flarum@datitisev.me",
"homepage": "https://datitisev.me"
},
{
"name": "Clark Winkelmann",
"email": "clark.winkelmann@gmail.com",
"homepage": "https://clarkwinkelmann.com"
},
{
"name": "Matthew Kilgore",
"email": "matthew@kilgore.dev"
}
],
"support": {
"issues": "https://github.com/flarum/core/issues",
"source": "https://github.com/flarum/core",
"docs": "http://flarum.org/docs"
"docs": "https://flarum.org/docs/"
},
"require": {
"php": ">=5.5.9",
"php": ">=7.2",
"axy/sourcemap": "^0.1.4",
"components/font-awesome": "5.9.*",
"dflydev/fig-cookies": "^1.0.2",
"doctrine/dbal": "^2.5",
"components/font-awesome": "^4.6",
"doctrine/dbal": "^2.7",
"franzl/whoops-middleware": "^0.4.0",
"illuminate/bus": "5.1.*",
"illuminate/cache": "5.1.*",
"illuminate/config": "5.1.*",
"illuminate/container": "5.1.*",
"illuminate/contracts": "5.1.*",
"illuminate/database": "^5.1.31",
"illuminate/events": "5.1.*",
"illuminate/filesystem": "5.1.*",
"illuminate/hashing": "5.1.*",
"illuminate/mail": "5.1.*",
"illuminate/support": "5.1.*",
"illuminate/validation": "5.1.*",
"illuminate/view": "5.1.*",
"intervention/image": "^2.3.0",
"illuminate/bus": "5.7.*",
"illuminate/cache": "5.7.*",
"illuminate/config": "5.7.*",
"illuminate/container": "5.7.*",
"illuminate/contracts": "5.7.*",
"illuminate/database": "5.7.*",
"illuminate/events": "5.7.*",
"illuminate/filesystem": "5.7.*",
"illuminate/hashing": "5.7.*",
"illuminate/mail": "5.7.*",
"illuminate/queue": "5.7.*",
"illuminate/session": "5.7.*",
"illuminate/support": "5.7.*",
"illuminate/validation": "5.7.*",
"illuminate/view": "5.7.*",
"intervention/image": "^2.5.0",
"laminas/laminas-diactoros": "^1.8.4",
"laminas/laminas-httphandlerrunner": "^1.0",
"laminas/laminas-stratigility": "^3.0",
"league/flysystem": "^1.0.11",
"league/oauth2-client": "~1.0",
"matthiasmullie/minify": "^1.3",
"middlewares/base-path": "^1.1",
"middlewares/base-path-router": "^0.2.1",
"middlewares/request-handler": "^1.2",
"monolog/monolog": "^1.16.0",
"nikic/fast-route": "^0.6",
"oyejorge/less.php": "~1.5",
"psr/http-message": "^1.0",
"symfony/console": "^2.7",
"symfony/http-foundation": "^2.7",
"symfony/translation": "^2.7",
"symfony/yaml": "^2.7",
"s9e/text-formatter": "^0.6.1",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"s9e/text-formatter": "^2.3.6",
"symfony/config": "^3.3",
"symfony/console": "^4.2",
"symfony/event-dispatcher": "^4.3.2",
"symfony/translation": "^3.3",
"symfony/yaml": "^3.3",
"tobscure/json-api": "^0.3.0",
"zendframework/zend-diactoros": "^1.1",
"zendframework/zend-stratigility": "^1.1"
"wikimedia/less.php": "^3.0"
},
"require-dev": {
"mockery/mockery": "^0.9.4",
"phpunit/phpunit": "^4.8"
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0"
},
"autoload": {
"psr-4": {
@@ -69,12 +93,30 @@
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
"Flarum\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "0.1.x-dev"
}
},
"scripts": {
"test": [
"@test:unit",
"@test:integration"
],
"test:unit": "phpunit -c tests/phpunit.unit.xml",
"test:integration": "phpunit -c tests/phpunit.integration.xml",
"test:setup": "@php tests/integration/setup.php"
},
"scripts-descriptions": {
"test": "Runs all tests.",
"test:unit": "Runs all unit tests.",
"test:integration": "Runs all integration tests.",
"test:setup": "Sets up a database for use with integration tests. Execute this only once."
}
}

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>403 Forbidden</h1>
<p>You do not have permissions to access this page.</p>
</body>
</html>

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>404 Not Found</h1>
<p>Looks like this page could not be found.</p>
</body>
</html>

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>500 Internal Server Error</h1>
<p>Something went wrong on our server.</p>
</body>
</html>

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>503 Service Unavailable</h1>
<p>This forum is down for maintenance.</p>
</body>
</html>

1
js/.gitignore vendored
View File

@@ -1 +0,0 @@
bower_components

6
js/.prettierrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"printWidth": 150,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5"
}

2
js/admin.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from './src/common';
export * from './src/admin';

1
js/admin/.gitignore vendored
View File

@@ -1 +0,0 @@
node_modules

View File

@@ -1,31 +0,0 @@
var gulp = require('flarum-gulp');
var bowerDir = '../bower_components';
gulp({
includeHelpers: true,
files: [
bowerDir + '/es6-micro-loader/dist/system-polyfill.js',
bowerDir + '/mithril/mithril.js',
bowerDir + '/m.attrs.bidi/bidi.js',
bowerDir + '/jquery/dist/jquery.js',
bowerDir + '/moment/moment.js',
bowerDir + '/bootstrap/js/affix.js',
bowerDir + '/bootstrap/js/dropdown.js',
bowerDir + '/bootstrap/js/modal.js',
bowerDir + '/bootstrap/js/tooltip.js',
bowerDir + '/bootstrap/js/transition.js',
bowerDir + '/spin.js/spin.js',
bowerDir + '/spin.js/jquery.spin.js'
],
modules: {
'flarum': [
'src/**/*.js',
'../lib/**/*.js'
]
},
outputFile: 'dist/app.js'
});

23804
js/admin/dist/app.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +0,0 @@
{
"private": true,
"devDependencies": {
"gulp": "^3.9.1",
"flarum-gulp": "^0.2.0"
}
}

View File

@@ -1,33 +0,0 @@
import App from 'flarum/App';
import store from 'flarum/initializers/store';
import preload from 'flarum/initializers/preload';
import routes from 'flarum/initializers/routes';
import boot from 'flarum/initializers/boot';
const app = new App();
app.initializers.add('store', store);
app.initializers.add('routes', routes);
app.initializers.add('preload', preload, -100);
app.initializers.add('boot', boot, -100);
app.extensionSettings = {};
app.getRequiredPermissions = function(permission) {
const required = [];
if (permission === 'startDiscussion' || permission.indexOf('discussion.') === 0) {
required.push('viewDiscussions');
}
if (permission === 'discussion.delete') {
required.push('discussion.hide');
}
if (permission === 'discussion.deletePosts') {
required.push('discussion.editPosts');
}
return required;
};
export default app;

View File

@@ -1,30 +0,0 @@
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import Modal from 'flarum/components/Modal';
export default class AddExtensionModal extends Modal {
className() {
return 'AddExtensionModal Modal--small';
}
title() {
return 'Add Extension';
}
content() {
return (
<div className="Modal-body">
<p>{app.translator.trans('core.admin.add_extension.temporary_text')}</p>
<p>{app.translator.trans('core.admin.add_extension.install_text', {a: <a href="https://discuss.flarum.org/t/extensions" target="_blank"/>})}</p>
<p>{app.translator.trans('core.admin.add_extension.developer_text', {a: <a href="http://flarum.org/docs/extend" target="_blank"/>})}</p>
</div>
);
}
}

View File

@@ -1,24 +0,0 @@
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import LinkButton from 'flarum/components/LinkButton';
export default class AdminLinkButton extends LinkButton {
getButtonContent() {
const content = super.getButtonContent();
content.push(
<div className="AdminLinkButton-description">
{this.props.description}
</div>
);
return content;
}
}

View File

@@ -1,79 +0,0 @@
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import Component from 'flarum/Component';
import AdminLinkButton from 'flarum/components/AdminLinkButton';
import SelectDropdown from 'flarum/components/SelectDropdown';
import ItemList from 'flarum/utils/ItemList';
export default class AdminNav extends Component {
view() {
return (
<SelectDropdown
className="AdminNav App-titleControl"
buttonClassName="Button"
children={this.items().toArray()}
/>
);
}
/**
* Build an item list of links to show in the admin navigation.
*
* @return {ItemList}
*/
items() {
const items = new ItemList();
items.add('dashboard', AdminLinkButton.component({
href: app.route('dashboard'),
icon: 'bar-chart',
children: app.translator.trans('core.admin.nav.dashboard_button'),
description: app.translator.trans('core.admin.nav.dashboard_text')
}));
items.add('basics', AdminLinkButton.component({
href: app.route('basics'),
icon: 'pencil',
children: app.translator.trans('core.admin.nav.basics_button'),
description: app.translator.trans('core.admin.nav.basics_text')
}));
items.add('mail', AdminLinkButton.component({
href: app.route('mail'),
icon: 'envelope',
children: app.translator.trans('core.admin.nav.email_button'),
description: app.translator.trans('core.admin.nav.email_text')
}));
items.add('permissions', AdminLinkButton.component({
href: app.route('permissions'),
icon: 'key',
children: app.translator.trans('core.admin.nav.permissions_button'),
description: app.translator.trans('core.admin.nav.permissions_text')
}));
items.add('appearance', AdminLinkButton.component({
href: app.route('appearance'),
icon: 'paint-brush',
children: app.translator.trans('core.admin.nav.appearance_button'),
description: app.translator.trans('core.admin.nav.appearance_text')
}));
items.add('extensions', AdminLinkButton.component({
href: app.route('extensions'),
icon: 'puzzle-piece',
children: app.translator.trans('core.admin.nav.extensions_button'),
description: app.translator.trans('core.admin.nav.extensions_text')
}));
return items;
}
}

View File

@@ -1,119 +0,0 @@
import Page from 'flarum/components/Page';
import Button from 'flarum/components/Button';
import Switch from 'flarum/components/Switch';
import EditCustomCssModal from 'flarum/components/EditCustomCssModal';
import EditCustomHeaderModal from 'flarum/components/EditCustomHeaderModal';
import UploadImageButton from 'flarum/components/UploadImageButton';
import saveSettings from 'flarum/utils/saveSettings';
export default class AppearancePage extends Page {
init() {
super.init();
this.primaryColor = m.prop(app.data.settings.theme_primary_color);
this.secondaryColor = m.prop(app.data.settings.theme_secondary_color);
this.darkMode = m.prop(app.data.settings.theme_dark_mode === '1');
this.coloredHeader = m.prop(app.data.settings.theme_colored_header === '1');
}
view() {
return (
<div className="AppearancePage">
<div className="container">
<form onsubmit={this.onsubmit.bind(this)}>
<fieldset className="AppearancePage-colors">
<legend>{app.translator.trans('core.admin.appearance.colors_heading')}</legend>
<div className="helpText">
{app.translator.trans('core.admin.appearance.colors_text')}
</div>
<div className="AppearancePage-colors-input">
<input className="FormControl" placeholder="#aaaaaa" value={this.primaryColor()} onchange={m.withAttr('value', this.primaryColor)}/>
<input className="FormControl" placeholder="#aaaaaa" value={this.secondaryColor()} onchange={m.withAttr('value', this.secondaryColor)}/>
</div>
{Switch.component({
state: this.darkMode(),
children: app.translator.trans('core.admin.appearance.dark_mode_label'),
onchange: this.darkMode
})}
{Switch.component({
state: this.coloredHeader(),
children: app.translator.trans('core.admin.appearance.colored_header_label'),
onchange: this.coloredHeader
})}
{Button.component({
className: 'Button Button--primary',
type: 'submit',
children: app.translator.trans('core.admin.appearance.submit_button'),
loading: this.loading
})}
</fieldset>
</form>
<fieldset>
<legend>{app.translator.trans('core.admin.appearance.logo_heading')}</legend>
<div className="helpText">
{app.translator.trans('core.admin.appearance.logo_text')}
</div>
<UploadImageButton name="logo"/>
</fieldset>
<fieldset>
<legend>{app.translator.trans('core.admin.appearance.favicon_heading')}</legend>
<div className="helpText">
{app.translator.trans('core.admin.appearance.favicon_text')}
</div>
<UploadImageButton name="favicon"/>
</fieldset>
<fieldset>
<legend>{app.translator.trans('core.admin.appearance.custom_header_heading')}</legend>
<div className="helpText">
{app.translator.trans('core.admin.appearance.custom_header_text')}
</div>
{Button.component({
className: 'Button',
children: app.translator.trans('core.admin.appearance.edit_header_button'),
onclick: () => app.modal.show(new EditCustomHeaderModal())
})}
</fieldset>
<fieldset>
<legend>{app.translator.trans('core.admin.appearance.custom_styles_heading')}</legend>
<div className="helpText">
{app.translator.trans('core.admin.appearance.custom_styles_text')}
</div>
{Button.component({
className: 'Button',
children: app.translator.trans('core.admin.appearance.edit_css_button'),
onclick: () => app.modal.show(new EditCustomCssModal())
})}
</fieldset>
</div>
</div>
);
}
onsubmit(e) {
e.preventDefault();
const hex = /^#[0-9a-f]{3}([0-9a-f]{3})?$/i;
if (!hex.test(this.primaryColor()) || !hex.test(this.secondaryColor())) {
alert(app.translator.trans('core.admin.appearance.enter_hex_message'));
return;
}
this.loading = true;
saveSettings({
theme_primary_color: this.primaryColor(),
theme_secondary_color: this.secondaryColor(),
theme_dark_mode: this.darkMode(),
theme_colored_header: this.coloredHeader()
}).then(() => window.location.reload());
}
}

View File

@@ -1,156 +0,0 @@
import Page from 'flarum/components/Page';
import FieldSet from 'flarum/components/FieldSet';
import Select from 'flarum/components/Select';
import Button from 'flarum/components/Button';
import Alert from 'flarum/components/Alert';
import saveSettings from 'flarum/utils/saveSettings';
import ItemList from 'flarum/utils/ItemList';
export default class BasicsPage extends Page {
init() {
super.init();
this.loading = false;
this.fields = [
'forum_title',
'forum_description',
'default_locale',
'default_route',
'welcome_title',
'welcome_message'
];
this.values = {};
const settings = app.data.settings;
this.fields.forEach(key => this.values[key] = m.prop(settings[key]));
this.localeOptions = {};
const locales = app.data.locales;
for (const i in locales) {
this.localeOptions[i] = `${locales[i]} (${i})`;
}
}
view() {
return (
<div className="BasicsPage">
<div className="container">
<form onsubmit={this.onsubmit.bind(this)}>
{FieldSet.component({
label: app.translator.trans('core.admin.basics.forum_title_heading'),
children: [
<input className="FormControl" value={this.values.forum_title()} oninput={m.withAttr('value', this.values.forum_title)}/>
]
})}
{FieldSet.component({
label: app.translator.trans('core.admin.basics.forum_description_heading'),
children: [
<div className="helpText">
{app.translator.trans('core.admin.basics.forum_description_text')}
</div>,
<textarea className="FormControl" value={this.values.forum_description()} oninput={m.withAttr('value', this.values.forum_description)}/>
]
})}
{Object.keys(this.localeOptions).length > 1
? FieldSet.component({
label: app.translator.trans('core.admin.basics.default_language_heading'),
children: [
Select.component({
options: this.localeOptions,
onchange: this.values.default_locale
})
]
})
: ''}
{FieldSet.component({
label: app.translator.trans('core.admin.basics.home_page_heading'),
className: 'BasicsPage-homePage',
children: [
<div className="helpText">
{app.translator.trans('core.admin.basics.home_page_text')}
</div>,
this.homePageItems().toArray().map(({path, label}) =>
<label className="checkbox">
<input type="radio" name="homePage" value={path} checked={this.values.default_route() === path} onclick={m.withAttr('value', this.values.default_route)}/>
{label}
</label>
)
]
})}
{FieldSet.component({
label: app.translator.trans('core.admin.basics.welcome_banner_heading'),
className: 'BasicsPage-welcomeBanner',
children: [
<div className="helpText">
{app.translator.trans('core.admin.basics.welcome_banner_text')}
</div>,
<div className="BasicsPage-welcomeBanner-input">
<input className="FormControl" value={this.values.welcome_title()} oninput={m.withAttr('value', this.values.welcome_title)}/>
<textarea className="FormControl" value={this.values.welcome_message()} oninput={m.withAttr('value', this.values.welcome_message)}/>
</div>
]
})}
{Button.component({
type: 'submit',
className: 'Button Button--primary',
children: app.translator.trans('core.admin.basics.submit_button'),
loading: this.loading,
disabled: !this.changed()
})}
</form>
</div>
</div>
);
}
changed() {
return this.fields.some(key => this.values[key]() !== app.data.settings[key]);
}
/**
* Build a list of options for the default homepage. Each option must be an
* object with `path` and `label` properties.
*
* @return {ItemList}
* @public
*/
homePageItems() {
const items = new ItemList();
items.add('allDiscussions', {
path: '/all',
label: app.translator.trans('core.admin.basics.all_discussions_label')
});
return items;
}
onsubmit(e) {
e.preventDefault();
if (this.loading) return;
this.loading = true;
app.alerts.dismiss(this.successAlert);
const settings = {};
this.fields.forEach(key => settings[key] = this.values[key]());
saveSettings(settings)
.then(() => {
app.alerts.show(this.successAlert = new Alert({type: 'success', children: app.translator.trans('core.admin.basics.saved_message')}));
})
.catch(() => {})
.then(() => {
this.loading = false;
m.redraw();
});
}
}

View File

@@ -1,22 +0,0 @@
import Page from 'flarum/components/Page';
export default class DashboardPage extends Page {
view() {
return (
<div className="DashboardPage">
<div className="container">
<h2>{app.translator.trans('core.admin.dashboard.welcome_text')}</h2>
<p>{app.translator.trans('core.admin.dashboard.version_text', {version: <strong>{app.forum.attribute('version')}</strong>})}</p>
<p>{app.translator.trans('core.admin.dashboard.beta_warning_text', {strong: <strong/>})}</p>
<ul>
<li>{app.translator.trans('core.admin.dashboard.contributing_text', {a: <a href="http://flarum.org/docs/contributing" target="_blank"/>})}</li>
<li>{app.translator.trans('core.admin.dashboard.troubleshooting_text', {a: <a href="http://flarum.org/docs/troubleshooting" target="_blank"/>})}</li>
<li>{app.translator.trans('core.admin.dashboard.support_text', {a: <a href="http://discuss.flarum.org/t/support" target="_blank"/>})}</li>
<li>{app.translator.trans('core.admin.dashboard.features_text', {a: <a href="http://discuss.flarum.org/t/features" target="_blank"/>})}</li>
<li>{app.translator.trans('core.admin.dashboard.extension_text', {a: <a href="http://flarum.org/docs/extend" target="_blank"/>})}</li>
</ul>
</div>
</div>
);
}
}

View File

@@ -1,24 +0,0 @@
import SettingsModal from 'flarum/components/SettingsModal';
export default class EditCustomCssModal extends SettingsModal {
className() {
return 'EditCustomCssModal Modal--large';
}
title() {
return app.translator.trans('core.admin.edit_css.title');
}
form() {
return [
<p>{app.translator.trans('core.admin.edit_css.customize_text', {a: <a href="https://github.com/flarum/core/tree/master/less" target="_blank"/>})}</p>,
<div className="Form-group">
<textarea className="FormControl" rows="30" bidi={this.setting('custom_less')}/>
</div>
];
}
onsaved() {
window.location.reload();
}
}

View File

@@ -1,24 +0,0 @@
import SettingsModal from 'flarum/components/SettingsModal';
export default class EditCustomHeaderModal extends SettingsModal {
className() {
return 'EditCustomHeaderModal Modal--large';
}
title() {
return app.translator.trans('core.admin.edit_header.title');
}
form() {
return [
<p>{app.translator.trans('core.admin.edit_header.customize_text')}</p>,
<div className="Form-group">
<textarea className="FormControl" rows="30" bidi={this.setting('custom_header')}/>
</div>
];
}
onsaved() {
window.location.reload();
}
}

View File

@@ -1,102 +0,0 @@
import Modal from 'flarum/components/Modal';
import Button from 'flarum/components/Button';
import Badge from 'flarum/components/Badge';
import Group from 'flarum/models/Group';
/**
* The `EditGroupModal` component shows a modal dialog which allows the user
* to create or edit a group.
*/
export default class EditGroupModal extends Modal {
init() {
this.group = this.props.group || app.store.createRecord('groups');
this.nameSingular = m.prop(this.group.nameSingular() || '');
this.namePlural = m.prop(this.group.namePlural() || '');
this.icon = m.prop(this.group.icon() || '');
this.color = m.prop(this.group.color() || '');
}
className() {
return 'EditGroupModal Modal--small';
}
title() {
return [
this.color() || this.icon() ? Badge.component({
icon: this.icon(),
style: {backgroundColor: this.color()}
}) : '',
' ',
this.namePlural() || app.translator.trans('core.admin.edit_group.title')
];
}
content() {
return (
<div className="Modal-body">
<div className="Form">
<div className="Form-group">
<label>{app.translator.trans('core.admin.edit_group.name_label')}</label>
<div className="EditGroupModal-name-input">
<input className="FormControl" placeholder={app.translator.trans('core.admin.edit_group.singular_placeholder')} value={this.nameSingular()} oninput={m.withAttr('value', this.nameSingular)}/>
<input className="FormControl" placeholder={app.translator.trans('core.admin.edit_group.plural_placeholder')} value={this.namePlural()} oninput={m.withAttr('value', this.namePlural)}/>
</div>
</div>
<div className="Form-group">
<label>{app.translator.trans('core.admin.edit_group.color_label')}</label>
<input className="FormControl" placeholder="#aaaaaa" value={this.color()} oninput={m.withAttr('value', this.color)}/>
</div>
<div className="Form-group">
<label>{app.translator.trans('core.admin.edit_group.icon_label')}</label>
<div className="helpText">
{app.translator.trans('core.admin.edit_group.icon_text', {a: <a href="http://fortawesome.github.io/Font-Awesome/icons/" tabindex="-1"/>})}
</div>
<input className="FormControl" placeholder="bolt" value={this.icon()} oninput={m.withAttr('value', this.icon)}/>
</div>
<div className="Form-group">
{Button.component({
type: 'submit',
className: 'Button Button--primary EditGroupModal-save',
loading: this.loading,
children: app.translator.trans('core.admin.edit_group.submit_button')
})}
{this.group.exists && this.group.id() !== Group.ADMINISTRATOR_ID ? (
<button type="button" className="Button EditGroupModal-delete" onclick={this.deleteGroup.bind(this)}>
{app.translator.trans('core.admin.edit_group.delete_button')}
</button>
) : ''}
</div>
</div>
</div>
);
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
this.group.save({
nameSingular: this.nameSingular(),
namePlural: this.namePlural(),
color: this.color(),
icon: this.icon()
}, {errorHandler: this.onerror.bind(this)})
.then(this.hide.bind(this))
.catch(() => {
this.loading = false;
m.redraw();
});
}
deleteGroup() {
if (confirm(app.translator.trans('core.admin.edit_group.delete_confirmation'))) {
this.group.delete().then(() => m.redraw());
this.hide();
}
}
}

View File

@@ -1,114 +0,0 @@
import Page from 'flarum/components/Page';
import LinkButton from 'flarum/components/LinkButton';
import Button from 'flarum/components/Button';
import Dropdown from 'flarum/components/Dropdown';
import Separator from 'flarum/components/Separator';
import AddExtensionModal from 'flarum/components/AddExtensionModal';
import LoadingModal from 'flarum/components/LoadingModal';
import ItemList from 'flarum/utils/ItemList';
import icon from 'flarum/helpers/icon';
import listItems from 'flarum/helpers/listItems';
export default class ExtensionsPage extends Page {
view() {
return (
<div className="ExtensionsPage">
<div className="ExtensionsPage-header">
<div className="container">
{Button.component({
children: app.translator.trans('core.admin.extensions.add_button'),
icon: 'plus',
className: 'Button Button--primary',
onclick: () => app.modal.show(new AddExtensionModal())
})}
</div>
</div>
<div className="ExtensionsPage-list">
<div className="container">
<ul className="ExtensionList">
{Object.keys(app.data.extensions)
.map(id => {
const extension = app.data.extensions[id];
const controls = this.controlItems(extension.id).toArray();
return <li className={'ExtensionListItem ' + (!this.isEnabled(extension.id) ? 'disabled' : '')}>
<div className="ExtensionListItem-content">
<span className="ExtensionListItem-icon ExtensionIcon" style={extension.icon}>
{extension.icon ? icon(extension.icon.name) : ''}
</span>
{controls.length ? (
<Dropdown
className="ExtensionListItem-controls"
buttonClassName="Button Button--icon Button--flat"
menuClassName="Dropdown-menu--right"
icon="ellipsis-h">
{controls}
</Dropdown>
) : ''}
<label className="ExtensionListItem-title">
<input type="checkbox" checked={this.isEnabled(extension.id)} onclick={this.toggle.bind(this, extension.id)}/> {' '}
{extension.extra['flarum-extension'].title}
</label>
<div className="ExtensionListItem-version">{extension.version}</div>
</div>
</li>;
})}
</ul>
</div>
</div>
</div>
);
}
controlItems(name) {
const items = new ItemList();
const enabled = this.isEnabled(name);
if (app.extensionSettings[name]) {
items.add('settings', Button.component({
icon: 'cog',
children: app.translator.trans('core.admin.extensions.settings_button'),
onclick: app.extensionSettings[name]
}));
}
if (!enabled) {
items.add('uninstall', Button.component({
icon: 'trash-o',
children: app.translator.trans('core.admin.extensions.uninstall_button'),
onclick: () => {
app.request({
url: app.forum.attribute('apiUrl') + '/extensions/' + name,
method: 'DELETE'
}).then(() => window.location.reload());
app.modal.show(new LoadingModal());
}
}));
}
return items;
}
isEnabled(name) {
const enabled = JSON.parse(app.data.settings.extensions_enabled);
return enabled.indexOf(name) !== -1;
}
toggle(id) {
const enabled = this.isEnabled(id);
app.request({
url: app.forum.attribute('apiUrl') + '/extensions/' + id,
method: 'PATCH',
data: {enabled: !enabled}
}).then(() => {
if (!enabled) localStorage.setItem('enabledExtension', id);
window.location.reload();
});
app.modal.show(new LoadingModal());
}
}

View File

@@ -1,33 +0,0 @@
import Component from 'flarum/Component';
import ItemList from 'flarum/utils/ItemList';
import listItems from 'flarum/helpers/listItems';
/**
* The `HeaderPrimary` component displays primary header controls. On the
* default skin, these are shown just to the right of the forum title.
*/
export default class HeaderPrimary extends Component {
view() {
return (
<ul className="Header-controls">
{listItems(this.items().toArray())}
</ul>
);
}
config(isInitialized, context) {
// Since this component is 'above' the content of the page (that is, it is a
// part of the global UI that persists between routes), we will flag the DOM
// to be retained across route changes.
context.retain = true;
}
/**
* Build an item list for the controls.
*
* @return {ItemList}
*/
items() {
return new ItemList();
}
}

View File

@@ -1,37 +0,0 @@
import Component from 'flarum/Component';
import SessionDropdown from 'flarum/components/SessionDropdown';
import ItemList from 'flarum/utils/ItemList';
import listItems from 'flarum/helpers/listItems';
/**
* The `HeaderSecondary` component displays secondary header controls.
*/
export default class HeaderSecondary extends Component {
view() {
return (
<ul className="Header-controls">
{listItems(this.items().toArray())}
</ul>
);
}
config(isInitialized, context) {
// Since this component is 'above' the content of the page (that is, it is a
// part of the global UI that persists between routes), we will flag the DOM
// to be retained across route changes.
context.retain = true;
}
/**
* Build an item list for the controls.
*
* @return {ItemList}
*/
items() {
const items = new ItemList();
items.add('session', SessionDropdown.component());
return items;
}
}

View File

@@ -1,19 +0,0 @@
import Modal from 'flarum/components/Modal';
export default class LoadingModal extends Modal {
isDismissible() {
return false;
}
className() {
return 'LoadingModal Modal--small';
}
title() {
return app.translator.trans('core.admin.loading.title');
}
content() {
return '';
}
}

View File

@@ -1,124 +0,0 @@
import Page from 'flarum/components/Page';
import FieldSet from 'flarum/components/FieldSet';
import Button from 'flarum/components/Button';
import Alert from 'flarum/components/Alert';
import saveSettings from 'flarum/utils/saveSettings';
export default class MailPage extends Page {
init() {
super.init();
this.loading = false;
this.fields = [
'mail_driver',
'mail_host',
'mail_from',
'mail_port',
'mail_username',
'mail_password',
'mail_encryption'
];
this.values = {};
const settings = app.data.settings;
this.fields.forEach(key => this.values[key] = m.prop(settings[key]));
this.localeOptions = {};
const locales = app.locales;
for (const i in locales) {
this.localeOptions[i] = `${locales[i]} (${i})`;
}
}
view() {
return (
<div className="MailPage">
<div className="container">
<form onsubmit={this.onsubmit.bind(this)}>
<h2>{app.translator.trans('core.admin.email.heading')}</h2>
<div className="helpText">
{app.translator.trans('core.admin.email.text')}
</div>
{FieldSet.component({
label: app.translator.trans('core.admin.email.server_heading'),
className: 'MailPage-MailSettings',
children: [
<div className="MailPage-MailSettings-input">
<label>{app.translator.trans('core.admin.email.driver_label')}</label>
<input className="FormControl" value={this.values.mail_driver() || ''} oninput={m.withAttr('value', this.values.mail_driver)} />
<label>{app.translator.trans('core.admin.email.host_label')}</label>
<input className="FormControl" value={this.values.mail_host() || ''} oninput={m.withAttr('value', this.values.mail_host)} />
<label>{app.translator.trans('core.admin.email.port_label')}</label>
<input className="FormControl" value={this.values.mail_port() || ''} oninput={m.withAttr('value', this.values.mail_port)} />
<label>{app.translator.trans('core.admin.email.encryption_label')}</label>
<input className="FormControl" value={this.values.mail_encryption() || ''} oninput={m.withAttr('value', this.values.mail_encryption)} />
</div>
]
})}
{FieldSet.component({
label: app.translator.trans('core.admin.email.account_heading'),
className: 'MailPage-MailSettings',
children: [
<div className="MailPage-MailSettings-input">
<label>{app.translator.trans('core.admin.email.username_label')}</label>
<input className="FormControl" value={this.values.mail_username() || ''} oninput={m.withAttr('value', this.values.mail_username)} />
<label>{app.translator.trans('core.admin.email.password_label')}</label>
<input className="FormControl" value={this.values.mail_password() || ''} oninput={m.withAttr('value', this.values.mail_password)} />
</div>
]
})}
{FieldSet.component({
label: app.translator.trans('core.admin.email.addresses_heading'),
className: 'MailPage-MailSettings',
children: [
<div className="MailPage-MailSettings-input">
<label>{app.translator.trans('core.admin.email.from_label')}</label>
<input className="FormControl" value={this.values.mail_from() || ''} oninput={m.withAttr('value', this.values.mail_from)} />
</div>
]
})}
{Button.component({
type: 'submit',
className: 'Button Button--primary',
children: app.translator.trans('core.admin.email.submit_button'),
loading: this.loading,
disabled: !this.changed()
})}
</form>
</div>
</div>
);
}
changed() {
return this.fields.some(key => this.values[key]() !== app.data.settings[key]);
}
onsubmit(e) {
e.preventDefault();
if (this.loading) return;
this.loading = true;
app.alerts.dismiss(this.successAlert);
const settings = {};
this.fields.forEach(key => settings[key] = this.values[key]());
saveSettings(settings)
.then(() => {
app.alerts.show(this.successAlert = new Alert({type: 'success', children: app.translator.trans('core.admin.basics.saved_message')}));
})
.catch(() => {})
.then(() => {
this.loading = false;
m.redraw();
});
}
}

View File

@@ -1,32 +0,0 @@
import Component from 'flarum/Component';
/**
* The `Page` component
*
* @abstract
*/
export default class Page extends Component {
init() {
app.previous = app.current;
app.current = this;
app.modal.close();
/**
* A class name to apply to the body while the route is active.
*
* @type {String}
*/
this.bodyClass = '';
}
config(isInitialized, context) {
if (isInitialized) return;
if (this.bodyClass) {
$('#app').addClass(this.bodyClass);
context.onunload = () => $('#app').removeClass(this.bodyClass);
}
}
}

View File

@@ -1,149 +0,0 @@
import Dropdown from 'flarum/components/Dropdown';
import Button from 'flarum/components/Button';
import Separator from 'flarum/components/Separator';
import Group from 'flarum/models/Group';
import Badge from 'flarum/components/Badge';
import GroupBadge from 'flarum/components/GroupBadge';
function badgeForId(id) {
const group = app.store.getById('groups', id);
return group ? GroupBadge.component({group, label: null}) : '';
}
function filterByRequiredPermissions(groupIds, permission) {
app.getRequiredPermissions(permission)
.forEach(required => {
const restrictToGroupIds = app.data.permissions[required] || [];
if (restrictToGroupIds.indexOf(Group.GUEST_ID) !== -1) {
// do nothing
} else if (restrictToGroupIds.indexOf(Group.MEMBER_ID) !== -1) {
groupIds = groupIds.filter(id => id !== Group.GUEST_ID);
} else if (groupIds.indexOf(Group.MEMBER_ID) !== -1) {
groupIds = restrictToGroupIds;
} else {
groupIds = restrictToGroupIds.filter(id => groupIds.indexOf(id) !== -1);
}
groupIds = filterByRequiredPermissions(groupIds, required);
});
return groupIds;
}
export default class PermissionDropdown extends Dropdown {
static initProps(props) {
super.initProps(props);
props.className = 'PermissionDropdown';
props.buttonClassName = 'Button Button--text';
}
view() {
this.props.children = [];
let groupIds = app.data.permissions[this.props.permission] || [];
groupIds = filterByRequiredPermissions(groupIds, this.props.permission);
const everyone = groupIds.indexOf(Group.GUEST_ID) !== -1;
const members = groupIds.indexOf(Group.MEMBER_ID) !== -1;
const adminGroup = app.store.getById('groups', Group.ADMINISTRATOR_ID);
if (everyone) {
this.props.label = Badge.component({icon: 'globe'});
} else if (members) {
this.props.label = Badge.component({icon: 'user'});
} else {
this.props.label = [
badgeForId(Group.ADMINISTRATOR_ID),
groupIds.map(badgeForId)
];
}
if (this.showing) {
if (this.props.allowGuest) {
this.props.children.push(
Button.component({
children: [Badge.component({icon: 'globe'}), ' ', app.translator.trans('core.admin.permissions_controls.everyone_button')],
icon: everyone ? 'check' : true,
onclick: () => this.save([Group.GUEST_ID]),
disabled: this.isGroupDisabled(Group.GUEST_ID)
})
);
}
this.props.children.push(
Button.component({
children: [Badge.component({icon: 'user'}), ' ', app.translator.trans('core.admin.permissions_controls.members_button')],
icon: members ? 'check' : true,
onclick: () => this.save([Group.MEMBER_ID]),
disabled: this.isGroupDisabled(Group.MEMBER_ID)
}),
Separator.component(),
Button.component({
children: [badgeForId(adminGroup.id()), ' ', adminGroup.namePlural()],
icon: !everyone && !members ? 'check' : true,
disabled: !everyone && !members,
onclick: e => {
if (e.shiftKey) e.stopPropagation();
this.save([]);
}
})
);
[].push.apply(
this.props.children,
app.store.all('groups')
.filter(group => [Group.ADMINISTRATOR_ID, Group.GUEST_ID, Group.MEMBER_ID].indexOf(group.id()) === -1)
.map(group => Button.component({
children: [badgeForId(group.id()), ' ', group.namePlural()],
icon: groupIds.indexOf(group.id()) !== -1 ? 'check' : true,
onclick: (e) => {
if (e.shiftKey) e.stopPropagation();
this.toggle(group.id());
},
disabled: this.isGroupDisabled(group.id()) && this.isGroupDisabled(Group.MEMBER_ID) && this.isGroupDisabled(Group.GUEST_ID)
}))
);
}
return super.view();
}
save(groupIds) {
const permission = this.props.permission;
app.data.permissions[permission] = groupIds;
app.request({
method: 'POST',
url: app.forum.attribute('apiUrl') + '/permission',
data: {permission, groupIds}
});
}
toggle(groupId) {
const permission = this.props.permission;
let groupIds = app.data.permissions[permission] || [];
const index = groupIds.indexOf(groupId);
if (index !== -1) {
groupIds.splice(index, 1);
} else {
groupIds.push(groupId);
groupIds = groupIds.filter(id => [Group.GUEST_ID, Group.MEMBER_ID].indexOf(id) === -1);
}
this.save(groupIds);
}
isGroupDisabled(id) {
return filterByRequiredPermissions([id], this.props.permission).indexOf(id) === -1;
}
}

View File

@@ -1,240 +0,0 @@
import Component from 'flarum/Component';
import PermissionDropdown from 'flarum/components/PermissionDropdown';
import SettingDropdown from 'flarum/components/SettingDropdown';
import Button from 'flarum/components/Button';
import ItemList from 'flarum/utils/ItemList';
import icon from 'flarum/helpers/icon';
export default class PermissionGrid extends Component {
init() {
this.permissions = this.permissionItems().toArray();
}
view() {
const scopes = this.scopeItems().toArray();
const permissionCells = permission => {
return scopes.map(scope => (
<td>
{scope.render(permission)}
</td>
));
};
return (
<table className="PermissionGrid">
<thead>
<tr>
<td></td>
{scopes.map(scope => (
<th>
{scope.label}{' '}
{scope.onremove ? Button.component({icon: 'times', className: 'Button Button--text PermissionGrid-removeScope', onclick: scope.onremove}) : ''}
</th>
))}
<th>{this.scopeControlItems().toArray()}</th>
</tr>
</thead>
{this.permissions.map(section => (
<tbody>
<tr className="PermissionGrid-section">
<th>{section.label}</th>
{permissionCells(section)}
<td/>
</tr>
{section.children.map(child => (
<tr className="PermissionGrid-child">
<th>{icon(child.icon)}{child.label}</th>
{permissionCells(child)}
<td/>
</tr>
))}
</tbody>
))}
</table>
);
}
permissionItems() {
const items = new ItemList();
items.add('view', {
label: app.translator.trans('core.admin.permissions.read_heading'),
children: this.viewItems().toArray()
}, 100);
items.add('start', {
label: app.translator.trans('core.admin.permissions.create_heading'),
children: this.startItems().toArray()
}, 90);
items.add('reply', {
label: app.translator.trans('core.admin.permissions.participate_heading'),
children: this.replyItems().toArray()
}, 80);
items.add('moderate', {
label: app.translator.trans('core.admin.permissions.moderate_heading'),
children: this.moderateItems().toArray()
}, 70);
return items;
}
viewItems() {
const items = new ItemList();
items.add('viewDiscussions', {
icon: 'eye',
label: app.translator.trans('core.admin.permissions.view_discussions_label'),
permission: 'viewDiscussions',
allowGuest: true
}, 100);
items.add('signUp', {
icon: 'user-plus',
label: app.translator.trans('core.admin.permissions.sign_up_label'),
setting: () => SettingDropdown.component({
key: 'allow_sign_up',
options: [
{value: '1', label: app.translator.trans('core.admin.permissions_controls.signup_open_button')},
{value: '0', label: app.translator.trans('core.admin.permissions_controls.signup_closed_button')}
]
})
}, 90);
return items;
}
startItems() {
const items = new ItemList();
items.add('start', {
icon: 'edit',
label: app.translator.trans('core.admin.permissions.start_discussions_label'),
permission: 'startDiscussion'
}, 100);
items.add('allowRenaming', {
icon: 'i-cursor',
label: app.translator.trans('core.admin.permissions.allow_renaming_label'),
setting: () => {
const minutes = parseInt(app.data.settings.allow_renaming, 10);
return SettingDropdown.component({
defaultLabel: minutes
? app.translator.transChoice('core.admin.permissions_controls.allow_some_minutes_button', minutes, {count: minutes})
: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button'),
key: 'allow_renaming',
options: [
{value: '-1', label: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button')},
{value: '10', label: app.translator.trans('core.admin.permissions_controls.allow_ten_minutes_button')},
{value: 'reply', label: app.translator.trans('core.admin.permissions_controls.allow_until_reply_button')}
]
});
}
}, 90);
return items;
}
replyItems() {
const items = new ItemList();
items.add('reply', {
icon: 'reply',
label: app.translator.trans('core.admin.permissions.reply_to_discussions_label'),
permission: 'discussion.reply'
}, 100);
items.add('allowPostEditing', {
icon: 'pencil',
label: app.translator.trans('core.admin.permissions.allow_post_editing_label'),
setting: () => {
const minutes = parseInt(app.data.settings.allow_post_editing, 10);
return SettingDropdown.component({
defaultLabel: minutes
? app.translator.transChoice('core.admin.permissions_controls.allow_some_minutes_button', minutes, {count: minutes})
: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button'),
key: 'allow_post_editing',
options: [
{value: '-1', label: app.translator.trans('core.admin.permissions_controls.allow_indefinitely_button')},
{value: '10', label: app.translator.trans('core.admin.permissions_controls.allow_ten_minutes_button')},
{value: 'reply', label: app.translator.trans('core.admin.permissions_controls.allow_until_reply_button')}
]
});
}
}, 90);
return items;
}
moderateItems() {
const items = new ItemList();
items.add('viewIpsPosts', {
icon: 'bullseye',
label: app.translator.trans('core.admin.permissions.view_post_ips_label'),
permission: 'discussion.viewIpsPosts'
}, 110);
items.add('renameDiscussions', {
icon: 'i-cursor',
label: app.translator.trans('core.admin.permissions.rename_discussions_label'),
permission: 'discussion.rename'
}, 100);
items.add('hideDiscussions', {
icon: 'trash-o',
label: app.translator.trans('core.admin.permissions.delete_discussions_label'),
permission: 'discussion.hide'
}, 90);
items.add('deleteDiscussions', {
icon: 'times',
label: app.translator.trans('core.admin.permissions.delete_discussions_forever_label'),
permission: 'discussion.delete'
}, 80);
items.add('editPosts', {
icon: 'pencil',
label: app.translator.trans('core.admin.permissions.edit_and_delete_posts_label'),
permission: 'discussion.editPosts'
}, 70);
items.add('deletePosts', {
icon: 'times',
label: app.translator.trans('core.admin.permissions.delete_posts_forever_label'),
permission: 'discussion.deletePosts'
}, 60);
return items;
}
scopeItems() {
const items = new ItemList();
items.add('global', {
label: app.translator.trans('core.admin.permissions.global_heading'),
render: item => {
if (item.setting) {
return item.setting();
} else if (item.permission) {
return PermissionDropdown.component({
permission: item.permission,
allowGuest: item.allowGuest
});
}
return '';
}
}, 100);
return items;
}
scopeControlItems() {
return new ItemList();
}
}

View File

@@ -1,41 +0,0 @@
import Page from 'flarum/components/Page';
import GroupBadge from 'flarum/components/GroupBadge';
import EditGroupModal from 'flarum/components/EditGroupModal';
import Group from 'flarum/models/Group';
import icon from 'flarum/helpers/icon';
import PermissionGrid from 'flarum/components/PermissionGrid';
export default class PermissionsPage extends Page {
view() {
return (
<div className="PermissionsPage">
<div className="PermissionsPage-groups">
<div className="container">
{app.store.all('groups')
.filter(group => [Group.GUEST_ID, Group.MEMBER_ID].indexOf(group.id()) === -1)
.map(group => (
<button className="Button Group" onclick={() => app.modal.show(new EditGroupModal({group}))}>
{GroupBadge.component({
group,
className: 'Group-icon',
label: null
})}
<span className="Group-name">{group.namePlural()}</span>
</button>
))}
<button className="Button Group Group--add" onclick={() => app.modal.show(new EditGroupModal())}>
{icon('plus', {className: 'Group-icon'})}
<span className="Group-name">{app.translator.trans('core.admin.permissions.new_group_button')}</span>
</button>
</div>
</div>
<div className="PermissionsPage-permissions">
<div className="container">
{PermissionGrid.component()}
</div>
</div>
</div>
);
}
}

View File

@@ -1,54 +0,0 @@
import avatar from 'flarum/helpers/avatar';
import username from 'flarum/helpers/username';
import Dropdown from 'flarum/components/Dropdown';
import Button from 'flarum/components/Button';
import ItemList from 'flarum/utils/ItemList';
/**
* The `SessionDropdown` component shows a button with the current user's
* avatar/name, with a dropdown of session controls.
*/
export default class SessionDropdown extends Dropdown {
static initProps(props) {
super.initProps(props);
props.className = 'SessionDropdown';
props.buttonClassName = 'Button Button--user Button--flat';
props.menuClassName = 'Dropdown-menu--right';
}
view() {
this.props.children = this.items().toArray();
return super.view();
}
getButtonContent() {
const user = app.session.user;
return [
avatar(user), ' ',
<span className="Button-label">{username(user)}</span>
];
}
/**
* Build an item list for the contents of the dropdown menu.
*
* @return {ItemList}
*/
items() {
const items = new ItemList();
items.add('logOut',
Button.component({
icon: 'sign-out',
children: app.translator.trans('core.admin.header.log_out_button'),
onclick: app.session.logout.bind(app.session)
}),
-100
);
return items;
}
}

View File

@@ -1,25 +0,0 @@
import SelectDropdown from 'flarum/components/SelectDropdown';
import Button from 'flarum/components/Button';
import saveSettings from 'flarum/utils/saveSettings';
export default class SettingDropdown extends SelectDropdown {
static initProps(props) {
super.initProps(props);
props.className = 'SettingDropdown';
props.buttonClassName = 'Button Button--text';
props.caretIcon = 'caret-down';
props.defaultLabel = 'Custom';
props.children = props.options.map(({value, label}) => {
const active = app.data.settings[props.key] === value;
return Button.component({
children: label,
icon: active ? 'check' : true,
onclick: saveSettings.bind(this, {[props.key]: value}),
active
});
});
}
}

View File

@@ -1,79 +0,0 @@
import Modal from 'flarum/components/Modal';
import Button from 'flarum/components/Button';
import saveSettings from 'flarum/utils/saveSettings';
export default class SettingsModal extends Modal {
init() {
this.settings = {};
this.loading = false;
}
form() {
return '';
}
content() {
return (
<div className="Modal-body">
<div className="Form">
{this.form()}
<div className="Form-group">
{this.submitButton()}
</div>
</div>
</div>
);
}
submitButton() {
return (
<Button
type="submit"
className="Button Button--primary"
loading={this.loading}
disabled={!this.changed()}>
{app.translator.trans('core.admin.settings.submit_button')}
</Button>
);
}
setting(key, fallback = '') {
this.settings[key] = this.settings[key] || m.prop(app.data.settings[key] || fallback);
return this.settings[key];
}
dirty() {
const dirty = {};
Object.keys(this.settings).forEach(key => {
const value = this.settings[key]();
if (value !== app.data.settings[key]) {
dirty[key] = value;
}
});
return dirty;
}
changed() {
return Object.keys(this.dirty()).length;
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
saveSettings(this.dirty()).then(
this.onsaved.bind(this),
this.loaded.bind(this)
);
}
onsaved() {
this.hide();
}
}

View File

@@ -1,97 +0,0 @@
import Button from 'flarum/components/Button';
export default class UploadImageButton extends Button {
init() {
this.loading = false;
}
view() {
this.props.loading = this.loading;
this.props.className = (this.props.className || '') + ' Button';
if (app.data.settings[this.props.name + '_path']) {
this.props.onclick = this.remove.bind(this);
this.props.children = app.translator.trans('core.admin.upload_image.remove_button');
return (
<div>
<p><img src={app.forum.attribute(this.props.name+'Url')} alt=""/></p>
<p>{super.view()}</p>
</div>
);
} else {
this.props.onclick = this.upload.bind(this);
this.props.children = app.translator.trans('core.admin.upload_image.upload_button');
}
return super.view();
}
/**
* Prompt the user to upload an image.
*/
upload() {
if (this.loading) return;
const $input = $('<input type="file">');
$input.appendTo('body').hide().click().on('change', e => {
const data = new FormData();
data.append(this.props.name, $(e.target)[0].files[0]);
this.loading = true;
m.redraw();
app.request({
method: 'POST',
url: this.resourceUrl(),
serialize: raw => raw,
data
}).then(
this.success.bind(this),
this.failure.bind(this)
);
});
}
/**
* Remove the logo.
*/
remove() {
this.loading = true;
m.redraw();
app.request({
method: 'DELETE',
url: this.resourceUrl()
}).then(
this.success.bind(this),
this.failure.bind(this)
);
}
resourceUrl() {
return app.forum.attribute('apiUrl') + '/' + this.props.name;
}
/**
* After a successful upload/removal, reload the page.
*
* @param {Object} response
* @protected
*/
success(response) {
window.location.reload();
}
/**
* If upload/removal fails, stop loading.
*
* @param {Object} response
* @protected
*/
failure(response) {
this.loading = false;
m.redraw();
}
}

View File

@@ -1,66 +0,0 @@
/*global FastClick*/
import ScrollListener from 'flarum/utils/ScrollListener';
import Drawer from 'flarum/utils/Drawer';
import mapRoutes from 'flarum/utils/mapRoutes';
import Navigation from 'flarum/components/Navigation';
import HeaderPrimary from 'flarum/components/HeaderPrimary';
import HeaderSecondary from 'flarum/components/HeaderSecondary';
import AdminNav from 'flarum/components/AdminNav';
import ModalManager from 'flarum/components/ModalManager';
import AlertManager from 'flarum/components/AlertManager';
/**
* The `boot` initializer boots up the admin app. It initializes some app
* globals, mounts components to the page, and begins routing.
*
* @param {ForumApp} app
*/
export default function boot(app) {
m.startComputation();
m.mount(document.getElementById('app-navigation'), Navigation.component({className: 'App-backControl', drawer: true}));
m.mount(document.getElementById('header-navigation'), Navigation.component());
m.mount(document.getElementById('header-primary'), HeaderPrimary.component());
m.mount(document.getElementById('header-secondary'), HeaderSecondary.component());
m.mount(document.getElementById('admin-navigation'), AdminNav.component());
app.drawer = new Drawer();
app.modal = m.mount(document.getElementById('modal'), ModalManager.component());
app.alerts = m.mount(document.getElementById('alerts'), AlertManager.component());
app.history = {
canGoBack: () => true,
getPrevious: () => {},
backUrl: () => app.forum.attribute('baseUrl'),
back: function() {
window.location = this.backUrl();
}
};
m.route.mode = 'hash';
m.route(document.getElementById('content'), '/', mapRoutes(app.routes));
m.endComputation();
// Add a class to the body which indicates that the page has been scrolled
// down.
new ScrollListener(top => {
const $app = $('#app');
const offset = $app.offset().top;
$app
.toggleClass('affix', top >= offset)
.toggleClass('scrolled', top > offset);
}).start();
app.booted = true;
// If an extension has just been enabled, then we will run its settings
// callback.
const enabled = localStorage.getItem('enabledExtension');
if (enabled && app.extensionSettings[enabled]) {
app.extensionSettings[enabled]();
localStorage.removeItem('enabledExtension');
}
}

View File

@@ -1,22 +0,0 @@
import DashboardPage from 'flarum/components/DashboardPage';
import BasicsPage from 'flarum/components/BasicsPage';
import PermissionsPage from 'flarum/components/PermissionsPage';
import AppearancePage from 'flarum/components/AppearancePage';
import ExtensionsPage from 'flarum/components/ExtensionsPage';
import MailPage from 'flarum/components/MailPage';
/**
* The `routes` initializer defines the admin app's routes.
*
* @param {App} app
*/
export default function(app) {
app.routes = {
'dashboard': {path: '/', component: DashboardPage.component()},
'basics': {path: '/basics', component: BasicsPage.component()},
'permissions': {path: '/permissions', component: PermissionsPage.component()},
'appearance': {path: '/appearance', component: AppearancePage.component()},
'extensions': {path: '/extensions', component: ExtensionsPage.component()},
'mail': {path: '/mail', component: MailPage.component()}
};
}

View File

@@ -1,14 +0,0 @@
export default function saveSettings(settings) {
const oldSettings = JSON.parse(JSON.stringify(app.data.settings));
Object.assign(app.data.settings, settings);
return app.request({
method: 'POST',
url: app.forum.attribute('apiUrl') + '/settings',
data: settings
}).catch(error => {
app.data.settings = oldSettings;
throw error;
});
}

View File

@@ -1,16 +0,0 @@
{
"name": "flarum",
"dependencies": {
"jquery": "~2.1.3",
"jquery.hotkeys": "jeresig/jquery.hotkeys#0.2.0",
"bootstrap": "~3.3.2",
"spin.js": "~2.0.1",
"moment": "~2.8.4",
"color-thief": "v2.0",
"mithril": "lhorie/mithril.js#v0.2.5",
"es6-micro-loader": "caridy/es6-micro-loader#v0.2.1",
"fastclick": "~1.0.6",
"autolink": "~1.0.0",
"m.attrs.bidi": "tobscure/m.attrs.bidi"
}
}

20885
js/dist/admin.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
js/dist/admin.js.map vendored Normal file

File diff suppressed because one or more lines are too long

26522
js/dist/forum.js vendored Normal file

File diff suppressed because it is too large Load Diff

1
js/dist/forum.js.map vendored Normal file

File diff suppressed because one or more lines are too long

2
js/forum.ts Normal file
View File

@@ -0,0 +1,2 @@
export * from './src/common';
export * from './src/forum';

1
js/forum/.gitignore vendored
View File

@@ -1 +0,0 @@
node_modules

View File

@@ -1,35 +0,0 @@
var gulp = require('flarum-gulp');
var bowerDir = '../bower_components';
gulp({
includeHelpers: true,
files: [
bowerDir + '/es6-micro-loader/dist/system-polyfill.js',
bowerDir + '/mithril/mithril.js',
bowerDir + '/m.attrs.bidi/bidi.js',
bowerDir + '/jquery/dist/jquery.js',
bowerDir + '/jquery.hotkeys/jquery.hotkeys.js',
bowerDir + '/color-thief/src/color-thief.js',
bowerDir + '/moment/moment.js',
bowerDir + '/autolink/autolink-min.js',
bowerDir + '/bootstrap/js/affix.js',
bowerDir + '/bootstrap/js/dropdown.js',
bowerDir + '/bootstrap/js/modal.js',
bowerDir + '/bootstrap/js/tooltip.js',
bowerDir + '/bootstrap/js/transition.js',
bowerDir + '/spin.js/spin.js',
bowerDir + '/spin.js/jquery.spin.js',
bowerDir + '/fastclick/lib/fastclick.js'
],
modules: {
'flarum': [
'src/**/*.js',
'../lib/**/*.js'
]
},
outputFile: 'dist/app.js'
});

32117
js/forum/dist/app.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +0,0 @@
{
"private": true,
"devDependencies": {
"gulp": "^3.9.1",
"flarum-gulp": "^0.2.0"
}
}

View File

@@ -1,103 +0,0 @@
import History from 'flarum/utils/History';
import App from 'flarum/App';
import Search from 'flarum/components/Search';
import Composer from 'flarum/components/Composer';
import ReplyComposer from 'flarum/components/ReplyComposer';
import DiscussionPage from 'flarum/components/DiscussionPage';
import SignUpModal from 'flarum/components/SignUpModal';
export default class ForumApp extends App {
constructor(...args) {
super(...args);
/**
* The app's history stack, which keeps track of which routes the user visits
* so that they can easily navigate back to the previous route.
*
* @type {History}
*/
this.history = new History();
/**
* An object which controls the state of the page's side pane.
*
* @type {Pane}
*/
this.pane = null;
/**
* The page's search component instance.
*
* @type {SearchBox}
*/
this.search = new Search();
/**
* An object which controls the state of the page's drawer.
*
* @type {Drawer}
*/
this.drawer = null;
/**
* A map of post types to their components.
*
* @type {Object}
*/
this.postComponents = {};
/**
* A map of notification types to their components.
*
* @type {Object}
*/
this.notificationComponents = {};
}
/**
* Check whether or not the user is currently composing a reply to a
* discussion.
*
* @param {Discussion} discussion
* @return {Boolean}
*/
composingReplyTo(discussion) {
return this.composer.component instanceof ReplyComposer &&
this.composer.component.props.discussion === discussion &&
this.composer.position !== Composer.PositionEnum.HIDDEN;
}
/**
* Check whether or not the user is currently viewing a discussion.
*
* @param {Discussion} discussion
* @return {Boolean}
*/
viewingDiscussion(discussion) {
return this.current instanceof DiscussionPage &&
this.current.discussion === discussion;
}
/**
* Callback for when an external authenticator (social login) action has
* completed.
*
* If the payload indicates that the user has been logged in, then the page
* will be reloaded. Otherwise, a SignUpModal will be opened, prefilled
* with the provided details.
*
* @param {Object} payload A dictionary of props to pass into the sign up
* modal. A truthy `authenticated` prop indicates that the user has logged
* in, and thus the page is reloaded.
* @public
*/
authenticationComplete(payload) {
if (payload.authenticated) {
window.location.reload();
} else {
const modal = new SignUpModal(payload);
this.modal.show(modal);
modal.$('[name=password]').focus();
}
}
}

View File

@@ -1,21 +0,0 @@
import ForumApp from 'flarum/ForumApp';
import store from 'flarum/initializers/store';
import preload from 'flarum/initializers/preload';
import routes from 'flarum/initializers/routes';
import components from 'flarum/initializers/components';
import humanTime from 'flarum/initializers/humanTime';
import boot from 'flarum/initializers/boot';
import alertEmailConfirmation from 'flarum/initializers/alertEmailConfirmation';
const app = new ForumApp();
app.initializers.add('store', store);
app.initializers.add('routes', routes);
app.initializers.add('components', components);
app.initializers.add('humanTime', humanTime);
app.initializers.add('preload', preload, -100);
app.initializers.add('boot', boot, -100);
app.initializers.add('alertEmailConfirmation', alertEmailConfirmation, -100);
export default app;

View File

@@ -1,169 +0,0 @@
import Component from 'flarum/Component';
import avatar from 'flarum/helpers/avatar';
import icon from 'flarum/helpers/icon';
import listItems from 'flarum/helpers/listItems';
import ItemList from 'flarum/utils/ItemList';
import Button from 'flarum/components/Button';
import LoadingIndicator from 'flarum/components/LoadingIndicator';
/**
* The `AvatarEditor` component displays a user's avatar along with a dropdown
* menu which allows the user to upload/remove the avatar.
*
* ### Props
*
* - `className`
* - `user`
*/
export default class AvatarEditor extends Component {
init() {
/**
* Whether or not an avatar upload is in progress.
*
* @type {Boolean}
*/
this.loading = false;
}
static initProps(props) {
super.initProps(props);
props.className = props.className || '';
}
view() {
const user = this.props.user;
return (
<div className={'AvatarEditor Dropdown ' + this.props.className + (this.loading ? ' loading' : '')}>
{avatar(user)}
<a className={ user.avatarUrl() ? "Dropdown-toggle" : "Dropdown-toggle AvatarEditor--noAvatar" }
title={app.translator.trans('core.forum.user.avatar_upload_tooltip')}
data-toggle="dropdown"
onclick={this.quickUpload.bind(this)}>
{this.loading ? LoadingIndicator.component() : (user.avatarUrl() ? icon('pencil') : icon('plus-circle'))}
</a>
<ul className="Dropdown-menu Menu">
{listItems(this.controlItems().toArray())}
</ul>
</div>
);
}
/**
* Get the items in the edit avatar dropdown menu.
*
* @return {ItemList}
*/
controlItems() {
const items = new ItemList();
items.add('upload',
Button.component({
icon: 'upload',
children: app.translator.trans('core.forum.user.avatar_upload_button'),
onclick: this.upload.bind(this)
})
);
items.add('remove',
Button.component({
icon: 'times',
children: app.translator.trans('core.forum.user.avatar_remove_button'),
onclick: this.remove.bind(this)
})
);
return items;
}
/**
* If the user doesn't have an avatar, there's no point in showing the
* controls dropdown, because only one option would be viable: uploading.
* Thus, when the avatar editor's dropdown toggle button is clicked, we prompt
* the user to upload an avatar immediately.
*
* @param {Event} e
*/
quickUpload(e) {
if (!this.props.user.avatarUrl()) {
e.preventDefault();
e.stopPropagation();
this.upload();
}
}
/**
* Prompt the user to upload a new avatar.
*/
upload() {
if (this.loading) return;
// Create a hidden HTML input element and click on it so the user can select
// an avatar file. Once they have, we will upload it via the API.
const user = this.props.user;
const $input = $('<input type="file">');
$input.appendTo('body').hide().click().on('change', e => {
const data = new FormData();
data.append('avatar', $(e.target)[0].files[0]);
this.loading = true;
m.redraw();
app.request({
method: 'POST',
url: app.forum.attribute('apiUrl') + '/users/' + user.id() + '/avatar',
serialize: raw => raw,
data
}).then(
this.success.bind(this),
this.failure.bind(this)
);
});
}
/**
* Remove the user's avatar.
*/
remove() {
const user = this.props.user;
this.loading = true;
m.redraw();
app.request({
method: 'DELETE',
url: app.forum.attribute('apiUrl') + '/users/' + user.id() + '/avatar'
}).then(
this.success.bind(this),
this.failure.bind(this)
);
}
/**
* After a successful upload/removal, push the updated user data into the
* store, and force a recomputation of the user's avatar color.
*
* @param {Object} response
* @protected
*/
success(response) {
app.store.pushPayload(response);
delete this.props.user.avatarColor;
this.loading = false;
m.redraw();
}
/**
* If avatar upload/removal fails, stop loading.
*
* @param {Object} response
* @protected
*/
failure(response) {
this.loading = false;
m.redraw();
}
}

View File

@@ -1,116 +0,0 @@
import Modal from 'flarum/components/Modal';
import Button from 'flarum/components/Button';
/**
* The `ChangeEmailModal` component shows a modal dialog which allows the user
* to change their email address.
*/
export default class ChangeEmailModal extends Modal {
init() {
super.init();
/**
* Whether or not the email has been changed successfully.
*
* @type {Boolean}
*/
this.success = false;
/**
* The value of the email input.
*
* @type {function}
*/
this.email = m.prop(app.session.user.email());
/**
* The value of the password input.
*
* @type {function}
*/
this.password = m.prop('');
}
className() {
return 'ChangeEmailModal Modal--small';
}
title() {
return app.translator.trans('core.forum.change_email.title');
}
content() {
if (this.success) {
return (
<div className="Modal-body">
<div className="Form Form--centered">
<p className="helpText">{app.translator.trans('core.forum.change_email.confirmation_message', {email: <strong>{this.email()}</strong>})}</p>
<div className="Form-group">
<Button className="Button Button--primary Button--block" onclick={this.hide.bind(this)}>
{app.translator.trans('core.forum.change_email.dismiss_button')}
</Button>
</div>
</div>
</div>
);
}
return (
<div className="Modal-body">
<div className="Form Form--centered">
<div className="Form-group">
<input type="email" name="email" className="FormControl"
placeholder={app.session.user.email()}
bidi={this.email}
disabled={this.loading}/>
</div>
<div className="Form-group">
<input type="password" name="password" className="FormControl"
placeholder={app.translator.trans('core.forum.change_email.confirm_password_placeholder')}
bidi={this.password}
disabled={this.loading}/>
</div>
<div className="Form-group">
{Button.component({
className: 'Button Button--primary Button--block',
type: 'submit',
loading: this.loading,
children: app.translator.trans('core.forum.change_email.submit_button')
})}
</div>
</div>
</div>
);
}
onsubmit(e) {
e.preventDefault();
// If the user hasn't actually entered a different email address, we don't
// need to do anything. Woot!
if (this.email() === app.session.user.email()) {
this.hide();
return;
}
const oldEmail = app.session.user.email();
this.loading = true;
app.session.user.save({email: this.email()}, {
errorHandler: this.onerror.bind(this),
meta: {password: this.password()}
})
.then(() => this.success = true)
.catch(() => {})
.then(this.loaded.bind(this));
}
onerror(error) {
if (error.status === 401) {
error.alert.props.children = app.translator.trans('core.forum.change_email.incorrect_password_message');
}
super.onerror(error);
}
}

View File

@@ -1,49 +0,0 @@
import Modal from 'flarum/components/Modal';
import Button from 'flarum/components/Button';
/**
* The `ChangePasswordModal` component shows a modal dialog which allows the
* user to send themself a password reset email.
*/
export default class ChangePasswordModal extends Modal {
className() {
return 'ChangePasswordModal Modal--small';
}
title() {
return app.translator.trans('core.forum.change_password.title');
}
content() {
return (
<div className="Modal-body">
<div className="Form Form--centered">
<p className="helpText">{app.translator.trans('core.forum.change_password.text')}</p>
<div className="Form-group">
{Button.component({
className: 'Button Button--primary Button--block',
type: 'submit',
loading: this.loading,
children: app.translator.trans('core.forum.change_password.send_button')
})}
</div>
</div>
</div>
);
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
app.request({
method: 'POST',
url: app.forum.attribute('apiUrl') + '/forgot',
data: {email: app.session.user.email()}
}).then(
this.hide.bind(this),
this.loaded.bind(this)
);
}
}

View File

@@ -1,153 +0,0 @@
/*global s9e, hljs*/
import Post from 'flarum/components/Post';
import classList from 'flarum/utils/classList';
import PostUser from 'flarum/components/PostUser';
import PostMeta from 'flarum/components/PostMeta';
import PostEdited from 'flarum/components/PostEdited';
import EditPostComposer from 'flarum/components/EditPostComposer';
import ItemList from 'flarum/utils/ItemList';
import listItems from 'flarum/helpers/listItems';
import Button from 'flarum/components/Button';
/**
* The `CommentPost` component displays a standard `comment`-typed post. This
* includes a number of item lists (controls, header, and footer) surrounding
* the post's HTML content.
*
* ### Props
*
* - `post`
*/
export default class CommentPost extends Post {
init() {
super.init();
/**
* If the post has been hidden, then this flag determines whether or not its
* content has been expanded.
*
* @type {Boolean}
*/
this.revealContent = false;
// Create an instance of the component that displays the post's author so
// that we can force the post to rerender when the user card is shown.
this.postUser = new PostUser({post: this.props.post});
this.subtree.check(
() => this.postUser.cardVisible,
() => this.isEditing()
);
}
content() {
// Note: we avoid using JSX for the <ul> below because it results in some
// weirdness in Mithril.js 0.1.x (see flarum/core#975). This workaround can
// be reverted when we upgrade to Mithril 1.0.
return super.content().concat([
<header className="Post-header">{m('ul', listItems(this.headerItems().toArray()))}</header>,
<div className="Post-body">
{this.isEditing()
? <div className="Post-preview" config={this.configPreview.bind(this)}/>
: m.trust(this.props.post.contentHtml())}
</div>
]);
}
config(isInitialized, context) {
super.config(...arguments);
const contentHtml = this.isEditing() ? '' : this.props.post.contentHtml();
// If the post content has changed since the last render, we'll run through
// all of the <script> tags in the content and evaluate them. This is
// necessary because TextFormatter outputs them for e.g. syntax highlighting.
if (context.contentHtml !== contentHtml) {
this.$('.Post-body script').each(function() {
eval.call(window, $(this).text());
});
}
context.contentHtml = contentHtml;
}
isEditing() {
return app.composer.component instanceof EditPostComposer &&
app.composer.component.props.post === this.props.post;
}
attrs() {
const post = this.props.post;
const attrs = super.attrs();
attrs.className += ' '+classList({
'CommentPost': true,
'Post--hidden': post.isHidden(),
'Post--edited': post.isEdited(),
'revealContent': this.revealContent,
'editing': this.isEditing()
});
return attrs;
}
configPreview(element, isInitialized, context) {
if (isInitialized) return;
// Every 50ms, if the composer content has changed, then update the post's
// body with a preview.
let preview;
const updatePreview = () => {
const content = app.composer.component.content();
if (preview === content) return;
preview = content;
s9e.TextFormatter.preview(preview || '', element);
};
updatePreview();
const updateInterval = setInterval(updatePreview, 50);
context.onunload = () => clearInterval(updateInterval);
}
/**
* Toggle the visibility of a hidden post's content.
*/
toggleContent() {
this.revealContent = !this.revealContent;
}
/**
* Build an item list for the post's header.
*
* @return {ItemList}
*/
headerItems() {
const items = new ItemList();
const post = this.props.post;
const props = {post};
items.add('user', this.postUser.render(), 100);
items.add('meta', PostMeta.component(props));
if (post.isEdited() && !post.isHidden()) {
items.add('edited', PostEdited.component(props));
}
// If the post is hidden, add a button that allows toggling the visibility
// of the post's content.
if (post.isHidden()) {
items.add('toggle', (
Button.component({
className: 'Button Button--default Button--more',
icon: 'ellipsis-h',
onclick: this.toggleContent.bind(this)
})
));
}
return items;
}
}

View File

@@ -1,494 +0,0 @@
import Component from 'flarum/Component';
import ItemList from 'flarum/utils/ItemList';
import ComposerButton from 'flarum/components/ComposerButton';
import listItems from 'flarum/helpers/listItems';
import classList from 'flarum/utils/classList';
import computed from 'flarum/utils/computed';
/**
* The `Composer` component displays the composer. It can be loaded with a
* content component with `load` and then its position/state can be altered with
* `show`, `hide`, `close`, `minimize`, `fullScreen`, and `exitFullScreen`.
*/
class Composer extends Component {
init() {
/**
* The composer's current position.
*
* @type {Composer.PositionEnum}
*/
this.position = Composer.PositionEnum.HIDDEN;
/**
* The composer's intended height, which can be modified by the user
* (by dragging the composer handle).
*
* @type {Integer}
*/
this.height = null;
/**
* Whether or not the composer currently has focus.
*
* @type {Boolean}
*/
this.active = false;
/**
* Computed the composer's current height, based on the intended height, and
* the composer's current state. This will be applied to the composer's
* content's DOM element.
*
* @return {Integer}
*/
this.computedHeight = computed('height', 'position', (height, position) => {
// If the composer is minimized, then we don't want to set a height; we'll
// let the CSS decide how high it is. If it's fullscreen, then we need to
// make it as high as the window.
if (position === Composer.PositionEnum.MINIMIZED) {
return '';
} else if (position === Composer.PositionEnum.FULLSCREEN) {
return $(window).height();
}
// Otherwise, if it's normal or hidden, then we use the intended height.
// We don't let the composer get too small or too big, though.
return Math.max(200, Math.min(height, $(window).height() - $('#header').outerHeight()));
});
}
view() {
const classes = {
'normal': this.position === Composer.PositionEnum.NORMAL,
'minimized': this.position === Composer.PositionEnum.MINIMIZED,
'fullScreen': this.position === Composer.PositionEnum.FULLSCREEN,
'active': this.active
};
classes.visible = classes.normal || classes.minimized || classes.fullScreen;
// If the composer is minimized, tell the composer's content component that
// it shouldn't let the user interact with it. Set up a handler so that if
// the content IS clicked, the composer will be shown.
if (this.component) this.component.props.disabled = classes.minimized;
const showIfMinimized = this.position === Composer.PositionEnum.MINIMIZED ? this.show.bind(this) : undefined;
return (
<div className={'Composer ' + classList(classes)}>
<div className="Composer-handle" config={this.configHandle.bind(this)}/>
<ul className="Composer-controls">{listItems(this.controlItems().toArray())}</ul>
<div className="Composer-content" onclick={showIfMinimized}>
{this.component ? this.component.render() : ''}
</div>
</div>
);
}
config(isInitialized, context) {
let defaultHeight;
if (!isInitialized) {
defaultHeight = this.$().height();
}
if (isInitialized) return;
// Since this component is a part of the global UI that persists between
// routes, we will flag the DOM to be retained across route changes.
context.retain = true;
// Initialize the composer's intended height based on what the user has set
// it at previously, or otherwise the composer's default height. After that,
// we'll hide the composer.
this.height = localStorage.getItem('composerHeight') || defaultHeight;
this.$().hide().css('bottom', -this.height);
// Whenever any of the inputs inside the composer are have focus, we want to
// add a class to the composer to draw attention to it.
this.$().on('focus blur', ':input', e => {
this.active = e.type === 'focusin';
m.redraw();
});
// When the escape key is pressed on any inputs, close the composer.
this.$().on('keydown', ':input', 'esc', () => this.close());
// Don't let the user leave the page without first giving the composer's
// component a chance to scream at the user to make sure they don't
// unintentionally lose any contnet.
window.onbeforeunload = () => {
return (this.component && this.component.preventExit()) || undefined;
};
const handlers = {};
$(window).on('resize', handlers.onresize = this.updateHeight.bind(this)).resize();
$(document)
.on('mousemove', handlers.onmousemove = this.onmousemove.bind(this))
.on('mouseup', handlers.onmouseup = this.onmouseup.bind(this));
context.onunload = () => {
$(window).off('resize', handlers.onresize);
$(document)
.off('mousemove', handlers.onmousemove)
.off('mouseup', handlers.onmouseup);
};
}
/**
* Add the necessary event handlers to the composer's handle so that it can
* be used to resize the composer.
*
* @param {DOMElement} element
* @param {Boolean} isInitialized
*/
configHandle(element, isInitialized) {
if (isInitialized) return;
const composer = this;
$(element).css('cursor', 'row-resize')
.bind('dragstart mousedown', e => e.preventDefault())
.mousedown(function(e) {
composer.mouseStart = e.clientY;
composer.heightStart = composer.$().height();
composer.handle = $(this);
$('body').css('cursor', 'row-resize');
});
}
/**
* Resize the composer according to mouse movement.
*
* @param {Event} e
*/
onmousemove(e) {
if (!this.handle) return;
// Work out how much the mouse has been moved, and set the height
// relative to the old one based on that. Then update the content's
// height so that it fills the height of the composer, and update the
// body's padding.
const deltaPixels = this.mouseStart - e.clientY;
this.height = this.heightStart + deltaPixels;
this.updateHeight();
// Update the body's padding-bottom so that no content on the page will ever
// get permanently hidden behind the composer. If the user is already
// scrolled to the bottom of the page, then we will keep them scrolled to
// the bottom after the padding has been updated.
const scrollTop = $(window).scrollTop();
const anchorToBottom = scrollTop > 0 && scrollTop + $(window).height() >= $(document).height();
this.updateBodyPadding(anchorToBottom);
localStorage.setItem('composerHeight', this.height);
}
/**
* Finish resizing the composer when the mouse is released.
*/
onmouseup() {
if (!this.handle) return;
this.handle = null;
$('body').css('cursor', '');
}
/**
* Update the DOM to reflect the composer's current height. This involves
* setting the height of the composer's root element, and adjusting the height
* of any flexible elements inside the composer's body.
*/
updateHeight() {
const height = this.computedHeight();
const $flexible = this.$('.Composer-flexible');
this.$().height(height);
if ($flexible.length) {
const headerHeight = $flexible.offset().top - this.$().offset().top;
const paddingBottom = parseInt($flexible.css('padding-bottom'), 10);
const footerHeight = this.$('.Composer-footer').outerHeight(true);
$flexible.height(this.$().outerHeight() - headerHeight - paddingBottom - footerHeight);
}
}
/**
* Update the amount of padding-bottom on the body so that the page's
* content will still be visible above the composer when the page is
* scrolled right to the bottom.
*/
updateBodyPadding() {
const visible = this.position !== Composer.PositionEnum.HIDDEN &&
this.position !== Composer.PositionEnum.MINIMIZED &&
this.$().css('position') !== 'absolute';
const paddingBottom = visible
? this.computedHeight() - parseInt($('#app').css('padding-bottom'), 10)
: 0;
$('#content').css({paddingBottom});
}
/**
* Determine whether or not the Composer is covering the screen.
*
* This will be true if the Composer is in full-screen mode on desktop, or
* if the Composer is positioned absolutely as on mobile devices.
*
* @return {Boolean}
* @public
*/
isFullScreen() {
return this.position === Composer.PositionEnum.FULLSCREEN || this.$().css('position') === 'absolute';
}
/**
* Confirm with the user that they want to close the composer and lose their
* content.
*
* @return {Boolean} Whether or not the exit was cancelled.
*/
preventExit() {
if (this.component) {
const preventExit = this.component.preventExit();
if (preventExit) {
return !confirm(preventExit);
}
}
}
/**
* Load a content component into the composer.
*
* @param {Component} component
* @public
*/
load(component) {
if (this.preventExit()) return;
// If we load a similar component into the composer, then Mithril will be
// able to diff the old/new contents and some DOM-related state from the
// old composer will remain. To prevent this from happening, we clear the
// component and force a redraw, so that the new component will be working
// on a blank slate.
if (this.component) {
this.clear();
m.redraw(true);
}
this.component = component;
}
/**
* Clear the composer's content component.
*
* @public
*/
clear() {
this.component = null;
}
/**
* Animate the Composer into the given position.
*
* @param {Composer.PositionEnum} position
*/
animateToPosition(position) {
// Before we redraw the composer to its new state, we need to save the
// current height of the composer, as well as the page's scroll position, so
// that we can smoothly transition from the old to the new state.
const oldPosition = this.position;
const $composer = this.$().stop(true);
const oldHeight = $composer.outerHeight();
const scrollTop = $(window).scrollTop();
this.position = position;
m.redraw(true);
// Now that we've redrawn and the composer's DOM has been updated, we want
// to update the composer's height. Once we've done that, we'll capture the
// real value to use as the end point for our animation later on.
$composer.show();
this.updateHeight();
const newHeight = $composer.outerHeight();
if (oldPosition === Composer.PositionEnum.HIDDEN) {
$composer.css({bottom: -newHeight, height: newHeight});
} else {
$composer.css({height: oldHeight});
}
$composer.animate({bottom: 0, height: newHeight}, 'fast', () => this.component.focus());
this.updateBodyPadding();
$(window).scrollTop(scrollTop);
}
/**
* Show the Composer backdrop.
*/
showBackdrop() {
this.$backdrop = $('<div/>')
.addClass('composer-backdrop')
.appendTo('body');
}
/**
* Hide the Composer backdrop.
*/
hideBackdrop() {
if (this.$backdrop) this.$backdrop.remove();
}
/**
* Show the composer.
*
* @public
*/
show() {
if (this.position === Composer.PositionEnum.NORMAL || this.position === Composer.PositionEnum.FULLSCREEN) {
return;
}
this.animateToPosition(Composer.PositionEnum.NORMAL);
if (this.isFullScreen()) {
this.$().css('top', $(window).scrollTop());
this.showBackdrop();
this.component.focus();
}
}
/**
* Close the composer.
*
* @public
*/
hide() {
const $composer = this.$();
// Animate the composer sliding down off the bottom edge of the viewport.
// Only when the animation is completed, update the Composer state flag and
// other elements on the page.
$composer.stop(true).animate({bottom: -$composer.height()}, 'fast', () => {
this.position = Composer.PositionEnum.HIDDEN;
this.clear();
m.redraw();
$composer.hide();
this.hideBackdrop();
this.updateBodyPadding();
});
}
/**
* Confirm with the user so they don't lose their content, then close the
* composer.
*
* @public
*/
close() {
if (!this.preventExit()) {
this.hide();
}
}
/**
* Minimize the composer. Has no effect if the composer is hidden.
*
* @public
*/
minimize() {
if (this.position === Composer.PositionEnum.HIDDEN) return;
this.animateToPosition(Composer.PositionEnum.MINIMIZED);
this.$().css('top', 'auto');
this.hideBackdrop();
}
/**
* Take the composer into fullscreen mode. Has no effect if the composer is
* hidden.
*
* @public
*/
fullScreen() {
if (this.position !== Composer.PositionEnum.HIDDEN) {
this.position = Composer.PositionEnum.FULLSCREEN;
m.redraw();
this.updateHeight();
this.component.focus();
}
}
/**
* Exit fullscreen mode.
*
* @public
*/
exitFullScreen() {
if (this.position === Composer.PositionEnum.FULLSCREEN) {
this.position = Composer.PositionEnum.NORMAL;
m.redraw();
this.updateHeight();
this.component.focus();
}
}
/**
* Build an item list for the composer's controls.
*
* @return {ItemList}
*/
controlItems() {
const items = new ItemList();
if (this.position === Composer.PositionEnum.FULLSCREEN) {
items.add('exitFullScreen', ComposerButton.component({
icon: 'compress',
title: app.translator.trans('core.forum.composer.exit_full_screen_tooltip'),
onclick: this.exitFullScreen.bind(this)
}));
} else {
if (this.position !== Composer.PositionEnum.MINIMIZED) {
items.add('minimize', ComposerButton.component({
icon: 'minus minimize',
title: app.translator.trans('core.forum.composer.minimize_tooltip'),
onclick: this.minimize.bind(this),
itemClassName: 'App-backControl'
}));
items.add('fullScreen', ComposerButton.component({
icon: 'expand',
title: app.translator.trans('core.forum.composer.full_screen_tooltip'),
onclick: this.fullScreen.bind(this)
}));
}
items.add('close', ComposerButton.component({
icon: 'times',
title: app.translator.trans('core.forum.composer.close_tooltip'),
onclick: this.close.bind(this)
}));
}
return items;
}
}
Composer.PositionEnum = {
HIDDEN: 'hidden',
NORMAL: 'normal',
MINIMIZED: 'minimized',
FULLSCREEN: 'fullScreen'
};
export default Composer;

View File

@@ -1,113 +0,0 @@
import Component from 'flarum/Component';
import LoadingIndicator from 'flarum/components/LoadingIndicator';
import TextEditor from 'flarum/components/TextEditor';
import avatar from 'flarum/helpers/avatar';
import listItems from 'flarum/helpers/listItems';
import ItemList from 'flarum/utils/ItemList';
/**
* The `ComposerBody` component handles the body, or the content, of the
* composer. Subclasses should implement the `onsubmit` method and override
* `headerTimes`.
*
* ### Props
*
* - `originalContent`
* - `submitLabel`
* - `placeholder`
* - `user`
* - `confirmExit`
* - `disabled`
*
* @abstract
*/
export default class ComposerBody extends Component {
init() {
/**
* Whether or not the component is loading.
*
* @type {Boolean}
*/
this.loading = false;
/**
* The content of the text editor.
*
* @type {Function}
*/
this.content = m.prop(this.props.originalContent);
/**
* The text editor component instance.
*
* @type {TextEditor}
*/
this.editor = new TextEditor({
submitLabel: this.props.submitLabel,
placeholder: this.props.placeholder,
onchange: this.content,
onsubmit: this.onsubmit.bind(this),
value: this.content()
});
}
view() {
// If the component is loading, we should disable the text editor.
this.editor.props.disabled = this.loading;
return (
<div className={'ComposerBody ' + (this.props.className || '')}>
{avatar(this.props.user, {className: 'ComposerBody-avatar'})}
<div className="ComposerBody-content">
<ul className="ComposerBody-header">{listItems(this.headerItems().toArray())}</ul>
<div className="ComposerBody-editor">{this.editor.render()}</div>
</div>
{LoadingIndicator.component({className: 'ComposerBody-loading' + (this.loading ? ' active' : '')})}
</div>
);
}
/**
* Draw focus to the text editor.
*/
focus() {
this.$(':input:enabled:visible:first').focus();
}
/**
* Check if there is any unsaved data if there is, return a confirmation
* message to prompt the user with.
*
* @return {String}
*/
preventExit() {
const content = this.content();
return content && content !== this.props.originalContent && this.props.confirmExit;
}
/**
* Build an item list for the composer's header.
*
* @return {ItemList}
*/
headerItems() {
return new ItemList();
}
/**
* Handle the submit event of the text editor.
*
* @abstract
*/
onsubmit() {
}
/**
* Stop loading.
*/
loaded() {
this.loading = false;
m.redraw();
}
}

View File

@@ -1,13 +0,0 @@
import Button from 'flarum/components/Button';
/**
* The `ComposerButton` component displays a button suitable for the composer
* controls.
*/
export default class ComposerButton extends Button {
static initProps(props) {
super.initProps(props);
props.className = props.className || 'Button Button--icon Button--link';
}
}

View File

@@ -1,101 +0,0 @@
import ComposerBody from 'flarum/components/ComposerBody';
import extractText from 'flarum/utils/extractText';
/**
* The `DiscussionComposer` component displays the composer content for starting
* a new discussion. It adds a text field as a header control so the user can
* enter the title of their discussion. It also overrides the `submit` and
* `willExit` actions to account for the title.
*
* ### Props
*
* - All of the props for ComposerBody
* - `titlePlaceholder`
*/
export default class DiscussionComposer extends ComposerBody {
init() {
super.init();
/**
* The value of the title input.
*
* @type {Function}
*/
this.title = m.prop('');
}
static initProps(props) {
super.initProps(props);
props.placeholder = props.placeholder || extractText(app.translator.trans('core.forum.composer_discussion.body_placeholder'));
props.submitLabel = props.submitLabel || app.translator.trans('core.forum.composer_discussion.submit_button');
props.confirmExit = props.confirmExit || extractText(app.translator.trans('core.forum.composer_discussion.discard_confirmation'));
props.titlePlaceholder = props.titlePlaceholder || extractText(app.translator.trans('core.forum.composer_discussion.title_placeholder'));
props.className = 'ComposerBody--discussion';
}
headerItems() {
const items = super.headerItems();
items.add('title', <h3>{app.translator.trans('core.forum.composer_discussion.title')}</h3>, 100);
items.add('discussionTitle', (
<h3>
<input className="FormControl"
value={this.title()}
oninput={m.withAttr('value', this.title)}
placeholder={this.props.titlePlaceholder}
disabled={!!this.props.disabled}
onkeydown={this.onkeydown.bind(this)}/>
</h3>
));
return items;
}
/**
* Handle the title input's keydown event. When the return key is pressed,
* move the focus to the start of the text editor.
*
* @param {Event} e
*/
onkeydown(e) {
if (e.which === 13) { // Return
e.preventDefault();
this.editor.setSelectionRange(0, 0);
}
m.redraw.strategy('none');
}
preventExit() {
return (this.title() || this.content()) && this.props.confirmExit;
}
/**
* Get the data to submit to the server when the discussion is saved.
*
* @return {Object}
*/
data() {
return {
title: this.title(),
content: this.content()
};
}
onsubmit() {
this.loading = true;
const data = this.data();
app.store.createRecord('discussions').save(data).then(
discussion => {
app.composer.hide();
app.cache.discussionList.addDiscussion(discussion);
m.route(app.route.discussion(discussion));
},
this.loaded.bind(this)
);
}
}

View File

@@ -1,41 +0,0 @@
import Component from 'flarum/Component';
import ItemList from 'flarum/utils/ItemList';
import listItems from 'flarum/helpers/listItems';
/**
* The `DiscussionHero` component displays the hero on a discussion page.
*
* ### Props
*
* - `discussion`
*/
export default class DiscussionHero extends Component {
view() {
return (
<header className="Hero DiscussionHero">
<div className="container">
<ul className="DiscussionHero-items">{listItems(this.items().toArray())}</ul>
</div>
</header>
);
}
/**
* Build an item list for the contents of the discussion hero.
*
* @return {ItemList}
*/
items() {
const items = new ItemList();
const discussion = this.props.discussion;
const badges = discussion.badges().toArray();
if (badges.length) {
items.add('badges', <ul className="DiscussionHero-badges badges">{listItems(badges)}</ul>, 10);
}
items.add('title', <h2 className="DiscussionHero-title">{discussion.title()}</h2>);
return items;
}
}

View File

@@ -1,218 +0,0 @@
import Component from 'flarum/Component';
import DiscussionListItem from 'flarum/components/DiscussionListItem';
import Button from 'flarum/components/Button';
import LoadingIndicator from 'flarum/components/LoadingIndicator';
import Placeholder from 'flarum/components/Placeholder';
/**
* The `DiscussionList` component displays a list of discussions.
*
* ### Props
*
* - `params` A map of parameters used to construct a refined parameter object
* to send along in the API request to get discussion results.
*/
export default class DiscussionList extends Component {
init() {
/**
* Whether or not discussion results are loading.
*
* @type {Boolean}
*/
this.loading = true;
/**
* Whether or not there are more results that can be loaded.
*
* @type {Boolean}
*/
this.moreResults = false;
/**
* The discussions in the discussion list.
*
* @type {Discussion[]}
*/
this.discussions = [];
this.refresh();
}
view() {
const params = this.props.params;
let loading;
if (this.loading) {
loading = LoadingIndicator.component();
} else if (this.moreResults) {
loading = Button.component({
children: app.translator.trans('core.forum.discussion_list.load_more_button'),
className: 'Button',
onclick: this.loadMore.bind(this)
});
}
if (this.discussions.length === 0 && !this.loading) {
const text = app.translator.trans('core.forum.discussion_list.empty_text');
return (
<div className="DiscussionList">
{Placeholder.component({text})}
</div>
);
}
return (
<div className="DiscussionList">
<ul className="DiscussionList-discussions">
{this.discussions.map(discussion => {
return (
<li key={discussion.id()} data-id={discussion.id()}>
{DiscussionListItem.component({discussion, params})}
</li>
);
})}
</ul>
<div className="DiscussionList-loadMore">
{loading}
</div>
</div>
);
}
/**
* Get the parameters that should be passed in the API request to get
* discussion results.
*
* @return {Object}
* @api
*/
requestParams() {
const params = {include: ['startUser', 'lastUser'], filter: {}};
params.sort = this.sortMap()[this.props.params.sort];
if (this.props.params.q) {
params.filter.q = this.props.params.q;
params.include.push('relevantPosts', 'relevantPosts.discussion', 'relevantPosts.user');
}
return params;
}
/**
* Get a map of sort keys (which appear in the URL, and are used for
* translation) to the API sort value that they represent.
*
* @return {Object}
*/
sortMap() {
const map = {};
if (this.props.params.q) {
map.relevance = '';
}
map.latest = '-lastTime';
map.top = '-commentsCount';
map.newest = '-startTime';
map.oldest = 'startTime';
return map;
}
/**
* Clear and reload the discussion list.
*
* @public
*/
refresh(clear = true) {
if (clear) {
this.loading = true;
this.discussions = [];
}
return this.loadResults().then(
results => {
this.discussions = [];
this.parseResults(results);
},
() => {
this.loading = false;
m.redraw();
}
);
}
/**
* Load a new page of discussion results.
*
* @param {Integer} offset The index to start the page at.
* @return {Promise}
*/
loadResults(offset) {
const preloadedDiscussions = app.preloadedDocument();
if (preloadedDiscussions) {
return m.deferred().resolve(preloadedDiscussions).promise;
}
const params = this.requestParams();
params.page = {offset};
params.include = params.include.join(',');
return app.store.find('discussions', params);
}
/**
* Load the next page of discussion results.
*
* @public
*/
loadMore() {
this.loading = true;
this.loadResults(this.discussions.length)
.then(this.parseResults.bind(this));
}
/**
* Parse results and append them to the discussion list.
*
* @param {Discussion[]} results
* @return {Discussion[]}
*/
parseResults(results) {
[].push.apply(this.discussions, results);
this.loading = false;
this.moreResults = !!results.payload.links.next;
m.lazyRedraw();
return results;
}
/**
* Remove a discussion from the list if it is present.
*
* @param {Discussion} discussion
* @public
*/
removeDiscussion(discussion) {
const index = this.discussions.indexOf(discussion);
if (index !== -1) {
this.discussions.splice(index, 1);
}
}
/**
* Add a discussion to the top of the list.
*
* @param {Discussion} discussion
* @public
*/
addDiscussion(discussion) {
this.discussions.unshift(discussion);
}
}

View File

@@ -1,200 +0,0 @@
import Component from 'flarum/Component';
import avatar from 'flarum/helpers/avatar';
import listItems from 'flarum/helpers/listItems';
import highlight from 'flarum/helpers/highlight';
import icon from 'flarum/helpers/icon';
import humanTime from 'flarum/utils/humanTime';
import ItemList from 'flarum/utils/ItemList';
import abbreviateNumber from 'flarum/utils/abbreviateNumber';
import Dropdown from 'flarum/components/Dropdown';
import TerminalPost from 'flarum/components/TerminalPost';
import PostPreview from 'flarum/components/PostPreview';
import SubtreeRetainer from 'flarum/utils/SubtreeRetainer';
import DiscussionControls from 'flarum/utils/DiscussionControls';
import slidable from 'flarum/utils/slidable';
import extractText from 'flarum/utils/extractText';
import classList from 'flarum/utils/classList';
/**
* The `DiscussionListItem` component shows a single discussion in the
* discussion list.
*
* ### Props
*
* - `discussion`
* - `params`
*/
export default class DiscussionListItem extends Component {
init() {
/**
* Set up a subtree retainer so that the discussion will not be redrawn
* unless new data comes in.
*
* @type {SubtreeRetainer}
*/
this.subtree = new SubtreeRetainer(
() => this.props.discussion.freshness,
() => {
const time = app.session.user && app.session.user.readTime();
return time && time.getTime();
},
() => this.active()
);
}
attrs() {
return {
className: classList([
'DiscussionListItem',
this.active() ? 'active' : '',
this.props.discussion.isHidden() ? 'DiscussionListItem--hidden' : ''
])
};
}
view() {
const retain = this.subtree.retain();
if (retain) return retain;
const discussion = this.props.discussion;
const startUser = discussion.startUser();
const isUnread = discussion.isUnread();
const isRead = discussion.isRead();
const showUnread = !this.showRepliesCount() && isUnread;
const jumpTo = Math.min(discussion.lastPostNumber(), (discussion.readNumber() || 0) + 1);
const relevantPosts = this.props.params.q ? discussion.relevantPosts() : [];
const controls = DiscussionControls.controls(discussion, this).toArray();
const attrs = this.attrs();
return (
<div {...attrs}>
{controls.length ? Dropdown.component({
icon: 'ellipsis-v',
children: controls,
className: 'DiscussionListItem-controls',
buttonClassName: 'Button Button--icon Button--flat Slidable-underneath Slidable-underneath--right'
}) : ''}
<a className={'Slidable-underneath Slidable-underneath--left Slidable-underneath--elastic' + (isUnread ? '' : ' disabled')}
onclick={this.markAsRead.bind(this)}>
{icon('check')}
</a>
<div className={'DiscussionListItem-content Slidable-content' + (isUnread ? ' unread' : '') + (isRead ? ' read' : '')}>
<a href={startUser ? app.route.user(startUser) : '#'}
className="DiscussionListItem-author"
title={extractText(app.translator.trans('core.forum.discussion_list.started_text', {user: startUser, ago: humanTime(discussion.startTime())}))}
config={function(element) {
$(element).tooltip({placement: 'right'});
m.route.apply(this, arguments);
}}>
{avatar(startUser, {title: ''})}
</a>
<ul className="DiscussionListItem-badges badges">
{listItems(discussion.badges().toArray())}
</ul>
<a href={app.route.discussion(discussion, jumpTo)}
config={m.route}
className="DiscussionListItem-main">
<h3 className="DiscussionListItem-title">{highlight(discussion.title(), this.props.params.q)}</h3>
<ul className="DiscussionListItem-info">{listItems(this.infoItems().toArray())}</ul>
</a>
<span className="DiscussionListItem-count"
onclick={this.markAsRead.bind(this)}
title={showUnread ? app.translator.trans('core.forum.discussion_list.mark_as_read_tooltip') : ''}>
{abbreviateNumber(discussion[showUnread ? 'unreadCount' : 'repliesCount']())}
</span>
{relevantPosts && relevantPosts.length
? <div className="DiscussionListItem-relevantPosts">
{relevantPosts.map(post => PostPreview.component({post, highlight: this.props.params.q}))}
</div>
: ''}
</div>
</div>
);
}
config(isInitialized) {
if (isInitialized) return;
// If we're on a touch device, set up the discussion row to be slidable.
// This allows the user to drag the row to either side of the screen to
// reveal controls.
if ('ontouchstart' in window) {
const slidableInstance = slidable(this.$().addClass('Slidable'));
this.$('.DiscussionListItem-controls')
.on('hidden.bs.dropdown', () => slidableInstance.reset());
}
}
/**
* Determine whether or not the discussion is currently being viewed.
*
* @return {Boolean}
*/
active() {
const idParam = m.route.param('id');
return idParam && idParam.split('-')[0] === this.props.discussion.id();
}
/**
* Determine whether or not information about who started the discussion
* should be displayed instead of information about the most recent reply to
* the discussion.
*
* @return {Boolean}
*/
showStartPost() {
return ['newest', 'oldest'].indexOf(this.props.params.sort) !== -1;
}
/**
* Determine whether or not the number of replies should be shown instead of
* the number of unread posts.
*
* @return {Boolean}
*/
showRepliesCount() {
return this.props.params.sort === 'replies';
}
/**
* Mark the discussion as read.
*/
markAsRead() {
const discussion = this.props.discussion;
if (discussion.isUnread()) {
discussion.save({readNumber: discussion.lastPostNumber()});
m.redraw();
}
}
/**
* Build an item list of info for a discussion listing. By default this is
* just the first/last post indicator.
*
* @return {ItemList}
*/
infoItems() {
const items = new ItemList();
items.add('terminalPost',
TerminalPost.component({
discussion: this.props.discussion,
lastPost: !this.showStartPost()
})
);
return items;
}
}

View File

@@ -1,286 +0,0 @@
import Page from 'flarum/components/Page';
import ItemList from 'flarum/utils/ItemList';
import DiscussionHero from 'flarum/components/DiscussionHero';
import PostStream from 'flarum/components/PostStream';
import PostStreamScrubber from 'flarum/components/PostStreamScrubber';
import LoadingIndicator from 'flarum/components/LoadingIndicator';
import SplitDropdown from 'flarum/components/SplitDropdown';
import listItems from 'flarum/helpers/listItems';
import DiscussionControls from 'flarum/utils/DiscussionControls';
/**
* The `DiscussionPage` component displays a whole discussion page, including
* the discussion list pane, the hero, the posts, and the sidebar.
*/
export default class DiscussionPage extends Page {
init() {
super.init();
/**
* The discussion that is being viewed.
*
* @type {Discussion}
*/
this.discussion = null;
/**
* The number of the first post that is currently visible in the viewport.
*
* @type {Integer}
*/
this.near = null;
this.refresh();
// If the discussion list has been loaded, then we'll enable the pane (and
// hide it by default). Also, if we've just come from another discussion
// page, then we don't want Mithril to redraw the whole page if it did,
// then the pane would which would be slow and would cause problems with
// event handlers.
if (app.cache.discussionList) {
app.pane.enable();
app.pane.hide();
if (app.previous instanceof DiscussionPage) {
m.redraw.strategy('diff');
}
}
app.history.push('discussion');
this.bodyClass = 'App--discussion';
}
onunload(e) {
// If we have routed to the same discussion as we were viewing previously,
// cancel the unloading of this controller and instead prompt the post
// stream to jump to the new 'near' param.
if (this.discussion) {
const idParam = m.route.param('id');
if (idParam && idParam.split('-')[0] === this.discussion.id()) {
e.preventDefault();
const near = m.route.param('near') || '1';
if (near !== String(this.near)) {
this.stream.goToNumber(near);
}
this.near = null;
return;
}
}
// If we are indeed navigating away from this discussion, then disable the
// discussion list pane. Also, if we're composing a reply to this
// discussion, minimize the composer unless it's empty, in which case
// we'll just close it.
app.pane.disable();
if (app.composingReplyTo(this.discussion) && !app.composer.component.content()) {
app.composer.hide();
} else {
app.composer.minimize();
}
}
view() {
const discussion = this.discussion;
return (
<div className="DiscussionPage">
{app.cache.discussionList
? <div className="DiscussionPage-list" config={this.configPane.bind(this)}>
{!$('.App-navigation').is(':visible') ? app.cache.discussionList.render() : ''}
</div>
: ''}
<div className="DiscussionPage-discussion">
{discussion
? [
DiscussionHero.component({discussion}),
<div className="container">
<nav className="DiscussionPage-nav">
<ul>{listItems(this.sidebarItems().toArray())}</ul>
</nav>
<div className="DiscussionPage-stream">
{this.stream.render()}
</div>
</div>
]
: LoadingIndicator.component({className: 'LoadingIndicator--block'})}
</div>
</div>
);
}
/**
* Clear and reload the discussion.
*/
refresh() {
this.near = m.route.param('near') || 0;
this.discussion = null;
const preloadedDiscussion = app.preloadedDocument();
if (preloadedDiscussion) {
// We must wrap this in a setTimeout because if we are mounting this
// component for the first time on page load, then any calls to m.redraw
// will be ineffective and thus any configs (scroll code) will be run
// before stuff is drawn to the page.
setTimeout(this.show.bind(this, preloadedDiscussion), 0);
} else {
const params = this.requestParams();
app.store.find('discussions', m.route.param('id').split('-')[0], params)
.then(this.show.bind(this));
}
m.lazyRedraw();
}
/**
* Get the parameters that should be passed in the API request to get the
* discussion.
*
* @return {Object}
*/
requestParams() {
return {
page: {near: this.near}
};
}
/**
* Initialize the component to display the given discussion.
*
* @param {Discussion} discussion
*/
show(discussion) {
this.discussion = discussion;
app.history.push('discussion', discussion.title());
app.setTitle(discussion.title());
app.setTitleCount(0);
// When the API responds with a discussion, it will also include a number of
// posts. Some of these posts are included because they are on the first
// page of posts we want to display (determined by the `near` parameter)
// others may be included because due to other relationships introduced by
// extensions. We need to distinguish the two so we don't end up displaying
// the wrong posts. We do so by filtering out the posts that don't have
// the 'discussion' relationship linked, then sorting and splicing.
let includedPosts = [];
if (discussion.payload && discussion.payload.included) {
includedPosts = discussion.payload.included
.filter(record => record.type === 'posts' && record.relationships && record.relationships.discussion)
.map(record => app.store.getById('posts', record.id))
.sort((a, b) => a.id() - b.id())
.slice(0, 20);
}
// Set up the post stream for this discussion, along with the first page of
// posts we want to display. Tell the stream to scroll down and highlight
// the specific post that was routed to.
this.stream = new PostStream({discussion, includedPosts});
this.stream.on('positionChanged', this.positionChanged.bind(this));
this.stream.goToNumber(m.route.param('near') || (includedPosts[0] && includedPosts[0].number()), true);
}
/**
* Configure the discussion list pane.
*
* @param {DOMElement} element
* @param {Boolean} isInitialized
* @param {Object} context
*/
configPane(element, isInitialized, context) {
if (isInitialized) return;
context.retain = true;
const $list = $(element);
// When the mouse enters and leaves the discussions pane, we want to show
// and hide the pane respectively. We also create a 10px 'hot edge' on the
// left of the screen to activate the pane.
const pane = app.pane;
$list.hover(pane.show.bind(pane), pane.onmouseleave.bind(pane));
const hotEdge = e => {
if (e.pageX < 10) pane.show();
};
$(document).on('mousemove', hotEdge);
context.onunload = () => $(document).off('mousemove', hotEdge);
// If the discussion we are viewing is listed in the discussion list, then
// we will make sure it is visible in the viewport if it is not we will
// scroll the list down to it.
const $discussion = $list.find('.DiscussionListItem.active');
if ($discussion.length) {
const listTop = $list.offset().top;
const listBottom = listTop + $list.outerHeight();
const discussionTop = $discussion.offset().top;
const discussionBottom = discussionTop + $discussion.outerHeight();
if (discussionTop < listTop || discussionBottom > listBottom) {
$list.scrollTop($list.scrollTop() - listTop + discussionTop);
}
}
}
/**
* Build an item list for the contents of the sidebar.
*
* @return {ItemList}
*/
sidebarItems() {
const items = new ItemList();
items.add('controls',
SplitDropdown.component({
children: DiscussionControls.controls(this.discussion, this).toArray(),
icon: 'ellipsis-v',
className: 'App-primaryControl',
buttonClassName: 'Button--primary'
})
);
items.add('scrubber',
PostStreamScrubber.component({
stream: this.stream,
className: 'App-titleControl'
}),
-100
);
return items;
}
/**
* When the posts that are visible in the post stream change (i.e. the user
* scrolls up or down), then we update the URL and mark the posts as read.
*
* @param {Integer} startNumber
* @param {Integer} endNumber
*/
positionChanged(startNumber, endNumber) {
const discussion = this.discussion;
// Construct a URL to this discussion with the updated position, then
// replace it into the window's history and our own history stack.
const url = app.route.discussion(discussion, this.near = startNumber);
m.route(url, true);
window.history.replaceState(null, document.title, url);
app.history.push('discussion', discussion.title());
// If the user hasn't read past here before, then we'll update their read
// state and redraw.
if (app.session.user && endNumber > (discussion.readNumber() || 0)) {
discussion.save({readNumber: endNumber});
m.redraw();
}
}
}

View File

@@ -1,25 +0,0 @@
import Notification from 'flarum/components/Notification';
/**
* The `DiscussionRenamedNotification` component displays a notification which
* indicates that a discussion has had its title changed.
*
* ### Props
*
* - All of the props for Notification
*/
export default class DiscussionRenamedNotification extends Notification {
icon() {
return 'pencil';
}
href() {
const notification = this.props.notification;
return app.route.discussion(notification.subject(), notification.content().postNumber);
}
content() {
return app.translator.trans('core.forum.notifications.discussion_renamed_text', {user: this.props.notification.sender()});
}
}

View File

@@ -1,34 +0,0 @@
import EventPost from 'flarum/components/EventPost';
import extractText from 'flarum/utils/extractText';
/**
* The `DiscussionRenamedPost` component displays a discussion event post
* indicating that the discussion has been renamed.
*
* ### Props
*
* - All of the props for EventPost
*/
export default class DiscussionRenamedPost extends EventPost {
icon() {
return 'pencil';
}
description(data) {
const renamed = app.translator.trans('core.forum.post_stream.discussion_renamed_text', data);
const oldName = app.translator.trans('core.forum.post_stream.discussion_renamed_old_tooltip', data);
return <span title={extractText(oldName)}>{renamed}</span>;
}
descriptionData() {
const post = this.props.post;
const oldTitle = post.content()[0];
const newTitle = post.content()[1];
return {
'old': oldTitle,
'new': <strong className="DiscussionRenamedPost-new">{newTitle}</strong>
};
}
}

View File

@@ -1,58 +0,0 @@
import highlight from 'flarum/helpers/highlight';
import LinkButton from 'flarum/components/LinkButton';
/**
* The `DiscussionsSearchSource` finds and displays discussion search results in
* the search dropdown.
*
* @implements SearchSource
*/
export default class DiscussionsSearchSource {
constructor() {
this.results = {};
}
search(query) {
query = query.toLowerCase();
this.results[query] = [];
const params = {
filter: {q: query},
page: {limit: 3},
include: 'relevantPosts,relevantPosts.discussion,relevantPosts.user'
};
return app.store.find('discussions', params).then(results => this.results[query] = results);
}
view(query) {
query = query.toLowerCase();
const results = this.results[query] || [];
return [
<li className="Dropdown-header">{app.translator.trans('core.forum.search.discussions_heading')}</li>,
<li>
{LinkButton.component({
icon: 'search',
children: app.translator.trans('core.forum.search.all_discussions_button', {query}),
href: app.route('index', {q: query})
})}
</li>,
results.map(discussion => {
const relevantPosts = discussion.relevantPosts();
const post = relevantPosts && relevantPosts[0];
return (
<li className="DiscussionSearchResult" data-index={'discussions' + discussion.id()}>
<a href={app.route.discussion(discussion, post && post.number())} config={m.route}>
<div className="DiscussionSearchResult-title">{highlight(discussion.title(), query)}</div>
{post ? <div className="DiscussionSearchResult-excerpt">{highlight(post.contentPlain(), query, 100)}</div> : ''}
</a>
</li>
);
})
];
}
}

View File

@@ -1,26 +0,0 @@
import UserPage from 'flarum/components/UserPage';
import DiscussionList from 'flarum/components/DiscussionList';
/**
* The `DiscussionsUserPage` component shows a discussion list inside of a user
* page.
*/
export default class DiscussionsUserPage extends UserPage {
init() {
super.init();
this.loadUser(m.route.param('username'));
}
content() {
return (
<div className="DiscussionsUserPage">
{DiscussionList.component({
params: {
q: 'author:' + this.user.username()
}
})}
</div>
);
}
}

View File

@@ -1,86 +0,0 @@
import ComposerBody from 'flarum/components/ComposerBody';
import icon from 'flarum/helpers/icon';
function minimizeComposerIfFullScreen(e) {
if (app.composer.isFullScreen()) {
app.composer.minimize();
e.stopPropagation();
}
}
/**
* The `EditPostComposer` component displays the composer content for editing a
* post. It sets the initial content to the content of the post that is being
* edited, and adds a header control to indicate which post is being edited.
*
* ### Props
*
* - All of the props for ComposerBody
* - `post`
*/
export default class EditPostComposer extends ComposerBody {
init() {
super.init();
this.editor.props.preview = e => {
minimizeComposerIfFullScreen(e);
m.route(app.route.post(this.props.post));
};
}
static initProps(props) {
super.initProps(props);
props.submitLabel = props.submitLabel || app.translator.trans('core.forum.composer_edit.submit_button');
props.confirmExit = props.confirmExit || app.translator.trans('core.forum.composer_edit.discard_confirmation');
props.originalContent = props.originalContent || props.post.content();
props.user = props.user || props.post.user();
props.post.editedContent = props.originalContent;
}
headerItems() {
const items = super.headerItems();
const post = this.props.post;
const routeAndMinimize = function(element, isInitialized) {
if (isInitialized) return;
$(element).on('click', minimizeComposerIfFullScreen);
m.route.apply(this, arguments);
};
items.add('title', (
<h3>
{icon('pencil')} {' '}
<a href={app.route.discussion(post.discussion(), post.number())} config={routeAndMinimize}>
{app.translator.trans('core.forum.composer_edit.post_link', {number: post.number(), discussion: post.discussion().title()})}
</a>
</h3>
));
return items;
}
/**
* Get the data to submit to the server when the post is saved.
*
* @return {Object}
*/
data() {
return {
content: this.content()
};
}
onsubmit() {
this.loading = true;
const data = this.data();
this.props.post.save(data).then(
() => app.composer.hide(),
this.loaded.bind(this)
);
}
}

View File

@@ -1,136 +0,0 @@
import Modal from 'flarum/components/Modal';
import Button from 'flarum/components/Button';
import GroupBadge from 'flarum/components/GroupBadge';
import Group from 'flarum/models/Group';
import extractText from 'flarum/utils/extractText';
/**
* The `EditUserModal` component displays a modal dialog with a login form.
*/
export default class EditUserModal extends Modal {
init() {
super.init();
const user = this.props.user;
this.username = m.prop(user.username() || '');
this.email = m.prop(user.email() || '');
this.setPassword = m.prop(false);
this.password = m.prop(user.password() || '');
this.groups = {};
app.store.all('groups')
.filter(group => [Group.GUEST_ID, Group.MEMBER_ID].indexOf(group.id()) === -1)
.forEach(group => this.groups[group.id()] = m.prop(user.groups().indexOf(group) !== -1));
}
className() {
return 'EditUserModal Modal--small';
}
title() {
return app.translator.trans('core.forum.edit_user.title');
}
content() {
return (
<div className="Modal-body">
<div className="Form">
<div className="Form-group">
<label>Username</label>
<input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.username_label'))}
bidi={this.username} />
</div>
{app.session.user !== this.props.user ? [
<div className="Form-group">
<label>Email</label>
<div>
<input className="FormControl" placeholder={extractText(app.translator.trans('core.forum.edit_user.email_label'))}
bidi={this.email} />
</div>
</div>,
<div className="Form-group">
<label>Password</label>
<div>
<label className="checkbox">
<input type="checkbox" checked={this.setPassword()} onchange={e => {
this.setPassword(e.target.checked);
m.redraw(true);
if (e.target.checked) this.$('[name=password]').select();
m.redraw.strategy('none');
}}/>
Set new password
</label>
{this.setPassword() ? (
<input className="FormControl" type="password" name="password" placeholder={extractText(app.translator.trans('core.forum.edit_user.password_label'))}
bidi={this.password} />
) : ''}
</div>
</div>
] : ''}
<div className="Form-group EditUserModal-groups">
<label>Groups</label>
<div>
{Object.keys(this.groups)
.map(id => app.store.getById('groups', id))
.map(group => (
<label className="checkbox">
<input type="checkbox"
bidi={this.groups[group.id()]}
disabled={this.props.user.id() === '1' && group.id() === Group.ADMINISTRATOR_ID} />
{GroupBadge.component({group, label: ''})} {group.nameSingular()}
</label>
))}
</div>
</div>
<div className="Form-group">
{Button.component({
className: 'Button Button--primary',
type: 'submit',
loading: this.loading,
children: app.translator.trans('core.forum.edit_user.submit_button')
})}
</div>
</div>
</div>
);
}
data() {
const groups = Object.keys(this.groups)
.filter(id => this.groups[id]())
.map(id => app.store.getById('groups', id));
const data = {
username: this.username(),
relationships: {groups}
};
if (app.session.user !== this.props.user) {
data.email = this.email();
}
if (this.setPassword()) {
data.password = this.password();
}
return data;
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
this.props.user.save(this.data(), {errorHandler: this.onerror.bind(this)})
.then(this.hide.bind(this))
.catch(() => {
this.loading = false;
m.redraw();
});
}
}

View File

@@ -1,80 +0,0 @@
import Post from 'flarum/components/Post';
import { ucfirst } from 'flarum/utils/string';
import usernameHelper from 'flarum/helpers/username';
import icon from 'flarum/helpers/icon';
/**
* The `EventPost` component displays a post which indicating a discussion
* event, like a discussion being renamed or stickied. Subclasses must implement
* the `icon` and `description` methods.
*
* ### Props
*
* - All of the props for `Post`
*
* @abstract
*/
export default class EventPost extends Post {
attrs() {
const attrs = super.attrs();
attrs.className += ' EventPost ' + ucfirst(this.props.post.contentType()) + 'Post';
return attrs;
}
content() {
const user = this.props.post.user();
const username = usernameHelper(user);
const data = Object.assign(this.descriptionData(), {
user,
username: user
? <a className="EventPost-user" href={app.route.user(user)} config={m.route}>{username}</a>
: username
});
return super.content().concat([
icon(this.icon(), {className: 'EventPost-icon'}),
<div class="EventPost-info">
{this.description(data)}
</div>
]);
}
/**
* Get the name of the event icon.
*
* @return {String}
*/
icon() {
return '';
}
/**
* Get the description text for the event.
*
* @param {Object} data
* @return {String|Object} The description to render in the DOM
*/
description(data) {
return app.translator.transChoice(this.descriptionKey(), data.count, data);
}
/**
* Get the translation key for the description of the event.
*
* @return {String}
*/
descriptionKey() {
return '';
}
/**
* Get the translation data for the description of the event.
*
* @return {Object}
*/
descriptionData() {
return {};
}
}

View File

@@ -1,106 +0,0 @@
import Modal from 'flarum/components/Modal';
import Alert from 'flarum/components/Alert';
import Button from 'flarum/components/Button';
import extractText from 'flarum/utils/extractText';
/**
* The `ForgotPasswordModal` component displays a modal which allows the user to
* enter their email address and request a link to reset their password.
*
* ### Props
*
* - `email`
*/
export default class ForgotPasswordModal extends Modal {
init() {
super.init();
/**
* The value of the email input.
*
* @type {Function}
*/
this.email = m.prop(this.props.email || '');
/**
* Whether or not the password reset email was sent successfully.
*
* @type {Boolean}
*/
this.success = false;
}
className() {
return 'ForgotPasswordModal Modal--small';
}
title() {
return app.translator.trans('core.forum.forgot_password.title');
}
content() {
if (this.success) {
return (
<div className="Modal-body">
<div className="Form Form--centered">
<p className="helpText">{app.translator.trans('core.forum.forgot_password.email_sent_message')}</p>
<div className="Form-group">
<Button className="Button Button--primary Button--block" onclick={this.hide.bind(this)}>
{app.translator.trans('core.forum.forgot_password.dismiss_button')}
</Button>
</div>
</div>
</div>
);
}
return (
<div className="Modal-body">
<div className="Form Form--centered">
<p className="helpText">{app.translator.trans('core.forum.forgot_password.text')}</p>
<div className="Form-group">
<input className="FormControl" name="email" type="email" placeholder={extractText(app.translator.trans('core.forum.forgot_password.email_placeholder'))}
value={this.email()}
onchange={m.withAttr('value', this.email)}
disabled={this.loading} />
</div>
<div className="Form-group">
{Button.component({
className: 'Button Button--primary Button--block',
type: 'submit',
loading: this.loading,
children: app.translator.trans('core.forum.forgot_password.submit_button')
})}
</div>
</div>
</div>
);
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
app.request({
method: 'POST',
url: app.forum.attribute('apiUrl') + '/forgot',
data: {email: this.email()},
errorHandler: this.onerror.bind(this)
})
.then(() => {
this.success = true;
this.alert = null;
})
.catch(() => {})
.then(this.loaded.bind(this));
}
onerror(error) {
if (error.status === 404) {
error.alert.props.children = app.translator.trans('core.forum.forgot_password.not_found_message');
}
super.onerror(error);
}
}

View File

@@ -1,33 +0,0 @@
import Component from 'flarum/Component';
import ItemList from 'flarum/utils/ItemList';
import listItems from 'flarum/helpers/listItems';
/**
* The `HeaderPrimary` component displays primary header controls. On the
* default skin, these are shown just to the right of the forum title.
*/
export default class HeaderPrimary extends Component {
view() {
return (
<ul className="Header-controls">
{listItems(this.items().toArray())}
</ul>
);
}
config(isInitialized, context) {
// Since this component is 'above' the content of the page (that is, it is a
// part of the global UI that persists between routes), we will flag the DOM
// to be retained across route changes.
context.retain = true;
}
/**
* Build an item list for the controls.
*
* @return {ItemList}
*/
items() {
return new ItemList();
}
}

View File

@@ -1,92 +0,0 @@
import Component from 'flarum/Component';
import Button from 'flarum/components/Button';
import LogInModal from 'flarum/components/LogInModal';
import SignUpModal from 'flarum/components/SignUpModal';
import SessionDropdown from 'flarum/components/SessionDropdown';
import SelectDropdown from 'flarum/components/SelectDropdown';
import NotificationsDropdown from 'flarum/components/NotificationsDropdown';
import ItemList from 'flarum/utils/ItemList';
import listItems from 'flarum/helpers/listItems';
/**
* The `HeaderSecondary` component displays secondary header controls, such as
* the search box and the user menu. On the default skin, these are shown on the
* right side of the header.
*/
export default class HeaderSecondary extends Component {
view() {
return (
<ul className="Header-controls">
{listItems(this.items().toArray())}
</ul>
);
}
config(isInitialized, context) {
// Since this component is 'above' the content of the page (that is, it is a
// part of the global UI that persists between routes), we will flag the DOM
// to be retained across route changes.
context.retain = true;
}
/**
* Build an item list for the controls.
*
* @return {ItemList}
*/
items() {
const items = new ItemList();
items.add('search', app.search.render(), 30);
if (Object.keys(app.data.locales).length > 1) {
const locales = [];
for (const locale in app.data.locales) {
locales.push(Button.component({
active: app.data.locale === locale,
children: app.data.locales[locale],
icon: app.data.locale === locale ? 'check' : true,
onclick: () => {
if (app.session.user) {
app.session.user.savePreferences({locale}).then(() => window.location.reload());
} else {
document.cookie = `locale=${locale}; path=/; expires=Tue, 19 Jan 2038 03:14:07 GMT`;
window.location.reload();
}
}
}));
}
items.add('locale', SelectDropdown.component({
children: locales,
buttonClassName: 'Button Button--link'
}), 20);
}
if (app.session.user) {
items.add('notifications', NotificationsDropdown.component(), 10);
items.add('session', SessionDropdown.component(), 0);
} else {
if (app.forum.attribute('allowSignUp')) {
items.add('signUp',
Button.component({
children: app.translator.trans('core.forum.header.sign_up_link'),
className: 'Button Button--link',
onclick: () => app.modal.show(new SignUpModal())
}), 10
);
}
items.add('logIn',
Button.component({
children: app.translator.trans('core.forum.header.log_in_link'),
className: 'Button Button--link',
onclick: () => app.modal.show(new LogInModal())
}), 0
);
}
return items;
}
}

View File

@@ -1,373 +0,0 @@
import { extend } from 'flarum/extend';
import Page from 'flarum/components/Page';
import ItemList from 'flarum/utils/ItemList';
import listItems from 'flarum/helpers/listItems';
import icon from 'flarum/helpers/icon';
import DiscussionList from 'flarum/components/DiscussionList';
import WelcomeHero from 'flarum/components/WelcomeHero';
import DiscussionComposer from 'flarum/components/DiscussionComposer';
import LogInModal from 'flarum/components/LogInModal';
import DiscussionPage from 'flarum/components/DiscussionPage';
import Select from 'flarum/components/Select';
import Button from 'flarum/components/Button';
import LinkButton from 'flarum/components/LinkButton';
import SelectDropdown from 'flarum/components/SelectDropdown';
/**
* The `IndexPage` component displays the index page, including the welcome
* hero, the sidebar, and the discussion list.
*/
export default class IndexPage extends Page {
init() {
super.init();
// If the user is returning from a discussion page, then take note of which
// discussion they have just visited. After the view is rendered, we will
// scroll down so that this discussion is in view.
if (app.previous instanceof DiscussionPage) {
this.lastDiscussion = app.previous.discussion;
}
// If the user is coming from the discussion list, then they have either
// just switched one of the parameters (filter, sort, search) or they
// probably want to refresh the results. We will clear the discussion list
// cache so that results are reloaded.
if (app.previous instanceof IndexPage) {
app.cache.discussionList = null;
}
const params = this.params();
if (app.cache.discussionList) {
// Compare the requested parameters (sort, search query) to the ones that
// are currently present in the cached discussion list. If they differ, we
// will clear the cache and set up a new discussion list component with
// the new parameters.
Object.keys(params).some(key => {
if (app.cache.discussionList.props.params[key] !== params[key]) {
app.cache.discussionList = null;
return true;
}
});
}
if (!app.cache.discussionList) {
app.cache.discussionList = new DiscussionList({params});
}
app.history.push('index', icon('bars'));
this.bodyClass = 'App--index';
}
onunload() {
// Save the scroll position so we can restore it when we return to the
// discussion list.
app.cache.scrollTop = $(window).scrollTop();
}
view() {
return (
<div className="IndexPage">
{this.hero()}
<div className="container">
<nav className="IndexPage-nav sideNav">
<ul>{listItems(this.sidebarItems().toArray())}</ul>
</nav>
<div className="IndexPage-results sideNavOffset">
<div className="IndexPage-toolbar">
<ul className="IndexPage-toolbar-view">{listItems(this.viewItems().toArray())}</ul>
<ul className="IndexPage-toolbar-action">{listItems(this.actionItems().toArray())}</ul>
</div>
{app.cache.discussionList.render()}
</div>
</div>
</div>
);
}
config(isInitialized, context) {
super.config(...arguments);
if (isInitialized) return;
extend(context, 'onunload', () => $('#app').css('min-height', ''));
app.setTitle('');
app.setTitleCount(0);
// Work out the difference between the height of this hero and that of the
// previous hero. Maintain the same scroll position relative to the bottom
// of the hero so that the sidebar doesn't jump around.
const oldHeroHeight = app.cache.heroHeight;
const heroHeight = app.cache.heroHeight = this.$('.Hero').outerHeight();
const scrollTop = app.cache.scrollTop;
$('#app').css('min-height', $(window).height() + heroHeight);
// Scroll to the remembered position. We do this after a short delay so that
// it happens after the browser has done its own "back button" scrolling,
// which isn't right. https://github.com/flarum/core/issues/835
const scroll = () => $(window).scrollTop(scrollTop - oldHeroHeight + heroHeight);
scroll();
setTimeout(scroll, 1);
// If we've just returned from a discussion page, then the constructor will
// have set the `lastDiscussion` property. If this is the case, we want to
// scroll down to that discussion so that it's in view.
if (this.lastDiscussion) {
const $discussion = this.$(`.DiscussionListItem[data-id="${this.lastDiscussion.id()}"]`);
if ($discussion.length) {
const indexTop = $('#header').outerHeight();
const indexBottom = $(window).height();
const discussionTop = $discussion.offset().top;
const discussionBottom = discussionTop + $discussion.outerHeight();
if (discussionTop < scrollTop + indexTop || discussionBottom > scrollTop + indexBottom) {
$(window).scrollTop(discussionTop - indexTop);
}
}
}
}
/**
* Get the component to display as the hero.
*
* @return {MithrilComponent}
*/
hero() {
return WelcomeHero.component();
}
/**
* Build an item list for the sidebar of the index page. By default this is a
* "New Discussion" button, and then a DropdownSelect component containing a
* list of navigation items.
*
* @return {ItemList}
*/
sidebarItems() {
const items = new ItemList();
const canStartDiscussion = app.forum.attribute('canStartDiscussion') || !app.session.user;
items.add('newDiscussion',
Button.component({
children: app.translator.trans(canStartDiscussion ? 'core.forum.index.start_discussion_button' : 'core.forum.index.cannot_start_discussion_button'),
icon: 'edit',
className: 'Button Button--primary IndexPage-newDiscussion',
itemClassName: 'App-primaryControl',
onclick: this.newDiscussion.bind(this),
disabled: !canStartDiscussion
})
);
items.add('nav',
SelectDropdown.component({
children: this.navItems(this).toArray(),
buttonClassName: 'Button',
className: 'App-titleControl'
})
);
return items;
}
/**
* Build an item list for the navigation in the sidebar of the index page. By
* default this is just the 'All Discussions' link.
*
* @return {ItemList}
*/
navItems() {
const items = new ItemList();
const params = this.stickyParams();
items.add('allDiscussions',
LinkButton.component({
href: app.route('index', params),
children: app.translator.trans('core.forum.index.all_discussions_link'),
icon: 'comments-o'
}),
100
);
return items;
}
/**
* Build an item list for the part of the toolbar which is concerned with how
* the results are displayed. By default this is just a select box to change
* the way discussions are sorted.
*
* @return {ItemList}
*/
viewItems() {
const items = new ItemList();
const sortMap = app.cache.discussionList.sortMap();
const sortOptions = {};
for (const i in sortMap) {
sortOptions[i] = app.translator.trans('core.forum.index_sort.' + i + '_button');
}
items.add('sort',
Select.component({
options: sortOptions,
value: this.params().sort || Object.keys(sortMap)[0],
onchange: this.changeSort.bind(this)
})
);
return items;
}
/**
* Build an item list for the part of the toolbar which is about taking action
* on the results. By default this is just a "mark all as read" button.
*
* @return {ItemList}
*/
actionItems() {
const items = new ItemList();
items.add('refresh',
Button.component({
title: app.translator.trans('core.forum.index.refresh_tooltip'),
icon: 'refresh',
className: 'Button Button--icon',
onclick: () => app.cache.discussionList.refresh()
})
);
if (app.session.user) {
items.add('markAllAsRead',
Button.component({
title: app.translator.trans('core.forum.index.mark_all_as_read_tooltip'),
icon: 'check',
className: 'Button Button--icon',
onclick: this.markAllAsRead.bind(this)
})
);
}
return items;
}
/**
* Return the current search query, if any. This is implemented to activate
* the search box in the header.
*
* @see Search
* @return {String}
*/
searching() {
return this.params().q;
}
/**
* Redirect to the index page without a search filter. This is called when the
* 'x' is clicked in the search box in the header.
*
* @see Search
*/
clearSearch() {
const params = this.params();
delete params.q;
m.route(app.route(this.props.routeName, params));
}
/**
* Redirect to the index page using the given sort parameter.
*
* @param {String} sort
*/
changeSort(sort) {
const params = this.params();
if (sort === Object.keys(app.cache.discussionList.sortMap())[0]) {
delete params.sort;
} else {
params.sort = sort;
}
m.route(app.route(this.props.routeName, params));
}
/**
* Get URL parameters that stick between filter changes.
*
* @return {Object}
*/
stickyParams() {
return {
sort: m.route.param('sort'),
q: m.route.param('q')
};
}
/**
* Get parameters to pass to the DiscussionList component.
*
* @return {Object}
*/
params() {
const params = this.stickyParams();
params.filter = m.route.param('filter');
return params;
}
/**
* Log the user in and then open the composer for a new discussion.
*
* @return {Promise}
*/
newDiscussion() {
const deferred = m.deferred();
if (app.session.user) {
this.composeNewDiscussion(deferred);
} else {
app.modal.show(
new LogInModal({
onlogin: this.composeNewDiscussion.bind(this, deferred)
})
);
}
return deferred.promise;
}
/**
* Initialize the composer for a new discussion.
*
* @param {Deferred} deferred
* @return {Promise}
*/
composeNewDiscussion(deferred) {
const component = new DiscussionComposer({user: app.session.user});
app.composer.load(component);
app.composer.show();
deferred.resolve(component);
return deferred.promise;
}
/**
* Mark all discussions as read.
*
* @return void
*/
markAllAsRead() {
const confirmation = confirm(app.translator.trans('core.forum.index.mark_all_as_read_confirmation'));
if (confirmation) {
app.session.user.save({readTime: new Date()});
}
}
}

View File

@@ -1,25 +0,0 @@
import Component from 'flarum/Component';
import avatar from 'flarum/helpers/avatar';
/**
* The `LoadingPost` component shows a placeholder that looks like a post,
* indicating that the post is loading.
*/
export default class LoadingPost extends Component {
view() {
return (
<div className="Post CommentPost LoadingPost">
<header className="Post-header">
{avatar(null, {className: 'PostUser-avatar'})}
<div className="fakeText"/>
</header>
<div className="Post-body">
<div className="fakeText"/>
<div className="fakeText"/>
<div className="fakeText"/>
</div>
</div>
);
}
}

View File

@@ -1,30 +0,0 @@
import Button from 'flarum/components/Button';
/**
* The `LogInButton` component displays a social login button which will open
* a popup window containing the specified path.
*
* ### Props
*
* - `path`
*/
export default class LogInButton extends Button {
static initProps(props) {
props.className = (props.className || '') + ' LogInButton';
props.onclick = function() {
const width = 600;
const height = 400;
const $window = $(window);
window.open(app.forum.attribute('baseUrl') + props.path, 'logInPopup',
`width=${width},` +
`height=${height},` +
`top=${$window.height() / 2 - height / 2},` +
`left=${$window.width() / 2 - width / 2},` +
'status=no,scrollbars=no,resizable=no');
};
super.initProps(props);
}
}

View File

@@ -1,25 +0,0 @@
import Component from 'flarum/Component';
import ItemList from 'flarum/utils/ItemList';
/**
* The `LogInButtons` component displays a collection of social login buttons.
*/
export default class LogInButtons extends Component {
view() {
return (
<div className="LogInButtons">
{this.items().toArray()}
</div>
);
}
/**
* Build a list of LogInButton components.
*
* @return {ItemList}
* @public
*/
items() {
return new ItemList();
}
}

View File

@@ -1,138 +0,0 @@
import Modal from 'flarum/components/Modal';
import ForgotPasswordModal from 'flarum/components/ForgotPasswordModal';
import SignUpModal from 'flarum/components/SignUpModal';
import Alert from 'flarum/components/Alert';
import Button from 'flarum/components/Button';
import LogInButtons from 'flarum/components/LogInButtons';
import extractText from 'flarum/utils/extractText';
/**
* The `LogInModal` component displays a modal dialog with a login form.
*
* ### Props
*
* - `email`
* - `password`
*/
export default class LogInModal extends Modal {
init() {
super.init();
/**
* The value of the email input.
*
* @type {Function}
*/
this.email = m.prop(this.props.email || '');
/**
* The value of the password input.
*
* @type {Function}
*/
this.password = m.prop(this.props.password || '');
}
className() {
return 'LogInModal Modal--small';
}
title() {
return app.translator.trans('core.forum.log_in.title');
}
content() {
return [
<div className="Modal-body">
<LogInButtons/>
<div className="Form Form--centered">
<div className="Form-group">
<input className="FormControl" name="email" type="text" placeholder={extractText(app.translator.trans('core.forum.log_in.username_or_email_placeholder'))}
bidi={this.email}
disabled={this.loading} />
</div>
<div className="Form-group">
<input className="FormControl" name="password" type="password" placeholder={extractText(app.translator.trans('core.forum.log_in.password_placeholder'))}
bidi={this.password}
disabled={this.loading} />
</div>
<div className="Form-group">
{Button.component({
className: 'Button Button--primary Button--block',
type: 'submit',
loading: this.loading,
children: app.translator.trans('core.forum.log_in.submit_button')
})}
</div>
</div>
</div>,
<div className="Modal-footer">
<p className="LogInModal-forgotPassword">
<a onclick={this.forgotPassword.bind(this)}>{app.translator.trans('core.forum.log_in.forgot_password_link')}</a>
</p>
{app.forum.attribute('allowSignUp') ? (
<p className="LogInModal-signUp">
{app.translator.trans('core.forum.log_in.sign_up_text', {a: <a onclick={this.signUp.bind(this)}/>})}
</p>
) : ''}
</div>
];
}
/**
* Open the forgot password modal, prefilling it with an email if the user has
* entered one.
*
* @public
*/
forgotPassword() {
const email = this.email();
const props = email.indexOf('@') !== -1 ? {email} : undefined;
app.modal.show(new ForgotPasswordModal(props));
}
/**
* Open the sign up modal, prefilling it with an email/username/password if
* the user has entered one.
*
* @public
*/
signUp() {
const props = {password: this.password()};
const email = this.email();
props[email.indexOf('@') !== -1 ? 'email' : 'username'] = email;
app.modal.show(new SignUpModal(props));
}
onready() {
this.$('[name=' + (this.email() ? 'password' : 'email') + ']').select();
}
onsubmit(e) {
e.preventDefault();
this.loading = true;
const email = this.email();
const password = this.password();
app.session.login(email, password, {errorHandler: this.onerror.bind(this)}).then(
() => window.location.reload(),
this.loaded.bind(this)
);
}
onerror(error) {
if (error.status === 401) {
error.alert.props.children = app.translator.trans('core.forum.log_in.invalid_login_message');
}
super.onerror(error);
}
}

View File

@@ -1,86 +0,0 @@
import Component from 'flarum/Component';
import avatar from 'flarum/helpers/avatar';
import icon from 'flarum/helpers/icon';
import humanTime from 'flarum/helpers/humanTime';
/**
* The `Notification` component abstract displays a single notification.
* Subclasses should implement the `icon`, `href`, and `content` methods.
*
* ### Props
*
* - `notification`
*
* @abstract
*/
export default class Notification extends Component {
view() {
const notification = this.props.notification;
const href = this.href();
return (
<a className={'Notification Notification--' + notification.contentType() + ' ' + (!notification.isRead() ? 'unread' : '')}
href={href}
config={function(element, isInitialized) {
if (href.indexOf('://') === -1) m.route.apply(this, arguments);
if (!isInitialized) $(element).click(this.markAsRead.bind(this));
}}>
{avatar(notification.sender())}
{icon(this.icon(), {className: 'Notification-icon'})}
<span className="Notification-content">{this.content()}</span>
{humanTime(notification.time())}
<div className="Notification-excerpt">
{this.excerpt()}
</div>
</a>
);
}
/**
* Get the name of the icon that should be displayed in the notification.
*
* @return {String}
* @abstract
*/
icon() {
}
/**
* Get the URL that the notification should link to.
*
* @return {String}
* @abstract
*/
href() {
}
/**
* Get the content of the notification.
*
* @return {VirtualElement}
* @abstract
*/
content() {
}
/**
* Get the excerpt of the notification.
*
* @return {VirtualElement}
* @abstract
*/
excerpt() {
}
/**
* Mark the notification as read.
*/
markAsRead() {
if (this.props.notification.isRead()) return;
app.session.user.pushAttributes({unreadNotificationsCount: app.session.user.unreadNotificationsCount() - 1});
this.props.notification.save({isRead: true});
}
}

View File

@@ -1,188 +0,0 @@
import Component from 'flarum/Component';
import Checkbox from 'flarum/components/Checkbox';
import icon from 'flarum/helpers/icon';
import ItemList from 'flarum/utils/ItemList';
/**
* The `NotificationGrid` component displays a table of notification types and
* methods, allowing the user to toggle each combination.
*
* ### Props
*
* - `user`
*/
export default class NotificationGrid extends Component {
init() {
/**
* Information about the available notification methods.
*
* @type {Array}
*/
this.methods = [
{name: 'alert', icon: 'bell', label: app.translator.trans('core.forum.settings.notify_by_web_heading')},
{name: 'email', icon: 'envelope-o', label: app.translator.trans('core.forum.settings.notify_by_email_heading')}
];
/**
* A map of notification type-method combinations to the checkbox instances
* that represent them.
*
* @type {Object}
*/
this.inputs = {};
/**
* Information about the available notification types.
*
* @type {Object}
*/
this.types = this.notificationTypes().toArray();
// For each of the notification type-method combinations, create and store a
// new checkbox component instance, which we will render in the view.
this.types.forEach(type => {
this.methods.forEach(method => {
const key = this.preferenceKey(type.name, method.name);
const preference = this.props.user.preferences()[key];
this.inputs[key] = new Checkbox({
state: !!preference,
disabled: typeof preference === 'undefined',
onchange: () => this.toggle([key])
});
});
});
}
view() {
return (
<table className="NotificationGrid">
<thead>
<tr>
<td/>
{this.methods.map(method => (
<th className="NotificationGrid-groupToggle" onclick={this.toggleMethod.bind(this, method.name)}>
{icon(method.icon)} {method.label}
</th>
))}
</tr>
</thead>
<tbody>
{this.types.map(type => (
<tr>
<td className="NotificationGrid-groupToggle" onclick={this.toggleType.bind(this, type.name)}>
{icon(type.icon)} {type.label}
</td>
{this.methods.map(method => (
<td className="NotificationGrid-checkbox">
{this.inputs[this.preferenceKey(type.name, method.name)].render()}
</td>
))}
</tr>
))}
</tbody>
</table>
);
}
config(isInitialized) {
if (isInitialized) return;
this.$('thead .NotificationGrid-groupToggle').bind('mouseenter mouseleave', function(e) {
const i = parseInt($(this).index(), 10) + 1;
$(this).parents('table').find('td:nth-child(' + i + ')').toggleClass('highlighted', e.type === 'mouseenter');
});
this.$('tbody .NotificationGrid-groupToggle').bind('mouseenter mouseleave', function(e) {
$(this).parent().find('td').toggleClass('highlighted', e.type === 'mouseenter');
});
}
/**
* Toggle the state of the given preferences, based on the value of the first
* one.
*
* @param {Array} keys
*/
toggle(keys) {
const user = this.props.user;
const preferences = user.preferences();
const enabled = !preferences[keys[0]];
keys.forEach(key => {
const control = this.inputs[key];
control.loading = true;
preferences[key] = control.props.state = enabled;
});
m.redraw();
user.save({preferences}).then(() => {
keys.forEach(key => this.inputs[key].loading = false);
m.redraw();
});
}
/**
* Toggle all notification types for the given method.
*
* @param {String} method
*/
toggleMethod(method) {
const keys = this.types
.map(type => this.preferenceKey(type.name, method))
.filter(key => !this.inputs[key].props.disabled);
this.toggle(keys);
}
/**
* Toggle all notification methods for the given type.
*
* @param {String} type
*/
toggleType(type) {
const keys = this.methods
.map(method => this.preferenceKey(type, method.name))
.filter(key => !this.inputs[key].props.disabled);
this.toggle(keys);
}
/**
* Get the name of the preference key for the given notification type-method
* combination.
*
* @param {String} type
* @param {String} method
* @return {String}
*/
preferenceKey(type, method) {
return 'notify_' + type + '_' + method;
}
/**
* Build an item list for the notification types to display in the grid.
*
* Each notification type is an object which has the following properties:
*
* - `name` The name of the notification type.
* - `label` The label to display in the notification grid row.
*
* @return {ItemList}
*/
notificationTypes() {
const items = new ItemList();
items.add('discussionRenamed', {
name: 'discussionRenamed',
icon: 'pencil',
label: app.translator.trans('core.forum.settings.notify_discussion_renamed_label')
});
return items;
}
}

Some files were not shown because too many files have changed in this diff Show More