1
0
mirror of https://github.com/flarum/core.git synced 2025-08-13 11:54:32 +02:00

Compare commits

...

220 Commits

Author SHA1 Message Date
flarum-bot
8149397850 Bundled output for commit 1ced907e52
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-06-06 01:50:56 +00:00
David Wheatley
1ced907e52 npm audit fix 2021-06-06 02:47:58 +01:00
David Wheatley
17c5a40740 Update changelog 2021-06-06 02:44:32 +01:00
David Wheatley
440bed81b8 Fix XSS vulnerability 2021-06-06 02:41:48 +01:00
David Wheatley
eeb8fe1443 Update version constant to 1.0.2 2021-06-06 02:09:03 +01:00
Daniel Klabbers
11b1ab5932 update version constant for 1.0.2-dev 2021-06-02 09:10:01 +02:00
Daniel Klabbers
6f34c43dc1 v1.0.1 changelog and constant 2021-06-02 09:05:36 +02:00
luceos
8ced9eef45 Apply fixes from StyleCI
[ci skip] [skip ci]
2021-05-31 14:08:49 +00:00
Daniel Klabbers
8af52153e4 ref #2890, no longer using process and dump 2021-05-31 16:08:15 +02:00
Daniel Klabbers
2c5e5f13dd Revert "Revert "Squash core migrations (#2842)""
This reverts commit 16f3ae9d1e.
2021-05-31 15:49:20 +02:00
Daniel Klabbers
1bbfea4aa3 updated version constraint string 2021-05-29 22:42:28 +02:00
Daniel Klabbers
16f3ae9d1e Revert "Squash core migrations (#2842)"
This reverts commit 6ecca9565a.
2021-05-29 22:38:25 +02:00
Daniel Klabbers
a976a2118a changelog and version constraint fix for flarum/testing 2021-05-25 23:01:54 +02:00
Daniël Klabbers
9cecbe407f Version constant for 1.0.0 (#2885) 2021-05-25 15:00:21 +02:00
Alexander Skvortsov
b3de5157fe Apply fixes from StyleCI
[ci skip] [skip ci]
2021-05-18 07:08:50 +00:00
Alexander Skvortsov
188dc98c4a Fix onOneServer, withoutOverlapping console scheduling options
Flarum doesn't fully use Laravel's cache system, but rather
creates and binds a single cache store.
See \Flarum\Foundation\InstalledSite::registerCache
Since certain config options (e.g. withoutOverlapping, onOneServer)
need the cache, we must override the cache factory we give to the scheduling
mutexes so it returns our single custom cache.
2021-05-18 03:08:32 -04:00
flarum-bot
bcc4545ce7 Bundled output for commit 9ee3cd6a18
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-18 05:39:33 +00:00
Alexander Skvortsov
9ee3cd6a18 Fix insertText
In dd8323ee36, insertText was modified from the original to work with reply mentioning. This was done due to a misunderstanding of the API: the selection range isn't the selection to replace, but rather the final selection state after replacing the *current* selection with the text. This commit restores the original, correct implementation of insertText and instead adjusts the `insertBetween`method of BasicEditorDriver to set selection state before executing `insertText`.

Fixes https://github.com/flarum/core/issues/2877
2021-05-18 01:37:19 -04:00
Alexander Skvortsov
a5182a1454 Fix filesystem wrong method call
The proper method is `exists`, not `has`.
2021-05-17 18:04:08 -04:00
Daniel Klabbers
be7581c432 fix missing import of container for resolving the queue connection from ioc 2021-05-17 21:13:30 +02:00
flarum-bot
e855c49824 Bundled output for commit e010cbc319
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-17 00:29:54 +00:00
David Wheatley
e010cbc319 Fix Badge className not being correctly set
Fixes group icons on Admin permissions page
2021-05-17 01:27:30 +01:00
David Wheatley
70f0c5b728 Update copyright date (#2863) 2021-05-16 19:10:33 -04:00
flarum-bot
1a34b85250 Bundled output for commit 1b8c77d034
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-16 23:04:41 +00:00
SychO9
1b8c77d034 Remove Beta leftover warning code 2021-05-17 00:02:21 +01:00
Alexander Skvortsov
07b1a974cf Bump composer reqs for 1.0.0 2021-05-16 18:27:36 -04:00
flarum-bot
54319c0466 Bundled output for commit 9040e62c0e
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-16 00:14:08 +00:00
Alexander Skvortsov
9040e62c0e Drop JS copyright blocks 2021-05-15 20:11:38 -04:00
flarum-bot
763bd7d244 Bundled output for commit 9b76c8f611
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-15 23:09:46 +00:00
Alexander Skvortsov
9b76c8f611 Merge pull request #2867 from flarum/as/1.0-qa-fixes
Assorted 1.0 QA fixes
2021-05-15 19:07:41 -04:00
Alexander Skvortsov
fede3f9fc7 Fix glitchy group editing
Currently, when groups are edited, the new groups flicker, but the UI soon reverts to the old groups. This is because the returned API response has the old group values. This, in turn, is because we eager load groups, and when we sync the new group relation, that doesn't update the groups saved in memory. By unsetting the relation, we make sure the right groups are returned (and also available to the GroupsChanged event).

See https://github.com/flarum/core/issues/2514
2021-05-15 02:30:03 -04:00
Alexander Skvortsov
9eb74fdc8a Fix CustomFooterModal Appearance
The textarea in the CustomFooterModal was much larger than in the other appearance page modals, and did not use a monospaced font. Turns out the other 2 were explicitly specified in the less. This commit adds a class that can be applied to all these modals for simpler maintenance.

Fixes https://github.com/flarum/core/issues/2865
2021-05-14 21:36:06 -04:00
Alexander Skvortsov
05dda5b083 Fix KeyboardNavigatable
In b2d053f686, I tried to be clever and create a new KeyboardNavigatable object as a return value for `when`. My approach to cloning was incorrect, and caused the util to break entirely.

My original intent for having this "clone"-based behavior is that a single KeyboardNavigatable instance could be created with multiple listeners, and then "cloned" like this with different "activators" registered via "then" calls. In hindsight, this change introduces more issues than it solves: outside of just not working, the cloned "KeyboardNavigatable" instances have shared internal state (the set of callbacks), and each has write access to this internal state. This is a recipe for unpredictable behavior and confusing bugs, so best to keep things simple for now, and maybe introduce more functional behavior in later releases.

Fixes https://github.com/flarum/QualityAssurance/issues/25
2021-05-14 21:21:58 -04:00
Alexander Skvortsov
d1e987a240 Fix 0s in notification dropdown
By casting the length int to a bool, if there are no badges, we don't display a  0. It seems that mithril will render integers, but not booleans.

Fixes https://github.com/flarum/QualityAssurance/issues/28
2021-05-14 21:08:48 -04:00
Alexander Skvortsov
8ffeac4315 NotificationListState separate content method
This fixes an error where an empty notification list wouldn't show the "empty" text.

It also simplifies flow of logic and breaks the component up a bit for readability.
2021-05-14 21:04:26 -04:00
David Wheatley
dd3c203827 Update copyright year 2021-05-15 00:45:09 +01:00
flarum-bot
fc06c76e2c Bundled output for commit 13d341e014
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-14 22:37:39 +00:00
Sami Mazouz
13d341e014 Use slugs for user pages (#2864) 2021-05-14 23:35:50 +01:00
Alexander Skvortsov
1d5d0688aa Fix "add numbered list" styleSelectedText action
Looks like I missed the `numberedLines` function used by the `orderedList` function in dd8323ee36
2021-05-14 18:35:11 -04:00
Sami Mazouz
1a19856c0c Fix version update page (#2862)
* Binding closures only get the container instance as argument
2021-05-14 16:10:05 +01:00
SychO9
0236e1529e Update Application version constant to 1.0.0-dev 2021-05-13 22:19:01 +01:00
flarum-bot
947613a7e2 Bundled output for commit 88df26d722
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-13 19:58:41 +00:00
Christian Lopez
88df26d722 Replace removed hasDiscussions method from DiscussionListPane (#2860) 2021-05-13 15:56:55 -04:00
Sami Mazouz
7bceda976b Backend cleanup (#2859)
* Extender docblocks cleanup
* Excplicit type hinting in extenders
* Bring method under constructor
* Mark some classes and methods as internal
* Remove beta references

Co-authored-by: Clark Winkelmann <clark.winkelmann@gmail.com>
2021-05-13 15:26:24 +01:00
flarum-bot
e3f506817b Bundled output for commit 422525a9bb
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-13 00:03:24 +00:00
Alexander Skvortsov
422525a9bb hasDiscussions method of DiscussionListState has been removed 2021-05-12 19:41:28 -04:00
flarum-bot
c3a684c7ed Bundled output for commit 3537f76eab
Includes transpiled JS/TS, and Typescript declaration files (typings).

[skip ci]
2021-05-12 23:29:46 +00:00
David Wheatley
3537f76eab Update core to use new Webpack config, flarum-tsconfig, and build action (#2856)
* Update core to use new Webpack and TSConfig

* Bump webpack dep

* Update JS build action

* Copy custom `.d.ts` files to `dist-typings` folder on typings compile

* Run workflow against action v2

This allows us to have a moving tag, like first party actions have.

* Remove bundle analyzer from core

* Use webpack config 0.1.0-beta.16.2

* Add note about checking flarum-tsconfig
2021-05-13 00:28:17 +01:00
flarum-bot
c37c4f46da Bundled output for commit 42eacd616c
Includes transpiled JS/TS.

[skip ci]
2021-05-12 23:12:10 +00:00
Alexander Skvortsov
42eacd616c Use proper attrs for viewForum and searchUsers 2021-05-12 18:49:11 -04:00
flarum-bot
875f8eb530 Bundled output for commit 9dca657edf [skip ci] 2021-05-12 22:19:45 +00:00
David Wheatley
9dca657edf Fix formatting error in Tooltip.tsx
Prettier is acting differently on different systems.
2021-05-12 23:14:50 +01:00
flarum-bot
d7648102a9 Bundled output for commit bba6485eff [skip ci] 2021-05-12 03:57:28 +00:00
Alexander Skvortsov
bba6485eff Tooltip formatting fix 2021-05-11 23:55:52 -04:00
Alexander Skvortsov
2075c7319f Typehint event in console scheduling test case 2021-05-11 23:55:34 -04:00
flarum-bot
92e1d0843c Bundled output for commit 4e0fdb4c77 [skip ci] 2021-05-11 23:15:50 +00:00
David Sevilla Martín
4e0fdb4c77 Create abstract PaginatedListState for DiscussionList and others (#2781) 2021-05-11 19:14:26 -04:00
flarum-bot
9a26b2bef4 Bundled output for commit d64750b3eb [skip ci] 2021-05-11 19:17:04 +00:00
Alexander Skvortsov
d64750b3eb Rename viewDiscussions => viewForum, viewUserList => searchUsers (#2854)
This naming is clearer as to the intended effect. Changes include:

- A migration to rename all permissions
- Updating the seed migration to use the original naming from the start
- Replacing usage of the old names with new names in code
- Throwing warnings when the old names are used.
2021-05-11 15:15:27 -04:00
flarum-bot
06f63a2087 Bundled output for commit b2d053f686 [skip ci] 2021-05-11 02:31:32 +00:00
Alexander Skvortsov
b2d053f686 Search frontend cleanup (#2849)
- Convert KeyboardNavigatable to TypeScript, as that is used internally here.
- Convert search sources to TypeScript
- Convert Search component to TypeScript
- Convert Search States to Typescript
- Add `getInitialSearch` to `SearchState`
- Fix search disappearing on page reload / direct link
2021-05-10 22:30:04 -04:00
David Sevilla Martín
765bd59965 Improve discussion page canonical URL (#2853)
* Switch to ?page= discussion page canonical URL & fix no-JS pagination buttons
2021-05-10 19:20:47 -04:00
Alexander Skvortsov
6ecca9565a Squash core migrations (#2842)
Data migrations (seed default groups, seed default permissions) are deliberately excluded.
This also allows us to remove a lot of now unnecessary public API from the migrator and migration repository.
2021-05-10 18:05:01 -04:00
flarum-bot
a28009f24b Bundled output for commit 7f596db09b [skip ci] 2021-05-10 21:56:41 +00:00
Alexander Skvortsov
7f596db09b Some minor JS cleanup (#2846)
- Change index files to ts
- Remove deprecated EditUserModal from forum compat
- Remove b14-specific error
- Remove transChoice method (ICU should be used instead)
- Translator to TypeScript
- Small JS => TS cleanup
* Trivial js => ts change

Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-05-10 17:54:58 -04:00
Alexander Skvortsov
dd8323ee36 Use github markdown utils in core, support key handlers (#2826)
This simplifies the markdown extension and allows BBCode to use these features.
It also allows undoing stuff like inserting replies/mentions
2021-05-10 17:53:32 -04:00
Alexander Skvortsov
104a31ba30 Run API Client requests through middleware (#2783)
- Add integration tests for login and registration
- Use URL instead of controller
- Add fluent API
- Allow setting parent request, user, session
2021-05-10 17:41:38 -04:00
flarum-bot
b0a26eb78c Bundled output for commit f9e8424620 [skip ci] 2021-05-10 20:07:59 +00:00
David Wheatley
f9e8424620 Add tooltip component (#2843)
* Add Tooltip component to common

Will be used to provide backwards compatibility when we switch to CSS tooltips.

All other methods of creating tooltips are deprecated and this component-based method should be used instead.

* Modify direct child instead of using container element

Instead of using a container to house the tooltip, we'll now modify the
first direct child of the Tooltip component.

The Tooltip component will ensure that:
- children are passed to it
- only one child is present
- that child is an actual HTML Element and not a text node, or similar
- that child is currently present in the DOM

Only after all of the above are satisfied, will the tooltip be created
on that element. We store a reference to the DOM node that the tooltip
should be created on, then use this to perform tooltip actions via
jQuery. If this element gets changes (e.g. the tooltip content is
updated to another element) then the tooltip will be recreated.

If any of the first 3 requirements are not satisfied, an error will
be thrown to alert the developer to their misuse of this component.

To make this work, we do need to overwrite the title attribute of
the element with the tooltip, but this is the only solution other than
specifying `title` as an option when making the tooltip, but this is
not accessible by screenreaders unless they simulate a hover on the
element.

* Add warning about component overwriting `title` attr

* Update previous uses of Tooltip component
2021-05-10 21:06:40 +01:00
flarum-bot
9bfb7f978d Bundled output for commit d4e3254395 [skip ci] 2021-05-09 22:10:56 +00:00
Alexander Skvortsov
d4e3254395 Use all Mithril lifecycle stubs (#2847) 2021-05-09 18:09:45 -04:00
David Wheatley
ceb567779e Remove spin.js, bump some dependencies (#2848) 2021-05-09 18:09:29 -04:00
flarum-bot
2e0d494bec Bundled output for commit 6d9bb709c7 [skip ci] 2021-05-09 21:35:04 +00:00
David Wheatley
6d9bb709c7 Fix typo in LoadingIndicator docblock 2021-05-09 22:33:33 +01:00
flarum-bot
915351baec Bundled output for commit 707889abc8 [skip ci] 2021-05-09 21:23:38 +00:00
David Wheatley
707889abc8 Fix required selector argument to Component.$() (#2844) 2021-05-09 17:22:22 -04:00
flarum-bot
2cd1c2964a Bundled output for commit 8a451e0bfc [skip ci] 2021-05-07 16:31:01 +00:00
Alexander Skvortsov
8a451e0bfc Fix exception in bootExtensions
Frontend extenders exist in a weird state of limbo, where they are technically defined, but aren't used or tested at all. In da5db714c2, we shifted from passing `extension.extend` to `flattenDeep` to calling `flat` on `extension.extend`. If an extension doesn't define extenders (as is the case for most extensions), the change breaks the forum. All we do here is add a null check.
2021-05-07 12:29:10 -04:00
flarum-bot
0b9ad5425c Bundled output for commit da5db714c2 [skip ci] 2021-05-05 23:29:41 +00:00
David Wheatley
da5db714c2 Remove lodash from core (#2827)
* Remove `lodash-es` dependency

* Replace `escapeRegExp` with home-made util

* Replace `throttle` with `throttle-debounce` library

* Use native browser methods for `deepFlatten`

We need a polyfill for iOS 11 and below. I think using a native method with this polyfill is better than having our own function instead, even if the bundle size is ~150B more.

* Save a few bytes in `escapeRegExp`

* Fix typo in comment

* Undo import re-organisation

* Use spread instead of slice

* Use smaller Array.flat polyfill from MDN

* Export new utils in `compat.js`
2021-05-06 00:28:22 +01:00
flarum-bot
d4a2357a32 Bundled output for commit 588a9f952f [skip ci] 2021-05-05 14:47:48 +00:00
David Wheatley
588a9f952f Remove unneeded delete (#2835) 2021-05-05 15:46:23 +01:00
Alexander Skvortsov
66233ce818 Remove unused variable 2021-05-04 18:15:05 -04:00
Alexander Skvortsov
7d4bd8a845 Centralize permission caching (#2832) 2021-05-04 13:56:14 -04:00
David Wheatley
3a6b8847f1 Mark JS dist folder as generated code (#2828)
This excludes it from the repo's language stats and are suppressed in Linguist diffs.

See: https://github.com/github/linguist/blob/master/docs/overrides.md#generated-code
2021-05-04 18:13:42 +01:00
Robert Korulczyk
2ffec2ee71 Update validation.yml. (#2829)
source: https://github.com/laravel/laravel/blob/v8.5.16/resources/lang/en/validation.php
2021-05-03 19:47:18 -04:00
Matt Kilgore
7eea2476ca Harden Headers (#2721)
* Basic security headers

* Remove XSS Header (not relevent)

* Fix config name

* Use Arr::get()

* Add tests

* Re-fix the StoreConfig step for fresh installs

Co-authored-by: luceos <luceos@users.noreply.github.com>
Co-authored-by: Alexander Skvortsov <askvortsov1@users.noreply.github.com>
2021-05-03 12:42:06 -04:00
Alexander Skvortsov
9711af42ae Apply fixes from StyleCI
[ci skip] [skip ci]
2021-05-03 05:36:06 +00:00
Alexander Skvortsov
d12d52918b Use latest version of settings package
This allows us to get rid of hacks for configuring settings and config
2021-05-03 01:35:46 -04:00
flarum-bot
ad92d11cf9 Bundled output for commit 3ca035f9aa [skip ci] 2021-05-02 16:14:09 +00:00
David Wheatley
3ca035f9aa Revamp notifications stylesheet (grid and flex) (#2822) 2021-05-02 17:13:04 +01:00
flarum-bot
bbff3a2748 Bundled output for commit f5cd5f202f [skip ci] 2021-05-02 10:38:26 +00:00
David Wheatley
f5cd5f202f Allow multiple methods to be provided to extend and override 2021-05-02 11:37:19 +01:00
flarum-bot
a78cbf644c Bundled output for commit 2de47a8656 [skip ci] 2021-04-30 17:00:49 +00:00
Alexander Skvortsov
2de47a8656 Fix package-lock
b45519974a accidentially commited a package-lock with symlinks, breaking the JS build process
2021-04-30 12:59:33 -04:00
Alexander Skvortsov
b45519974a Switch to ICU MessageFormat (#2759) 2021-04-30 12:44:39 -04:00
Alexander Skvortsov
edaf45d133 Remove unnecessary laravel config (#2796) 2021-04-30 00:31:19 +02:00
Matt Kilgore
6b9e991082 Move Powered By Header to headers config (#2777)
* Move Powered By Header to headers config
* Use Arr::get()
2021-04-30 00:30:01 +02:00
David Wheatley
8a431dc3cc [A11Y] Add focus ring mixin to restore ring to elements which no longer have it (#2814)
* Add focus ring mixin

These mixins allow us to restore default browser focus rings on elements which no longer have them.

* Add info about custom outline styles; use `#private` namespace and fix mixin name

I just learned that Less has namespaces! https://lesscss.org/features/#mixins-feature-namespaces
2021-04-29 22:10:17 +01:00
David Wheatley
91b1d9029e LESS should be capitalised as Less
See http://lesscss.org/
2021-04-29 22:07:46 +01:00
Daniël Klabbers
e337c10bb8 Revision compiler revised (#2805)
- revisions now use <asset>.<type>?v=<revision> instead of <asset>-<revision>.<type>- remove deprecated filename for revision method
- reconsider use of cache differentiator and implement something that
prevents recompiling css every single time
- allow force recompilation
2021-04-29 16:49:36 -04:00
Daniël Klabbers
e0258d2708 error handling when extending flarum from extensions fails (#2740) 2021-04-29 16:17:41 -04:00
Daniël Klabbers
fcb5778705 fixed container bindings use of container (#2807) 2021-04-29 15:33:51 -04:00
Sami Mazouz
40b47de9e1 Remove ExtensionPage CSS over-specification (#2792) 2021-04-29 16:31:37 +01:00
Daniël Klabbers
deadd67691 clarify callable arguments for password checker (#2812) 2021-04-29 10:19:06 -04:00
flarum-bot
c119731e65 Bundled output for commit 2b7e7f3ff4 [skip ci] 2021-04-26 16:15:37 +00:00
Sami Mazouz
2b7e7f3ff4 Fix class naming (#2811) 2021-04-26 17:14:22 +01:00
flarum-bot
f4acb2c5db Bundled output for commit f9779284e4 [skip ci] 2021-04-22 22:37:03 +00:00
David Wheatley
f9779284e4 Add users list to admin dashboard (#2626)
* Commit initial WIP code

* Fix squashed grid on mobile

* Add pagination support; rename to userList

* Improve grid sizing

* Improve grid row shading

* Move EditUserModal to common

* Add link to profile page in grid

* Use Less styling vars

* Move EditUserModal translations to lib

* Add edit user button to grid

* Fix incorrect profile link priority

* Update profile link translation key

* Add priorities to other columns

* Add group badges to grid

* Add username to profile link tooltip

* Organise imports

* Use variable for header border bottom color

* Fix broken export

* Add total user count to API payload's metadata

* Add new metadata to ApiPayload type

* Implement correct page number

* Remove debug code

* Use function to get the total pages

This allows us to use the raw count elsewhere in the component (pssst... check the next commit!)

* Center profile link in column

* Add profile link header

* Show total users above table

* Use ItemList's itemName property for column data attributes

* Add user email column, hidden by default

This column is hidden by default using a placeholder email and blur filter. These are then removed when the visibility toggle is pressed.

This prevents any over-the-shoulder accidental data leakage, as emails are classed as PII under GDPR.

* Fix incorrect tooltip translation keys

* Add extra padding between email and visibility toggle button

* Prevent selection of blurred email

* Fix incorrect icon state for email toggle

* Update API response type to include metadata (for now)

* Increase number of users per page to 50

* Update compat files with new locations

* Format

* Add @deprecated notices for forum compat export

* Use AdminPayload for user count instead of supplying as REST API metadata

* Make nav look less squashed using bottom margin

* Suppress TS warning

* StyleCI fixes

* Fix TS error

* Update based on review comments

* Rename user list -> users

* Rename internal instances of user_list to users

* Fix formatting

* Use CSS custom properties for the table column count

* Use .Button--icon instead of custom style

* Make fake email more realistic length

* Add a11y attributes

* Use padding bottom instead of margin bottom for page spacing

* Make compatible with new CSS LoadingIndicator

I won't let it break here! :P

* Integrate profile link into username column

* Don't force columns to be 300px

This made the grid look very bloated and intimidating -- lets instead increase the padding between items and make it only the width it needs to be.

* Center edit user button in column

* Increase spacing between email and visibility toggle button

* Rename `statistics` to `modelStatistics` in Admin payload

This prevents any possible conflicts with core and `flarum/statistics`. We might want to consider migrating the stats extension to extend this object in the future.

* Update comments, fix TS error

* Various translation key changes

* Change gmail.com -> example.com

* Stretch 'edit user' button to entire cell size

* Update translations

* Is the YAML formatted right this time? 🙈

* Remove email placeholder

Fixes an issue where the table would jump if an email was unhidden that was longer than the placeholder.

* Re-order lib translations

* Clicking blurred email now unblurs

* Correct header class

* Improve edit user button centring

* Improve vertical row item centering

* Fix incorrect column length in aria attribute

* Use .Button--text!
2021-04-22 23:35:42 +01:00
flarum-bot
43d6b3104d Bundled output for commit 33bd99d376 [skip ci] 2021-04-21 11:27:23 +00:00
David Wheatley
33bd99d376 Fix uses of loading spinner (#2797)
* Update Loading Indicator

- Fix mistake in LoadingIndicator Less
- Middle align the loading indicator when inline
- Fix Loading Indicator not correctly accepting container class names
- Add inline and block attributes

* Fix loading indicator in composer

* Fix loading indicator on notification list

* Fix loading indicator on discussion page

* Fix loading indicator on button

* Update more uses of loading indicator

* Fix loading indicator in Search box

* Fix AvatarEditor loading spinner

* Set default spinner props

* Replace "tiny" with "small" in Less

* Improve spinner vertical centring in buttons

* Reduce size specificity

* Use single attribute for block/inline

* Use new display attribute

* Use classes for different sizes

* Use `display=block` by default
2021-04-21 12:26:09 +01:00
Alexander Skvortsov
eb4b18a979 Combine search tests
#b62debf031f1d3aec9cb5e92d9df54cb8ab3a3b1 and #b6f0b01307884b11388eff1ae2d814b7f57715aa
 both added/improved searching tests, but did so in separate files. As a result, the tests did not consider each other, and when both were merged, started failing. This commit combines the tests into one file that tests both order and search in titles.
2021-04-20 19:16:59 -04:00
Sami Mazouz
b62debf031 Add user id slug driver (#2787) 2021-04-20 23:52:53 +01:00
Alexander Skvortsov
1f2411e15e Fix searching titles in discussions (#2698)
* Fix searching titles in discussions

* Apply fixes from StyleCI

* Fix tests

* Distinct by discussion ID

* Replace distinct with groupBy

Co-authored-by: Alexander Skvortsov <askvortsov1@users.noreply.github.com>
2021-04-20 18:52:14 -04:00
flarum-bot
d99df936b1 Bundled output for commit 9716a15c31 [skip ci] 2021-04-20 16:26:39 +00:00
David Wheatley
9716a15c31 Add accessibility attributes to loading spinner (#2799) 2021-04-20 17:25:23 +01:00
Alexander Skvortsov
5e2340bf10 Fix registering custom searchers, allow searchers without fulltext (#2755) 2021-04-19 16:59:53 -04:00
Alexander Skvortsov
c84939b19c Filesystem Extender and Tests (#2732) 2021-04-19 16:25:08 -04:00
Alexander Skvortsov
4974c91481 Asset Publish Command (#2731) 2021-04-19 15:51:28 -04:00
Alexander Skvortsov
f67149bb06 Use Laravel filesystem interface for assets and avatars (#2729)
* WIP: Use Laravel filesystem interface where possible
* Drop vendorFilesystem
* Support getting URL of cloud-based logo and favicon
* FilesystemAdapter should always be cloud
* Get base avatar URL from filesystem adapter
* Restore deleted getAsset method

Co-authored-by: Alexander Skvortsov <askvortsov1@users.noreply.github.com>
2021-04-19 21:11:03 +02:00
Alexander Skvortsov
a2d77d7b81 Rename relevant migration so it runs again (#2793) 2021-04-19 14:14:07 -04:00
flarum-bot
da4264c8a3 Bundled output for commit 0f9526ba9f [skip ci] 2021-04-19 14:37:25 +00:00
Alexander Skvortsov
0f9526ba9f Adjust search height on resize (#2775)
Identified as a potential issue in https://github.com/flarum/core/pull/2650

When typing, the keyboard generally obstructs half the screen. However, when the keyboard is closed, search results don't expand to take up full space.
2021-04-19 10:36:04 -04:00
Alexander Skvortsov
e77365f32f Add id to migrations table (#2794) 2021-04-19 10:35:21 -04:00
Alexander Skvortsov
c7c456cb3e Remove unused container argument 2021-04-18 17:20:14 -04:00
Alexander Skvortsov
fb51fb4e6d Drop session from user class (#2790)
This was originally introduced in 3612ca7aca, but has not seen usage, since usually when the session needs to be modified, the request is available.

It causes issues with certain queue drivers, as it can't be serialized.

It's also not entirely accurate, as a user can have multiple sessions at once. Therefore, a given session is a property of the request, not of the user.

The reason this causes issues in the Queue is that when a Job has payload that consists User(s), the Queue will try to serialize that. Serializing the User object will require serializing the session too; this causes a Serialization of Closure is not allowed error, see image.

One can circumvent that in many ways, the most obvious one is adding a __sleep and __wakeup implementation in the User class (or the session handler). But as we aren't really using the session on the User model anywhere in core, bundled or most community extensions it is best to simply detach this from the user.
2021-04-16 15:53:05 -04:00
Sami Mazouz
5b7d364b87 Update laravel docs references to 8.x (#2788) 2021-04-16 13:26:15 +01:00
Sami Mazouz
39a6106854 Add unparse to Formatter extender (#2780) 2021-04-14 11:34:49 +01:00
Sami Mazouz
9e3699ea47 Access request actor in error handler (#2410)
* Add an ActorReference class to store the actor `$request->getAttribute('actorReference')->getActor()`
* Add a middleware to inject the actor reference
* Deprecate `$request->getAttribute('actor')`
2021-04-12 18:42:22 +01:00
Alexander Skvortsov
b6f0b01307 Fix relevance sort (#2773)
- Adds a field to QueryCriteria that determines whether the sort provided is the controller's default sort
- Set this field to true iff sort not in query params. Default it to false
- Override $sort if a new default sort has been set on search state, and the param is true.
- Add tests!
2021-04-11 22:21:56 -04:00
Sami Mazouz
548f1321f1 Require unique route names (#2771) 2021-04-10 20:38:25 +01:00
flarum-bot
e376cf2079 Bundled output for commit 286027ff27 [skip ci] 2021-04-10 14:45:12 +00:00
David Wheatley
286027ff27 Push lockfile from Linux to fix missing chokidar 2021-04-10 14:39:05 +00:00
David Wheatley
e52b769ceb Add option to build with Webpack Bundle Analyzer (#2708)
* Add option to build with webpack bundle analyzer

* Bump npm to v7 as recommended in actions/setup-node#213

* Workaround for npm/cli#558

* Add missing dep
2021-04-10 15:00:48 +01:00
Adam Hosker
b1f166d82a Remove MyISAM Requirement (#2442)
- Remove Database Engine Default of InnoDB
- Remove Hard Coded MyISAM requirement
2021-04-09 08:13:47 -04:00
flarum-bot
63675c81d6 Bundled output for commit f76524a5de [skip ci] 2021-04-08 23:43:36 +00:00
David Wheatley
f76524a5de Replace spin.js with a CSS-only loading spinner (#2764)
* Create CSS only loading indicator

* Core mods to fix Loading Indicator usage

* Remove extra whitespace

* Attrs interface extends ComponentAttrs and is exported

* Add doc block about custom styling
2021-04-09 00:42:32 +01:00
David Wheatley
c006931798 Cache npm cache between JS build runs (#2710) 2021-04-08 20:29:37 +01:00
flarum-bot
a5ec39b5cf Bundled output for commit c75db75efe [skip ci] 2021-04-08 11:36:26 +00:00
David Wheatley
c75db75efe Bump dependencies, add missing typing libraries (#2753)
* Bump dependencies and add missing typing libraries

* Fix expose-loader breaking changes

* Expose jQuery using its own typings instead of ours

* Extend jQuery typings with our own custom $.fn helpers

* Use jQuery typings for Component's `this.$` attribute

* Format webpack config file

* Use Spin.js 3.1.0
2021-04-08 12:35:10 +01:00
David Wheatley
300dadff60 Add code scanning workflow to identify common issues (#2744)
* Add code scanning workflow to identify common issues

* Don't run CodeQL if the only changes in a push/PR are .less or .md files

* Change cron

* Change workflow name to include language

* Make indents consistent with other workflows
2021-04-08 12:15:27 +01:00
Alexander Skvortsov
94d69fe15f Introduce RequestUtil to encapsulate getting/setting actor on requests(#2449) 2021-04-07 23:33:05 -04:00
Alexander Skvortsov
da598db376 Allow configuring default enabled extensions as part of installation (#2757)
This is needed for the testing library
2021-04-07 22:47:54 -04:00
Alexander Skvortsov
d31e0573f8 Don't fail silently on cache clear (#2756) 2021-04-07 22:13:08 -04:00
Sami Mazouz
2968341f77 Fix a missed getRouteData() (#2774) 2021-04-07 20:08:21 -04:00
flarum-bot
9839370701 Bundled output for commit 40dc6d0feb [skip ci] 2021-04-07 22:26:04 +00:00
Alexander Skvortsov
40dc6d0feb Preloaded API document Improvements (#2754)
* Invalidate preloadedApiDocument if URL has changed
* Revert to using `getRouteData()[0]`
2021-04-07 23:25:01 +01:00
flarum-bot
945f6478b5 Bundled output for commit 69a10c97be [skip ci] 2021-04-07 18:31:38 +00:00
David Wheatley
69a10c97be Merge "Remove unneeded vendor prefixes" (#2766) 2021-04-07 19:30:15 +01:00
Daniël Klabbers
0074f0c984 Removes duplication of cache clearing (#2738) 2021-04-07 17:29:32 +01:00
David Wheatley
19465fb522 Fix missing vendor prefix on post scrubber; move styles to Less 2021-04-05 23:19:52 +01:00
David Wheatley
0fe7723a7f Remove unneeded vendor prefixes 2021-04-05 20:27:47 +00:00
flarum-bot
fbe2813378 Bundled output for commit 4b69a35260 [skip ci] 2021-04-05 15:28:37 +00:00
David Wheatley
4b69a35260 Replace classList with clsx library (#2760) 2021-04-05 16:27:16 +01:00
Alexander Skvortsov
5e8155e1cc Remove unnecessary and imperceptible fade (#2685)
This concern was raised in https://discuss.flarum.org/d/26422-idearequest-make-header-background-color-match-exact-value-from-config.
2021-04-04 01:49:31 +01:00
flarum-bot
0f0f2b6d4e Bundled output for commit 3dae397c65 [skip ci] 2021-04-03 02:16:32 +00:00
David Wheatley
3dae397c65 Merge "Small Admin Patches" (#2739) from flarum/ck/adminux-patch2 into master
- Fixes #2736
- Fixes #2728
2021-04-03 03:14:41 +01:00
David Wheatley
7025a7f5e0 Pin GitHub Actions at specific tags and commits (#2748)
* Pin 3rd party action

* Pin GitHub-maintained actions to tag

* Bump Bundlewatch Node.js to v14 LTS

I have no clue what my thought process was when creating this workflow
initially. Thrown this in here as it's a minor change and it's silly to
make a PR just to update this number, in my opinion.
2021-04-03 01:00:26 +01:00
flarum-bot
12f6b1b375 Bundled output for commit 2de57af7c8 [skip ci] 2021-03-30 00:20:26 +00:00
David Sevilla Martin
2de57af7c8 Move forum & admin app declarations to separate files 2021-03-29 20:19:15 -04:00
Sami Mazouz
1c4817a0b3 Eager loading extender (#2724)
* Eager loading extender
* Add tests for the eager loading extender
2021-03-25 15:36:39 +01:00
KyrneDev
0eefbf0374 Help on redraw 2021-03-24 17:30:13 -10:00
KyrneDev
90c0bc410e Null name/desc breaks search fix 2021-03-24 17:29:54 -10:00
Sami Mazouz
d642fb531c Improve ApiSerializer tests (#2733)
The ApiSerializerTest was added before the ApiController extender, so I used a workaround at the time to check for the existence of the relationships on the serializer.
2021-03-23 17:33:51 -04:00
Alexander Skvortsov
706eaeda41 Use anonymous class for FakeApp (#2725)
It's a better implementation than declaring a second class in the same file, which can confuse IDEs. Furthermore, FakeApp shouldn't be used outside this file.
2021-03-22 19:00:36 +01:00
Sami Mazouz
3cc18c1da2 Eager load ListPostsController needed relations (#2717)
* Eager load ListPostsController needed relations
* Add comment explaining the reason for eagerloading
2021-03-22 09:54:18 +01:00
Alexander Skvortsov
8dd57ffed2 Include task scheduler in core 2021-03-19 18:01:38 -04:00
Alexander Skvortsov
d29495203b Move laravel helpers back in, deprecate perpetually 2021-03-19 18:01:38 -04:00
flarum-bot
783c563305 Bundled output for commit 908d087e00 [skip ci] 2021-03-19 18:14:58 +00:00
Alexander Skvortsov
908d087e00 Remove deprecated code from beta 16 (#2705) 2021-03-19 19:13:50 +01:00
sl-kr
374189d48e Refactor AccountActivationMailer and SendConfirmationEmailController (#2493)
* Add AccountActivationMailerTrait and use in AccountActivationMailer and SendConfirmationEmailController
* Remove prefix

Co-authored-by: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com>
2021-03-19 18:06:41 +01:00
flarum-bot
fe8dda6fd0 Bundled output for commit cd9ee48af6 [skip ci] 2021-03-18 22:04:58 +00:00
David Wheatley
cd9ee48af6 [A11Y] Add aria-label and landmark role to search input (#2669)
* Adds role="search" to Search container
* Add aria-label to search input

See this page for more info:
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Search_role
2021-03-18 23:03:01 +01:00
flarum-bot
2e9078a7cf Bundled output for commit 0cc12aed95 [skip ci] 2021-03-18 21:39:56 +00:00
David Wheatley
0cc12aed95 [A11Y] Fix nav drawer being focusable when off-screen on small viewports (#2666)
* Fix nav drawer being focusable when off-screen on small viewports

Fixes #2565

* Implement review suggestions

* Format
2021-03-18 22:38:32 +01:00
David Wheatley
59fdd7628a Speed up JS linting (#2709)
* Install Prettier only, instead of all deps

* Allow running on workflow dispatch

Allows manually triggered CI runs by org members

* Update Node to latest LTS; update step descriptions
2021-03-18 21:14:10 +00:00
David Wheatley
298f6c39f2 Add bundlewatch to track bundle size changes in PRs (#2695)
(Below steps already performed, but kept for future reference.)

Head here to get auth ID: https://service.bundlewatch.io/setup-github
Create repo secret called `BUNDLEWATCH_GITHUB_TOKEN` with the token inside
2021-03-17 14:54:42 +00:00
Alexander Skvortsov
233b97329c Drop the generate:migration command (#2686)
Core source code should contain things necessary for core to run. Development tooling like this belongs in external packages, like the upcoming Flarum CLI.
2021-03-16 12:41:07 -04:00
flarum-bot
1b5b143930 Bundled output for commit 0d139e6133 [skip ci] 2021-03-16 14:52:59 +00:00
David Wheatley
0d139e6133 [A11Y] Add aria-label to dropdown toggles (#2668)
Implement custom accessible dropdown toggle labels for forum components

Making the a11y label more specific to the specific action it performs is critical for good UX with assistive technologies.
2021-03-16 10:50:36 -04:00
Ian Morland
0e6a60bd5b Canonical URL: use UrlGenerator in place of extracting the url from request (#2674) 2021-03-15 21:43:59 -04:00
flarum-bot
6e4c75eba6 Bundled output for commit 386f3d3db1 [skip ci] 2021-03-16 01:43:29 +00:00
David Sevilla Martín
386f3d3db1 Fix Stream function code being shown when renaming discussion (#2693) 2021-03-15 21:42:22 -04:00
Alexander Skvortsov
9fffb8ec1a L8 requires constructor arguments to PhpEngine 2021-03-15 12:48:47 -04:00
Daniel Klabbers
92e590f1ab Release v0.1.0-beta.16 constant updated 2021-03-15 16:21:21 +01:00
Daniel Klabbers
098908cb4a Release v0.1.0-beta.16 2021-03-15 16:09:23 +01:00
Sami Mazouz
901846d0cf Beta 16 Changelog (#2687)
* Beta 16 Changelog

* Review tweaks

* Consistent letter casing

* IOS -> iOS

* Removed accidentally added F

* Csrf -> CSRF

Co-authored-by: David Wheatley <hi@davwheat.dev>
2021-03-15 14:55:47 +01:00
Daniel Klabbers
5a3aefb76c npm audit fix 2021-03-15 13:25:12 +01:00
Alexander Skvortsov
cf2a636e81 Apply GetModelIsPrivate BC mode to CommentPost, not Post 2021-03-13 17:16:18 -05:00
Alexander Skvortsov
a8ba510655 Fix ModelPrivate docblocks 2021-03-13 17:15:50 -05:00
Alexander Skvortsov
9c3b6c596f Merge pull request #2684 from flarum/as/filter-mutator-consistency
Make filter mutator API consistent with search mutator API.
2021-03-13 17:01:33 -05:00
Alexander Skvortsov
2310d782a3 Fix Index content, only use search when applicable. 2021-03-12 15:30:36 -05:00
Alexander Skvortsov
e9642250ae Provide active filters to filter state 2021-03-12 15:30:14 -05:00
flarum-bot
a6dd545dbc Bundled output for commit a64c39835a [skip ci] 2021-03-12 05:35:57 +00:00
Alexander Skvortsov
a64c39835a Fix shaky composer on safari mobile
When the composer is opened while scrolled to the absolute bottom of the page (via hitting the "reply" button, `window.scrollTop` has a value of ~600px greater than it should. This doesn't seem to be the composer element's height (which appears to be 0 at the time). This incorrect scrollTop positions the composer off screen, which causes Safari to freak out and shake the element violently as it tries to scroll to the cursor (which is now off screen).

We can get around this by calculating scrollTop ourselves.

Fixes https://github.com/flarum/core/issues/2683
2021-03-12 00:23:37 -05:00
Alexander Skvortsov
db0d8e89c7 Make filter mutator API consistent with search mutator API.
This is inline with the docblock for the Filter extender, and is much more sensible.
2021-03-11 23:12:49 -05:00
flarum-bot
4e126708e9 Bundled output for commit b88a7cb33b [skip ci] 2021-03-09 03:46:55 +00:00
Alexander Skvortsov
b88a7cb33b Search: dont adjust height if not rendered 2021-03-08 22:45:39 -05:00
flarum-bot
a2f52c09fd Bundled output for commit 30017eef09 [skip ci] 2021-03-08 21:31:49 +00:00
Alexander Skvortsov
30017eef09 Send username as author filter value instead of id.
For consistency with the Discussion AuthorFilterGambit, this should be sent usernames, not numerical ids.
2021-03-08 16:29:48 -05:00
flarum-bot
d0ffa26b0b Bundled output for commit 612a57c466 [skip ci] 2021-03-08 21:25:06 +00:00
Alexander Skvortsov
612a57c466 Use new author key for filtering posts
Fixes https://github.com/flarum/core/issues/2671
2021-03-08 16:21:36 -05:00
Alexander Skvortsov
91e8b56961 Add deprecated "user" filter for posts
In the filterer refactor for ListPostsController, the filter key was changed to `author` for consistency with the AuthorFilterGambit used in discussions. This commit adds a deprecated `user` filter back in for a release to allow for a graceful transition
2021-03-08 16:20:26 -05:00
flarum-bot
ba9665e9db Bundled output for commit 8eea0985a4 [skip ci] 2021-03-07 22:37:00 +00:00
Alexander Skvortsov
8eea0985a4 Split JSDoc directives to separate lines. 2021-03-07 17:35:58 -05:00
flarum-bot
1bcb9d3ea1 Bundled output for commit 2c3e1f9923 [skip ci] 2021-03-07 21:33:50 +00:00
Alexander Skvortsov
2c3e1f9923 Use flarum/testing for test infrastructure (#2545) 2021-03-07 16:32:41 -05:00
Sami Mazouz
bc607e089e Eagerload some needed relations in ListDiscussionsController (#2639) 2021-03-07 16:32:23 -05:00
Sami Mazouz
91d5d9c176 Use absolute positioning for the Composer on Safari (#2660) 2021-03-07 16:31:46 -05:00
Alexander Skvortsov
3aa118ab94 Fix search box out of screen (#2650)
Programatically set search results max height
2021-03-07 16:31:23 -05:00
Daniël Klabbers
4b0ad6972d added optional powered-by header (#2618) 2021-03-05 10:05:13 -05:00
Daniël Klabbers
84ded0ce50 Laravel components v8 (#2576)
- update actions ci
- include json for 4 spaces tab
- provide output int for process code exit
- adhere to parent type hint of builder
- mailer instance now needs a name, multiple can be instantiated
- getOriginal now uses mutators in the model
- Temporarily loosen MailableInterface requirements. This avoids an immediate BC break for classes in extensions that implement this interface.
- Temporarily provide (and autoload) old symfony translator interface
- make queue exception handler compatible with the contract of L8
- Update phpunit schema for newer version
- Update phpunit assert calls for newer version
2021-03-05 09:43:35 -05:00
Sami Mazouz
725863a6e2 Move TextEditor styles to common (#2661)
Now that TextEditor js component is shared, it only makes sense to also 
have its styles shared
2021-03-05 08:14:19 -05:00
Alexander Skvortsov
c81f629b0b Rename app to container (#2609)
* Rename `app` helper to `resolve`, deprecate old version
* Rename $this->app to $this->container in service providers

We no longer couple Flarum\Foundation\Application to the Laravel container; instead, we use the container separately. Changing our naming to reflect that will make things clearer.
2021-03-04 22:14:48 -05:00
flarum-bot
15cbe4daaa Bundled output for commit ddac07d991 [skip ci] 2021-03-04 21:52:50 +00:00
Alexander Skvortsov
ddac07d991 Move TextEditor to common (#2649) 2021-03-04 16:51:34 -05:00
Clark Winkelmann
08ba2599d7 Refactor Access Tokens (#2651)
- Make session token-based instead of user-based
- Clear current session access tokens on logout
- Introduce increment ID so we can show tokens to moderators in the future without exposing secrets
- Switch to type classes to manage the different token types. New implementation fixes #2075
- Drop ability to customize lifetime per-token
- Add developer access keys that don't expire. These must be created from the database for now
- Add title in preparation for the developer token UI
- Add IP and user agent logging
- Delete all non-remember tokens in migration
2021-03-04 16:50:38 -05:00
Blake Payne
8eef7230e9 Updated GroupFilterGambit to prevent hidden groups being visible wher… (#2657)
Updated GroupFilterGambit to prevent hidden groups being visible where they shouldn't be and to ensure that only the selected groups are returned on a search. Fixes #2559
2021-03-04 10:08:12 -05:00
flarum-bot
a61f9e7328 Bundled output for commit a65e1de641 [skip ci] 2021-03-03 23:52:04 +00:00
daniellesniak
a65e1de641 Convert common helpers to Typescript (#2541) 2021-03-03 18:50:54 -05:00
681 changed files with 25690 additions and 5806 deletions

View File

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

1
.gitattributes vendored
View File

@@ -11,5 +11,6 @@ phpunit.xml export-ignore
tests export-ignore
js/dist/* -diff
js/dist/* linguist-generated
* text=auto eol=lf

2
.github/SECURITY.md vendored
View File

@@ -2,7 +2,7 @@
## Supported Versions
During the beta phase, we will only patch security vulnerabilities in the latest beta release.
We will only patch security vulnerabilities in the stable 1.x release.
## Reporting a Vulnerability

View File

@@ -7,10 +7,27 @@ on:
jobs:
build:
name: JS / Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: flarum/action-build@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check out code
uses: actions/checkout@v2
- name: Restore npm cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('js/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# Our action will install npm, cd into `./js`, run `npm run build` and
# `npm run build-typings`, then commit and upload any changes
- name: Build production JS
uses: flarum/action-build@2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
build_script: build
package_manager: npm
typings_script: build-typings

76
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,76 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
# Run on:
# - pushes to master, or
# - PRs with a base of `master`
# - which do not **only** consist of changes to .md or .less files
on:
push:
branches: [ master ]
paths-ignore:
- '**/*.md'
- '**/*.less'
pull_request:
branches: [ master ]
paths-ignore:
- '**/*.md'
- '**/*.less'
schedule:
- cron: '0 0 * * 1,3,5'
jobs:
analyze:
name: Analyze / ${{ matrix.language }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View File

@@ -1,6 +1,7 @@
name: Lint
on:
workflow_dispatch:
push:
paths:
- 'js/src/**'
@@ -10,22 +11,18 @@ on:
jobs:
prettier:
name: JS / Prettier
runs-on: ubuntu-latest
name: JS / Prettier
steps:
- uses: actions/checkout@master
- name: Check out code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: "12"
node-version: "14"
- name: Install JS dependencies
run: npm ci
working-directory: ./js
- name: Check JS code for formatting
run: node_modules/.bin/prettier --check src
- name: Check JS formatting
run: npx prettier --check src
working-directory: ./js

45
.github/workflows/pr_size_change.yml vendored Normal file
View File

@@ -0,0 +1,45 @@
name: Bundle size checker
on:
workflow_dispatch:
push:
paths:
- "js/**"
pull_request:
paths:
- "js/**"
jobs:
bundlewatch:
runs-on: ubuntu-latest
name: Bundlewatch
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "14"
- name: Use npm v7
run: sudo npm install -g npm@7.x.x
- name: Install JS dependencies
# We need to use `npm install` here. If we don't, the workflow will fail.
run: npm install
working-directory: ./js
- name: Build production assets
run: npm run build
working-directory: ./js
- name: Check bundle size change
run: node_modules/.bin/bundlewatch --config .bundlewatch.config.json
working-directory: ./js
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
CI_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

View File

@@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
php: ['7.2', '7.3', '7.4', '8.0']
php: [7.3, 7.4, '8.0']
service: ['mysql:5.7', mariadb]
prefix: ['', flarum_]
@@ -21,12 +21,6 @@ jobs:
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_
@@ -49,10 +43,11 @@ jobs:
name: 'PHP ${{ matrix.php }} / ${{ matrix.db }} ${{ matrix.prefixStr }}'
steps:
- uses: actions/checkout@master
- name: Check out code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
uses: shivammathur/setup-php@0b9d33cd0782337377999751fc10ea079fdd7104 # pin@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
@@ -80,3 +75,5 @@ jobs:
- name: Run Composer tests
run: composer test
env:
COMPOSER_PROCESS_TIMEOUT: 600

1
.gitignore vendored
View File

@@ -4,6 +4,7 @@ composer.phar
node_modules
.DS_Store
Thumbs.db
tests/.phpunit.result.cache
/tests/integration/tmp
.vagrant
.idea/*

View File

@@ -12,7 +12,3 @@ disabled:
- phpdoc_order
- phpdoc_separation
- phpdoc_types
finder:
exclude:
- "stubs"

View File

@@ -1,5 +1,172 @@
# Changelog
## [1.0.2](https://github.com/flarum/core/compare/v1.0.1...v1.0.2)
### Fixed
- Critical XSS vulnerability
## [1.0.1](https://github.com/flarum/core/compare/v1.0.0...v1.0.1)
### Fixed
- Installation fails on environments without proc_* functions enabled or mysql client binary (https://github.com/flarum/core/issues/2890)
## [1.0.0](https://github.com/flarum/core/compare/v0.1.0-beta.16...v1.0.0)
### Added
- Task scheduling
- `load()` method on `ApiController` extender to allow eager loading of relations (https://github.com/flarum/core/pull/2724)
- Installation supports enabling a set of extensions (https://github.com/flarum/core/pull/2757)
- RequestUtil helper class added to abstract the logic of the actor, session, locale and route name from the request (https://github.com/flarum/core/pull/2449)
- Code scanning action with GitHub CodeQL (https://github.com/flarum/core/pull/2744)
- The Formatter extender now has an `unparse` method to allow extensions to hook into the unparsing of content (https://github.com/flarum/core/pull/2780)
- A Filesystem extender allows direct modification and addition of filesystem disks (https://github.com/flarum/core/pull/2732)
- A slug driver based on the User ID was introduced (https://github.com/flarum/core/pull/2787)
- An extensible users list was added to the admin area (https://github.com/flarum/core/pull/2626)
- Headers hardened by adding Referer Policy, Xss Protection and Content type (https://github.com/flarum/core/pull/2721)
- Tooltip component (https://github.com/flarum/core/pull/2843)
- Moved `insertText` and `styleSelectedText` from markdown to core (https://github.com/flarum/core/pull/2826)
- A squashed database schema install dump to speed up new installs (https://github.com/flarum/core/pull/2842)
- Pagination in the canonical URL for discussion pages (https://github.com/flarum/core/pull/2853)
- PaginatedListState for the DiscussionList and to support paginated lists in the frontend (https://github.com/flarum/core/pull/2781)
- Introduce the new webpack config and flarum-tsconfig for typehinting (https://github.com/flarum/core/pull/2856)
### Changed
- Now tracking bundle sizes to keep an eye on web performance (https://github.com/flarum/core/pull/2695)
- Eager load relations on ListPostsController to improve performance (https://github.com/flarum/core/pull/2717)
- Replace classList with clsx library (https://github.com/flarum/core/pull/2760)
- Replaced the javascript based loading spinner with a pure CSS version (https://github.com/flarum/core/pull/2764)
- Route names now have to be unique (https://github.com/flarum/core/pull/2771)
- ActorReference is now available from the error handler middleware (https://github.com/flarum/core/pull/2410)
- The `migrations` table now has an Auto Increment ID (https://github.com/flarum/core/pull/2794)
- Assets and avatars are now managed using Laravel filesystem disks (https://github.com/flarum/core/pull/2729)
- Extracted asset publishing (`php flarum assets:publish`) from migrating (https://github.com/flarum/core/pull/2731)
- Assets were compiled in the format `<asset>-<revision>.<js|css>`, this is now `<asset>.<js|css>?v=<revision>` (https://github.com/flarum/core/pull/2805)
- The powered by header can now be configured in the config under `headers` (https://github.com/flarum/core/pull/2777)
- Switched to the ICU format for translation files (https://github.com/flarum/core/pull/2759)
- Allow extend and override to apply to multiple methods in one call
- Notifications dropdown and list refactored (https://github.com/flarum/core/pull/2822)
- Updated validation locale strings based on Laravel 8 changes (https://github.com/flarum/core/pull/2829)
- Caching of permissions is now taken care of centrally, reducing code duplication (https://github.com/flarum/core/pull/2832)
- Replaced lodash-es by throttle-debounce to reduce bundle size (https://github.com/flarum/core/pull/2827)
- Internal API requests are now executed through middleware (https://github.com/flarum/core/pull/2783)
- Permission changes: `viewDiscussions` to `viewForum` and `viewUserList` to `searchUsers` (https://github.com/flarum/core/pull/2854)
### Fixes
- Javascript is shown when editing the title of a discussion (https://github.com/flarum/core/pull/2693)
- Canonical url logic uses request object which causes wrong URL's when a different page is default (https://github.com/flarum/core/pull/2674)
- Dropdown toggle has no aria label (https://github.com/flarum/core/pull/2668)
- Nav drawer is focusable when off-screen on small viewports (https://github.com/flarum/core/pull/2666)
- Search input has no aria-label and no role (https://github.com/flarum/core/pull/2669)
- Code duplication exists between SendConfirmationEmailController and AccountActivationMailer (https://github.com/flarum/core/pull/2493)
- When setting tags as homepage default, visiting a tag will show all posts (https://github.com/flarum/core/pull/2754)
- Locale cache is cleared twice when cache clearing (https://github.com/flarum/core/pull/2738)
- When cache clearing fails an exception can be thrown due to a partial flush (https://github.com/flarum/core/pull/2756)
- Database migrations rely on MyISAM even though the eventual migrated database does not use it (https://github.com/flarum/core/pull/2442)
- Discussion search result is not sorted by relevance by default (https://github.com/flarum/core/pull/2773)
- Extensions cannot register custom searcher classes (https://github.com/flarum/core/pull/2755)
- Searching discussion titles is not possible (https://github.com/flarum/core/pull/2698)
- Boot errors due to failing extenders throw a generic error (https://github.com/flarum/core/pull/2740)
- Required argument to `Component.$()` isn't really required (https://github.com/flarum/core/pull/2844)
- Component does not allows use of all mithril lifecycle functionality (https://github.com/flarum/core/pull/2847)
### Removed
- The `make:migration` command has been removed (https://github.com/flarum/core/pull/2686)
- Background fade on the header has been removed (https://github.com/flarum/core/pull/2685)
- Remove vendor prefixes in less (https://github.com/flarum/core/pull/2766)
- The session is no longer available from the User class (https://github.com/flarum/core/pull/2790)
- The `mail` key is removed from the laravel related config (https://github.com/flarum/core/pull/2796)
## [0.1.0-beta.16](https://github.com/flarum/core/compare/v0.1.0-beta.15...v0.1.0-beta.16)
### Added
- Allow event subscribers (https://github.com/flarum/core/pull/2535)
- Allow Settings extender to have a default value (https://github.com/flarum/core/pull/2495)
- Allow hooking into the sending of notifications before being send (https://github.com/flarum/core/pull/2533)
- PHP 8 support (https://github.com/flarum/core/pull/2507)
- Search extender (https://github.com/flarum/core/pull/2483)
- User badges to post preview (https://github.com/flarum/core/pull/2555)
- Optional extension dependencies allow a booting order (https://github.com/flarum/core/pull/2579)
- Auth extender (https://github.com/flarum/core/pull/2176)
- `X-Powered-By` header added to allow indexers easier data aggregation of Flarum adoption (https://github.com/flarum/core/pull/2618)
### Changed
- Run integration tests in transaction (https://github.com/flarum/core/pull/2304)
- Allow policies to return a boolean for simplified allow/deny (https://github.com/flarum/core/pull/2534)
- Converted highlight helper to typescript (https://github.com/flarum/core/pull/2532)
- Add accessibility attributes to Mark as Read button (https://github.com/flarum/core/pull/2564)
- Dismiss errors on change email modal upon a new request ([00913d5](https://github.com/flarum/core/commit/00913d5b0be2172cfce1f16aaf64a24f3d2e6d4b))
- Disabled extensions now are marked with a red circle instead of a red dot (https://github.com/flarum/core/pull/2562)
- Extension dependency errors now show the extension title instead of the ID (https://github.com/flarum/core/pull/2563)
- Change `mutate` method on ApiSerializer extender to `attributes` (https://github.com/flarum/core/pull/2578)
- Moved locale files to the core from the language pack (https://github.com/flarum/core/pull/2408)
- AdminPage extensibility and generic improvements (https://github.com/flarum/core/pull/2593)
- Remove entry of authors, link to https://flarum.org/team (https://github.com/flarum/core/pull/2625)
- Search and filtering are split (https://github.com/flarum/core/pull/2454)
- Move IP identification into a middleware (https://github.com/flarum/core/pull/2624)
- Editor Driver abstraction introduced (https://github.com/flarum/core/pull/2594)
- Allow overriding routes (https://github.com/flarum/core/pull/2577)
- Split user edit permissions into permissions for editing of user credentials, username, groups and suspending (https://github.com/flarum/core/pull/2620)
- Reduced number of admin extension categories (https://github.com/flarum/core/pull/2604)
- Move search related classes to a dedicated Query namespace (https://github.com/flarum/core/pull/2645)
- Rewrite common helpers into typescript (https://github.com/flarum/core/pull/2541)
- `TextEditor` is moved to the common namespace for use in the admin frontend (https://github.com/flarum/core/pull/2649)
- Update Laravel/Illuminate components to 8 (https://github.com/flarum/core/pull/2576)
- Eager load relations in discussion listing to improve performance (https://github.com/flarum/core/pull/2639)
- Adopt flarum/testing package (https://github.com/flarum/core/pull/2545)
- Replace `user` gambit with `author` gambit ([612a57c](https://github.com/flarum/core/commit/612a57c4664415a3ea120103483645c32acc6f12))
- Posts page of on user profile loads posts using username instead of id ([30017ee](https://github.com/flarum/core/commit/30017eef09ae9e78640c4e2cacd4909fffa8d775))
### Fixed
- Transform css breaks iOS scroll functionality (https://github.com/flarum/core/pull/2527)
- Composer header is hidden on mobile devices (https://github.com/flarum/core/pull/2279)
- Cannot delete a post or discussion of a deleted user (https://github.com/flarum/core/pull/2521)
- DiscussionListPane jumps around not keeping the scroll position (https://github.com/flarum/core/pull/2402)
- Infinite scroll on notifications dropdown broken (https://github.com/flarum/core/pull/2524)
- The show language selector switch remains toggled on ([9347b12](https://github.com/flarum/core/commit/9347b12b47bf4ab97ffb7ca92673604b237c1012))
- Model Visibility extender throws exception on extensions that aren't installed or enabled (https://github.com/flarum/core/pull/2580)
- Extensions are marked as enabled when enabling fails to unmet extension dependencies (https://github.com/flarum/core/pull/2558)
- Routes to admin extension pages without a valid ID break the admin page (https://github.com/flarum/core/pull/2584)
- Disabled fieldset use an incorrect CSS property `disallowed` (https://github.com/flarum/core/pull/2585)
- Scrolling to a post that is already loaded the Load More button shows and does not trigger (https://github.com/flarum/core/pull/2388)
- Opening discussions on some mobile devices require a double tap (https://github.com/flarum/core/pull/2607)
- iOS devices show erratic behavior in the post stream while updating (https://github.com/flarum/core/pull/2548)
- Small mobile screens partially hides the composer when the keyboard is open (https://github.com/flarum/core/pull/2631)
- Clearing cache does not clear the template cache in storage/views (https://github.com/flarum/core/pull/2648)
- Boot errors show critical information (https://github.com/flarum/core/pull/2633)
- List user endpoint discloses last online even if user choose against it (https://github.com/flarum/core/pull/2634)
- Group gambit disclosed hidden groups (https://github.com/flarum/core/pull/2657)
- Search results on small windows not fully visible (https://github.com/flarum/core/pull/2650)
- Composer goes off screen on Safari when starting to type (https://github.com/flarum/core/pull/2660)
- A search that has no results shows the search results dropdown ([b88a7cb](https://github.com/flarum/core/commit/b88a7cb33b56e318f11670e9e2d563aef94db039))
- The composer modal moves around when typing on Safari ([a64c398](https://github.com/flarum/core/commit/a64c39835aba43e831209609f4a9638ae589aa41))
### Removed
- Deprecated CSRF wildcard path match
- Deprecated policy and visibility scoping events
- Deprecated post types event
- Deprecated validation events
- Deprecated notification events
- Deprecated floodgate
- Deprecated user preferences event
- Deprecated formatting events
- Deprecated api events
- Deprecated bootstrap.php support
- PHP 7.2 support (https://github.com/flarum/core/pull/2507)
- Bidi attribute in the rendered HTML (https://github.com/flarum/core/pull/2602)
- `AccessToken::find`, use `AccessToken::findValid` instead (https://github.com/flarum/core/pull/2651)
### Deprecated
- `GetModelIsPrivate` event (https://github.com/flarum/core/pull/2587)
- `CheckingPassword` event (https://github.com/flarum/core/pull/2176)
- `event()` helper (https://github.com/flarum/core/pull/2608)
- `AccessToken::generate` argument `$lifetime` (https://github.com/flarum/core/pull/2651)
- `Rememberer::remember` argument `$token` should receive an instance of `RememberAccessToken` with `AccessToken` being deprecated (https://github.com/flarum/core/pull/2651)
- `Rememberer::rememberUser` (https://github.com/flarum/core/pull/2651)
- `SessionAuthenticator::logIn` argument `$userId`, should be replaced with `AccessToken` (https://github.com/flarum/core/pull/2651)
- `TextEditor` has been moved to `common` (https://github.com/flarum/core/pull/2649)
- `UserFilter` ([91e8b56](https://github.com/flarum/core/commit/91e8b569618957c86757ef89bac666e9102db5ae))
## [0.1.0-beta.15](https://github.com/flarum/core/compare/v0.1.0-beta.14.1...v0.1.0-beta.15)
### Added
@@ -210,7 +377,7 @@
- SES mail support (#2011)
- Backward compatibility layer for `Flarum\Mail\DriverInterface`, new methods from beta.12 are now required
- `Flarum\Util\Str` helper class
- `Flarum\Event\ConfigureMiddleware` event
- `Flarum\Event\ConfigureMiddleware` event
### Deprecated
- `Flarum\Event\AbstractConfigureRoutes` event class

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2019-2020 Stichting Flarum (Flarum Foundation)
Copyright (c) 2019-2021 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

View File

@@ -1,7 +1,10 @@
{
"name": "flarum/core",
"description": "Delightfully simple forum software.",
"keywords": ["forum", "discussion"],
"keywords": [
"forum",
"discussion"
],
"homepage": "https://flarum.org/",
"license": "MIT",
"authors": [
@@ -17,27 +20,29 @@
"docs": "https://flarum.org/docs/"
},
"require": {
"php": ">=7.2",
"php": ">=7.3",
"axy/sourcemap": "^0.1.4",
"components/font-awesome": "^5.14.0",
"dflydev/fig-cookies": "^3.0.0",
"doctrine/dbal": "^2.7",
"dragonmantank/cron-expression": "^3.1.0",
"franzl/whoops-middleware": "^2.0.0",
"illuminate/bus": "^6.0",
"illuminate/cache": "^6.0",
"illuminate/config": "^6.0",
"illuminate/container": "^6.0",
"illuminate/contracts": "^6.0",
"illuminate/database": "^6.0",
"illuminate/events": "^6.0",
"illuminate/filesystem": "^6.0",
"illuminate/hashing": "^6.0",
"illuminate/mail": "^6.0",
"illuminate/queue": "^6.0",
"illuminate/session": "^6.0",
"illuminate/support": "^6.0",
"illuminate/validation": "^6.0",
"illuminate/view": "^6.0",
"illuminate/bus": "^8.0",
"illuminate/cache": "^8.0",
"illuminate/config": "^8.0",
"illuminate/console": "^8.0",
"illuminate/container": "^8.0",
"illuminate/contracts": "^8.0",
"illuminate/database": "^8.0",
"illuminate/events": "^8.0",
"illuminate/filesystem": "^8.0",
"illuminate/hashing": "^8.0",
"illuminate/mail": "^8.0",
"illuminate/queue": "^8.0",
"illuminate/session": "^8.0",
"illuminate/support": "^8.0",
"illuminate/validation": "^8.0",
"illuminate/view": "^8.0",
"intervention/image": "^2.5.0",
"laminas/laminas-diactoros": "^2.4.1",
"laminas/laminas-httphandlerrunner": "^1.2.0",
@@ -54,18 +59,18 @@
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0",
"s9e/text-formatter": "^2.3.6",
"symfony/config": "^4.3.4",
"symfony/console": "^4.3.4",
"symfony/event-dispatcher": "^4.3.4",
"symfony/config": "^5.2.2",
"symfony/console": "^5.2.2",
"symfony/event-dispatcher": "^5.2.2",
"symfony/mime": "^5.2.0",
"symfony/translation": "^4.3.4",
"symfony/yaml": "^4.3.4",
"symfony/polyfill-intl-messageformatter": "^1.22.0",
"symfony/translation": "^5.1.5",
"symfony/yaml": "^5.2.2",
"tobscure/json-api": "^0.3.0",
"wikimedia/less.php": "^3.0"
},
"require-dev": {
"mockery/mockery": "^1.3.3",
"phpunit/phpunit": "^8.0"
"flarum/testing": "1.0@dev"
},
"autoload": {
"psr-4": {
@@ -85,7 +90,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.1.x-dev"
"dev-master": "1.x-dev"
}
},
"scripts": {

View File

@@ -0,0 +1,8 @@
{
"files": [
{
"path": "./dist/*.js"
}
],
"defaultCompression": "gzip"
}

View File

@@ -6,7 +6,9 @@ import * as _dayjs from 'dayjs';
import * as _$ from 'jquery';
// Globals from flarum/core
import Application from './src/common/Application';
import Application from '../../src/common/Application';
import type { TooltipJQueryFunction } from '../tooltips';
/**
* flarum/core exposes several extensions globally:
@@ -19,9 +21,14 @@ import Application from './src/common/Application';
* to (and should not) bundle these themselves.
*/
declare global {
const $: typeof _$;
// $ is already defined by `@types/jquery`
const m: Mithril.Static;
const dayjs: typeof _dayjs;
// Extend JQuery with our custom functions, defined with $.fn
interface JQuery {
tooltip: TooltipJQueryFunction;
}
}
/**

68
js/@types/tooltips/index.d.ts vendored Normal file
View File

@@ -0,0 +1,68 @@
/**
* Selection of options accepted by [Bootstrap's tooltips](https://getbootstrap.com/docs/3.3/javascript/#tooltips-options).
*
* ---
*
* Not all options are present from Bootstrap to discourage the use of options
* that will be deprecated in the future.
*
* More commonly used options that will be deprecated remain, but are marked as
* such.
*
* @see https://getbootstrap.com/docs/3.3/javascript/#tooltips-options
*/
export interface TooltipCreationOptions {
/**
* Whether HTML content is allowed in the tooltip.
*
* ---
*
* **Warning:** this is a possible XSS attack vector. This option shouldn't
* be used wherever possible, and will not work when we migrate to CSS-only
* tooltips.
*
* @deprecated
*/
html?: boolean;
/**
* Tooltip position around the target element.
*/
placement?: 'top' | 'bottom' | 'left' | 'right';
/**
* Sets the delay between a trigger state occurring and the tooltip appearing
* on-screen.
*
* ---
*
* **Warning:** this option will be removed when we switch to CSS-only
* tooltips.
*
* @deprecated
*/
delay?: number;
/**
* Value used if no `title` attribute is present on the HTML element.
*
* If a function is given, it will be called with its `this` reference set to
* the element that the tooltip is attached to.
*/
title?: string;
/**
* How the tooltip is triggered.
*
* Either on `hover`, on `hover focus` (either of the two).
*
* ---
*
* **Warning:** `manual`, `click` and `focus` on its own are deprecated options
* which will not be supported in the future.
*/
trigger?: 'hover' | 'hover focus';
}
/**
* Creates a tooltip on a jQuery element reference.
*
* Returns the same jQuery reference to allow for method chaining.
*/
export type TooltipJQueryFunction = (tooltipOptions?: TooltipCreationOptions | 'destroy' | 'show' | 'hide') => JQuery;

View File

@@ -1,11 +1,2 @@
/*
* 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.
*/
export * from './src/common';
export * from './src/admin';

View File

@@ -0,0 +1,39 @@
// Mithril
import Mithril from 'mithril';
// Other third-party libs
import * as _dayjs from 'dayjs';
import * as _$ from 'jquery';
// Globals from flarum/core
import Application from '../../src/common/Application';
import type { TooltipJQueryFunction } from '../tooltips';
/**
* flarum/core exposes several extensions globally:
*
* - jQuery for convenient DOM manipulation
* - Mithril for VDOM and components
* - dayjs for date/time operations
*
* Since these are already part of the global namespace, extensions won't need
* to (and should not) bundle these themselves.
*/
declare global {
// $ is already defined by `@types/jquery`
const m: Mithril.Static;
const dayjs: typeof _dayjs;
// Extend JQuery with our custom functions, defined with $.fn
interface JQuery {
tooltip: TooltipJQueryFunction;
}
}
/**
* All global variables owned by flarum/core.
*/
declare global {
const app: Application;
}

View File

@@ -0,0 +1,68 @@
/**
* Selection of options accepted by [Bootstrap's tooltips](https://getbootstrap.com/docs/3.3/javascript/#tooltips-options).
*
* ---
*
* Not all options are present from Bootstrap to discourage the use of options
* that will be deprecated in the future.
*
* More commonly used options that will be deprecated remain, but are marked as
* such.
*
* @see https://getbootstrap.com/docs/3.3/javascript/#tooltips-options
*/
export interface TooltipCreationOptions {
/**
* Whether HTML content is allowed in the tooltip.
*
* ---
*
* **Warning:** this is a possible XSS attack vector. This option shouldn't
* be used wherever possible, and will not work when we migrate to CSS-only
* tooltips.
*
* @deprecated
*/
html?: boolean;
/**
* Tooltip position around the target element.
*/
placement?: 'top' | 'bottom' | 'left' | 'right';
/**
* Sets the delay between a trigger state occurring and the tooltip appearing
* on-screen.
*
* ---
*
* **Warning:** this option will be removed when we switch to CSS-only
* tooltips.
*
* @deprecated
*/
delay?: number;
/**
* Value used if no `title` attribute is present on the HTML element.
*
* If a function is given, it will be called with its `this` reference set to
* the element that the tooltip is attached to.
*/
title?: string;
/**
* How the tooltip is triggered.
*
* Either on `hover`, on `hover focus` (either of the two).
*
* ---
*
* **Warning:** `manual`, `click` and `focus` on its own are deprecated options
* which will not be supported in the future.
*/
trigger?: 'hover' | 'hover focus';
}
/**
* Creates a tooltip on a jQuery element reference.
*
* Returns the same jQuery reference to allow for method chaining.
*/
export type TooltipJQueryFunction = (tooltipOptions?: TooltipCreationOptions | 'destroy' | 'show' | 'hide') => JQuery;

View File

@@ -0,0 +1,17 @@
export default class AdminApplication extends Application {
extensionData: ExtensionData;
extensionCategories: {
feature: number;
theme: number;
language: number;
};
history: {
canGoBack: () => boolean;
getPrevious: () => void;
backUrl: () => any;
back: () => void;
};
getRequiredPermissions(permission: any): string[];
}
import Application from "../common/Application";
import ExtensionData from "./utils/ExtensionData";

3
js/dist-typings/admin/app.d.ts vendored Normal file
View File

@@ -0,0 +1,3 @@
import Admin from './AdminApplication';
declare const app: Admin;
export default app;

164
js/dist-typings/admin/compat.d.ts vendored Normal file
View File

@@ -0,0 +1,164 @@
declare var _default: {
extend: typeof import("../common/extend");
Session: typeof import("../common/Session").default;
Store: typeof import("../common/Store").default;
'utils/BasicEditorDriver': typeof import("../common/utils/BasicEditorDriver").default;
'utils/evented': {
handlers: Object;
getHandlers(event: string): any[];
trigger(event: string, ...args: any[]): void;
on(event: string, handler: Function): void;
one(event: string, handler: Function): void;
off(event: string, handler: Function): void;
};
'utils/liveHumanTimes': typeof import("../common/utils/liveHumanTimes").default;
'utils/ItemList': typeof import("../common/utils/ItemList").default;
'utils/mixin': typeof import("../common/utils/mixin").default;
'utils/humanTime': typeof import("../common/utils/humanTime").default;
'utils/computed': typeof import("../common/utils/computed").default;
'utils/insertText': typeof import("../common/utils/insertText").default;
'utils/styleSelectedText': typeof import("../common/utils/styleSelectedText").default;
'utils/Drawer': typeof import("../common/utils/Drawer").default;
'utils/anchorScroll': typeof import("../common/utils/anchorScroll").default;
'utils/RequestError': typeof import("../common/utils/RequestError").default;
'utils/abbreviateNumber': typeof import("../common/utils/abbreviateNumber").default;
'utils/string': typeof import("../common/utils/string");
'utils/SubtreeRetainer': typeof import("../common/utils/SubtreeRetainer").default;
'utils/escapeRegExp': typeof import("../common/utils/escapeRegExp").default;
'utils/extract': typeof import("../common/utils/extract").default;
'utils/ScrollListener': typeof import("../common/utils/ScrollListener").default;
'utils/stringToColor': typeof import("../common/utils/stringToColor").default;
'utils/Stream': typeof import("mithril/stream");
'utils/subclassOf': typeof import("../common/utils/subclassOf").default;
'utils/setRouteWithForcedRefresh': typeof import("../common/utils/setRouteWithForcedRefresh").default;
'utils/patchMithril': typeof import("../common/utils/patchMithril").default;
'utils/proxifyCompat': (compat: {
[key: string]: any;
}, namespace: string) => {
[key: string]: any;
};
'utils/classList': (...classes: import("clsx").ClassValue[]) => string;
'utils/extractText': typeof import("../common/utils/extractText").default;
'utils/formatNumber': typeof import("../common/utils/formatNumber").default;
'utils/mapRoutes': typeof import("../common/utils/mapRoutes").default;
'utils/withAttr': (key: string, cb: Function) => (this: Element) => void;
'utils/throttleDebounce': typeof import("../common/utils/throttleDebounce");
'models/Notification': typeof import("../common/models/Notification").default;
'models/User': typeof import("../common/models/User").default;
'models/Post': typeof import("../common/models/Post").default;
'models/Discussion': typeof import("../common/models/Discussion").default;
'models/Group': typeof import("../common/models/Group").default;
'models/Forum': typeof import("../common/models/Forum").default;
Component: typeof import("../common/Component").default;
Fragment: typeof import("../common/Fragment").default;
Translator: typeof import("../common/Translator").default;
'components/AlertManager': typeof import("../common/components/AlertManager").default;
'components/Page': typeof import("../common/components/Page").default;
'components/Switch': typeof import("../common/components/Switch").default;
'components/Badge': typeof import("../common/components/Badge").default;
'components/LoadingIndicator': typeof import("../common/components/LoadingIndicator").default;
'components/Placeholder': typeof import("../common/components/Placeholder").default;
'components/Separator': typeof import("../common/components/Separator").default;
'components/Dropdown': typeof import("../common/components/Dropdown").default;
'components/SplitDropdown': typeof import("../common/components/SplitDropdown").default;
'components/RequestErrorModal': typeof import("../common/components/RequestErrorModal").default;
'components/FieldSet': typeof import("../common/components/FieldSet").default;
'components/Select': typeof import("../common/components/Select").default;
'components/Navigation': typeof import("../common/components/Navigation").default;
'components/Alert': typeof import("../common/components/Alert").default;
'components/Link': typeof import("../common/components/Link").default;
'components/LinkButton': typeof import("../common/components/LinkButton").default;
'components/Checkbox': typeof import("../common/components/Checkbox").default;
'components/SelectDropdown': typeof import("../common/components/SelectDropdown").default;
'components/ModalManager': typeof import("../common/components/ModalManager").default;
'components/Button': typeof import("../common/components/Button").default;
'components/Modal': typeof import("../common/components/Modal").default;
'components/GroupBadge': typeof import("../common/components/GroupBadge").default;
'components/TextEditor': typeof import("../common/components/TextEditor").default;
'components/TextEditorButton': typeof import("../common/components/TextEditorButton").default;
'components/Tooltip': typeof import("../common/components/Tooltip").default;
'components/EditUserModal': typeof import("../common/components/EditUserModal").default;
Model: typeof import("../common/Model").default;
Application: typeof import("../common/Application").default;
'helpers/fullTime': typeof import("../common/helpers/fullTime").default;
'helpers/avatar': typeof import("../common/helpers/avatar").default;
'helpers/icon': typeof import("../common/helpers/icon").default;
'helpers/humanTime': typeof import("../common/helpers/humanTime").default;
'helpers/punctuateSeries': typeof import("../common/helpers/punctuateSeries").default;
'helpers/highlight': typeof import("../common/helpers/highlight").default;
'helpers/username': typeof import("../common/helpers/username").default;
'helpers/userOnline': typeof import("../common/helpers/userOnline").default;
'helpers/listItems': typeof import("../common/helpers/listItems").default;
'resolvers/DefaultResolver': typeof import("../common/resolvers/DefaultResolver").default;
'states/PaginatedListState': typeof import("../common/states/PaginatedListState").default;
} & {
'utils/saveSettings': typeof saveSettings;
'utils/ExtensionData': typeof ExtensionData;
'utils/isExtensionEnabled': typeof isExtensionEnabled;
'utils/getCategorizedExtensions': typeof getCategorizedExtensions;
'components/SettingDropdown': typeof SettingDropdown;
'components/EditCustomFooterModal': typeof EditCustomFooterModal;
'components/SessionDropdown': typeof SessionDropdown;
'components/HeaderPrimary': typeof HeaderPrimary;
'components/AdminPage': typeof AdminPage;
'components/AppearancePage': typeof AppearancePage;
'components/StatusWidget': typeof StatusWidget;
'components/ExtensionsWidget': typeof ExtensionsWidget;
'components/HeaderSecondary': typeof HeaderSecondary;
'components/SettingsModal': typeof SettingsModal;
'components/DashboardWidget': typeof DashboardWidget;
'components/ExtensionPage': typeof ExtensionPage;
'components/ExtensionLinkButton': typeof ExtensionLinkButton;
'components/PermissionGrid': typeof PermissionGrid;
'components/ExtensionPermissionGrid': typeof ExtensionPermissionGrid;
'components/MailPage': typeof MailPage;
'components/UploadImageButton': typeof UploadImageButton;
'components/LoadingModal': typeof LoadingModal;
'components/DashboardPage': typeof DashboardPage;
'components/BasicsPage': typeof BasicsPage;
'components/UserListPage': typeof UserListPage;
'components/EditCustomHeaderModal': typeof EditCustomHeaderModal;
'components/PermissionsPage': typeof PermissionsPage;
'components/PermissionDropdown': typeof PermissionDropdown;
'components/AdminNav': typeof AdminNav;
'components/AdminHeader': typeof AdminHeader;
'components/EditCustomCssModal': typeof EditCustomCssModal;
'components/EditGroupModal': typeof EditGroupModal;
routes: typeof routes;
AdminApplication: typeof AdminApplication;
};
export default _default;
import saveSettings from "./utils/saveSettings";
import ExtensionData from "./utils/ExtensionData";
import isExtensionEnabled from "./utils/isExtensionEnabled";
import getCategorizedExtensions from "./utils/getCategorizedExtensions";
import SettingDropdown from "./components/SettingDropdown";
import EditCustomFooterModal from "./components/EditCustomFooterModal";
import SessionDropdown from "./components/SessionDropdown";
import HeaderPrimary from "./components/HeaderPrimary";
import AdminPage from "./components/AdminPage";
import AppearancePage from "./components/AppearancePage";
import StatusWidget from "./components/StatusWidget";
import ExtensionsWidget from "./components/ExtensionsWidget";
import HeaderSecondary from "./components/HeaderSecondary";
import SettingsModal from "./components/SettingsModal";
import DashboardWidget from "./components/DashboardWidget";
import ExtensionPage from "./components/ExtensionPage";
import ExtensionLinkButton from "./components/ExtensionLinkButton";
import PermissionGrid from "./components/PermissionGrid";
import ExtensionPermissionGrid from "./components/ExtensionPermissionGrid";
import MailPage from "./components/MailPage";
import UploadImageButton from "./components/UploadImageButton";
import LoadingModal from "./components/LoadingModal";
import DashboardPage from "./components/DashboardPage";
import BasicsPage from "./components/BasicsPage";
import UserListPage from "./components/UserListPage";
import EditCustomHeaderModal from "./components/EditCustomHeaderModal";
import PermissionsPage from "./components/PermissionsPage";
import PermissionDropdown from "./components/PermissionDropdown";
import AdminNav from "./components/AdminNav";
import AdminHeader from "./components/AdminHeader";
import EditCustomCssModal from "./components/EditCustomCssModal";
import EditGroupModal from "./components/EditGroupModal";
import routes from "./routes";
import AdminApplication from "./AdminApplication";

View File

@@ -0,0 +1,4 @@
export default class AdminHeader extends Component<import("../../common/Component").ComponentAttrs> {
constructor();
}
import Component from "../../common/Component";

View File

@@ -0,0 +1,15 @@
export default class AdminNav extends Component<import("../../common/Component").ComponentAttrs> {
constructor();
query: Stream<string> | undefined;
scrollToActive(): void;
/**
* Build an item list of main links to show in the admin navigation.
*
* @return {ItemList}
*/
items(): ItemList;
extensionItems(): ItemList;
}
import Component from "../../common/Component";
import Stream from "../../common/utils/Stream";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,55 @@
export default class AdminPage extends Page {
settings: {} | undefined;
loading: boolean | undefined;
content(): string;
submitButton(): JSX.Element;
header(): JSX.Element;
headerInfo(): {
className: string;
icon: string;
title: string;
description: string;
};
/**
* buildSettingComponent takes a settings object and turns it into a component.
* Depending on the type of input, you can set the type to 'bool', 'select', or
* any standard <input> type. Any values inside the 'extra' object will be added
* to the component as an attribute.
*
* Alternatively, you can pass a callback that will be executed in ExtensionPage's
* context to include custom JSX elements.
*
* @example
*
* {
* setting: 'acme.checkbox',
* label: app.translator.trans('acme.admin.setting_label'),
* type: 'bool',
* help: app.translator.trans('acme.admin.setting_help'),
* className: 'Setting-item'
* }
*
* @example
*
* {
* setting: 'acme.select',
* label: app.translator.trans('acme.admin.setting_label'),
* type: 'select',
* options: {
* 'option1': 'Option 1 label',
* 'option2': 'Option 2 label',
* },
* default: 'option1',
* }
*
* @param setting
* @returns {JSX.Element}
*/
buildSettingComponent(entry: any): JSX.Element;
onsaved(): void;
setting(key: any, fallback?: string): any;
dirty(): {};
isChanged(): number;
saveSettings(e: any): Promise<void>;
}
import Page from "../../common/components/Page";

View File

@@ -0,0 +1,3 @@
export default class AppearancePage extends AdminPage {
}
import AdminPage from "./AdminPage";

View File

@@ -0,0 +1,15 @@
export default class BasicsPage extends AdminPage {
localeOptions: {} | undefined;
displayNameOptions: {} | undefined;
slugDriverOptions: {} | undefined;
/**
* Build a list of options for the default homepage. Each option must be an
* object with `path` and `label` properties.
*
* @return {ItemList}
* @public
*/
public homePageItems(): ItemList;
}
import AdminPage from "./AdminPage";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,5 @@
export default class DashboardPage extends AdminPage {
availableWidgets(): ItemList;
}
import AdminPage from "./AdminPage";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,16 @@
export default class DashboardWidget extends Component<import("../../common/Component").ComponentAttrs> {
constructor();
/**
* Get the class name to apply to the widget.
*
* @return {String}
*/
className(): string;
/**
* Get the content of the widget.
*
* @return {VirtualElement}
*/
content(): any;
}
import Component from "../../common/Component";

View File

@@ -0,0 +1,3 @@
export default class EditCustomCssModal extends SettingsModal {
}
import SettingsModal from "./SettingsModal";

View File

@@ -0,0 +1,3 @@
export default class EditCustomFooterModal extends SettingsModal {
}
import SettingsModal from "./SettingsModal";

View File

@@ -0,0 +1,3 @@
export default class EditCustomHeaderModal extends SettingsModal {
}
import SettingsModal from "./SettingsModal";

View File

@@ -0,0 +1,24 @@
/**
* The `EditGroupModal` component shows a modal dialog which allows the user
* to create or edit a group.
*/
export default class EditGroupModal extends Modal {
group: any;
nameSingular: Stream<any> | undefined;
namePlural: Stream<any> | undefined;
icon: Stream<any> | undefined;
color: Stream<any> | undefined;
isHidden: Stream<any> | undefined;
fields(): ItemList;
submitData(): {
nameSingular: any;
namePlural: any;
color: any;
icon: any;
isHidden: any;
};
deleteGroup(): void;
}
import Modal from "../../common/components/Modal";
import Stream from "../../common/utils/Stream";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,5 @@
export default class ExtensionLinkButton extends LinkButton {
statusItems(name: any): ItemList;
}
import LinkButton from "../../common/components/LinkButton";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,21 @@
export default class ExtensionPage extends AdminPage {
extension: any;
changingState: boolean | undefined;
infoFields: {
discuss: string;
documentation: string;
support: string;
website: string;
donate: string;
source: string;
} | undefined;
className(): string;
sections(): ItemList;
topItems(): ItemList;
infoItems(): ItemList;
toggle(): void;
isEnabled(): any;
onerror(e: any): void;
}
import AdminPage from "./AdminPage";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,4 @@
export default class ExtensionPermissionGrid extends PermissionGrid {
extensionId: any;
}
import PermissionGrid from "./PermissionGrid";

View File

@@ -0,0 +1,6 @@
export default class ExtensionsWidget extends DashboardWidget {
categorizedExtensions: {} | undefined;
extensionCategory(category: any): JSX.Element;
extensionWidget(extension: any): JSX.Element;
}
import DashboardWidget from "./DashboardWidget";

View File

@@ -0,0 +1,16 @@
/**
* 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<import("../../common/Component").ComponentAttrs> {
constructor();
config(isInitialized: any, context: any): void;
/**
* Build an item list for the controls.
*
* @return {ItemList}
*/
items(): ItemList;
}
import Component from "../../common/Component";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,14 @@
/**
* The `HeaderSecondary` component displays secondary header controls.
*/
export default class HeaderSecondary extends Component<import("../../common/Component").ComponentAttrs> {
constructor();
/**
* Build an item list for the controls.
*
* @return {ItemList}
*/
items(): ItemList;
}
import Component from "../../common/Component";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,3 @@
export default class LoadingModal extends Modal {
}
import Modal from "../../common/components/Modal";

View File

@@ -0,0 +1,12 @@
export default class MailPage extends AdminPage {
sendingTest: boolean | undefined;
refresh(): void;
status: {
sending: boolean;
errors: {};
} | undefined;
driverFields: any;
sendTestEmail(): void;
testEmailSuccessAlert: number | undefined;
}
import AdminPage from "./AdminPage";

View File

@@ -0,0 +1,6 @@
export default class PermissionDropdown extends Dropdown {
save(groupIds: any): void;
toggle(groupId: any): void;
isGroupDisabled(id: any): boolean;
}
import Dropdown from "../../common/components/Dropdown";

View File

@@ -0,0 +1,12 @@
export default class PermissionGrid extends Component<import("../../common/Component").ComponentAttrs> {
constructor();
permissionItems(): ItemList;
viewItems(): ItemList;
startItems(): ItemList;
replyItems(): ItemList;
moderateItems(): ItemList;
scopeItems(): ItemList;
scopeControlItems(): ItemList;
}
import Component from "../../common/Component";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,3 @@
export default class PermissionsPage extends AdminPage {
}
import AdminPage from "./AdminPage";

View File

@@ -0,0 +1,14 @@
/**
* 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 {
/**
* Build an item list for the contents of the dropdown menu.
*
* @return {ItemList}
*/
items(): ItemList;
}
import Dropdown from "../../common/components/Dropdown";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,3 @@
export default class SettingDropdown extends SelectDropdown {
}
import SelectDropdown from "../../common/components/SelectDropdown";

View File

@@ -0,0 +1,10 @@
export default class SettingsModal extends Modal {
settings: {} | undefined;
form(): string;
submitButton(): JSX.Element;
setting(key: any, fallback?: string): any;
dirty(): {};
changed(): number;
onsaved(): void;
}
import Modal from "../../common/components/Modal";

View File

@@ -0,0 +1,6 @@
export default class StatusWidget extends DashboardWidget {
items(): ItemList;
handleClearCache(e: any): void;
}
import DashboardWidget from "./DashboardWidget";
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1,27 @@
export default class UploadImageButton extends Button {
loading: boolean;
/**
* Prompt the user to upload an image.
*/
upload(): void;
/**
* Remove the logo.
*/
remove(): void;
resourceUrl(): string;
/**
* After a successful upload/removal, reload the page.
*
* @param {Object} response
* @protected
*/
protected success(response: Object): void;
/**
* If upload/removal fails, stop loading.
*
* @param {Object} response
* @protected
*/
protected failure(response: Object): void;
}
import Button from "../../common/components/Button";

View File

@@ -0,0 +1,72 @@
/// <reference types="mithril" />
import ItemList from '../../common/utils/ItemList';
import AdminPage from './AdminPage';
/**
* Admin page which displays a paginated list of all users on the forum.
*/
export default class UserListPage extends AdminPage {
/**
* Number of users to load per page.
*/
private numPerPage;
/**
* Current page number. Zero-indexed.
*/
private pageNumber;
/**
* Total number of forum users.
*
* Fetched from the active `AdminApplication` (`app`), with
* data provided by `AdminPayload.php`, or `flarum/statistics`
* if installed.
*/
readonly userCount: number;
/**
* Get total number of user pages.
*/
private getTotalPageCount;
/**
* This page's array of users.
*
* `undefined` when page loads as no data has been fetched.
*/
private pageData;
/**
* Are there more users available?
*/
private moreData;
private isLoadingPage;
/**
* Component to render.
*/
content(): JSX.Element[];
/**
* Build an item list of columns to show for each user.
*
* Each column in the list should be an object with keys `name` and `content`.
*
* `name` is a string that will be used as the column name.
* `content` is a function with the User model passed as the first and only argument.
*
* See `UserListPage.tsx` for examples.
*/
columns(): ItemList;
headerInfo(): {
className: string;
icon: string;
title: any;
description: any;
};
/**
* Asynchronously fetch the next set of users to be rendered.
*
* Returns an array of Users, plus the raw API payload.
*
* Uses the `this.numPerPage` as the response limit, and automatically calculates the offset required from `pageNumber`.
*
* @param pageNumber The page number to load and display
*/
loadPage(pageNumber: number): Promise<void>;
nextPage(): void;
previousPage(): void;
}

5
js/dist-typings/admin/index.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
import app from './app';
export { app };
export declare const compat: {
[key: string]: any;
};

View File

@@ -0,0 +1,9 @@
import DefaultResolver from '../../common/resolvers/DefaultResolver';
/**
* A custom route resolver for ExtensionPage that generates handles routes
* to default extension pages or a page provided by an extension.
*/
export default class ExtensionPageResolver extends DefaultResolver {
static extension: string | null;
onmatch(args: any, requestedPath: any, route: any): any;
}

6
js/dist-typings/admin/routes.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
/**
* The `routes` initializer defines the forum app's routes.
*
* @param {App} app
*/
export default function _default(app: any): void;

View File

@@ -0,0 +1,98 @@
export default class ExtensionData {
data: {};
currentExtension: any;
/**
* This function simply takes the extension id
*
* @example
* app.extensionData.load('flarum-tags')
*
* flarum/flags -> flarum-flags | acme/extension -> acme-extension
*
* @param extension
*/
for(extension: any): ExtensionData;
/**
* This function registers your settings with Flarum
*
* It takes either a settings object or a callback.
*
* @example
*
* .registerSetting({
* setting: 'flarum-flags.guidelines_url',
* type: 'text', // This will be inputted into the input tag for the setting (text/number/etc)
* label: app.translator.trans('flarum-flags.admin.settings.guidelines_url_label')
* }, 15) // priority is optional (ItemList)
*
*
* @param content
* @param priority
* @returns {ExtensionData}
*/
registerSetting(content: any, priority?: number): ExtensionData;
/**
* This function registers your permission with Flarum
*
* @example
*
* .registerPermission('permissions', {
* icon: 'fas fa-flag',
* label: app.translator.trans('flarum-flags.admin.permissions.view_flags_label'),
* permission: 'discussion.viewFlags'
* }, 'moderate', 65)
*
* @param content
* @param permissionType
* @param priority
* @returns {ExtensionData}
*/
registerPermission(content: any, permissionType?: any, priority?: number): ExtensionData;
/**
* Replace the default extension page with a custom component.
* This component would typically extend ExtensionPage
*
* @param component
* @returns {ExtensionData}
*/
registerPage(component: any): ExtensionData;
/**
* Get an extension's registered settings
*
* @param extensionId
* @returns {boolean|*}
*/
getSettings(extensionId: any): boolean | any;
/**
*
* Get an ItemList of all extensions' registered permissions
*
* @param extension
* @param type
* @returns {ItemList}
*/
getAllExtensionPermissions(type: any): ItemList;
/**
* Get a singular extension's registered permissions
*
* @param extension
* @param type
* @returns {boolean|*}
*/
getExtensionPermissions(extension: any, type: any): boolean | any;
/**
* Checks whether a given extension has registered permissions.
*
* @param extension
* @returns {boolean}
*/
extensionHasPermissions(extension: any): boolean;
/**
* Returns an extension's custom page component if it exists.
*
* @param extension
* @returns {boolean|*}
*/
getPage(extension: any): boolean | any;
}
import ItemList from "../../common/utils/ItemList";

View File

@@ -0,0 +1 @@
export default function getCategorizedExtensions(): {};

View File

@@ -0,0 +1 @@
export default function isExtensionEnabled(name: any): any;

View File

@@ -0,0 +1 @@
export default function saveSettings(settings: any): Promise<any>;

174
js/dist-typings/common/Application.d.ts vendored Normal file
View File

@@ -0,0 +1,174 @@
/**
* The `App` class provides a container for an application, as well as various
* utilities for the rest of the app to use.
*/
export default class Application {
/**
* The forum model for this application.
*
* @type {Forum}
* @public
*/
public forum: Forum;
/**
* A map of routes, keyed by a unique route name. Each route is an object
* containing the following properties:
*
* - `path` The path that the route is accessed at.
* - `component` The Mithril component to render when this route is active.
*
* @example
* app.routes.discussion = {path: '/d/:id', component: DiscussionPage.component()};
*
* @type {Object}
* @public
*/
public routes: Object;
/**
* An ordered list of initializers to bootstrap the application.
*
* @type {ItemList}
* @public
*/
public initializers: ItemList;
/**
* The app's session.
*
* @type {Session}
* @public
*/
public session: Session;
/**
* The app's translator.
*
* @type {Translator}
* @public
*/
public translator: Translator;
/**
* The app's data store.
*
* @type {Store}
* @public
*/
public store: Store;
/**
* A local cache that can be used to store data at the application level, so
* that is persists between different routes.
*
* @type {Object}
* @public
*/
public cache: Object;
/**
* Whether or not the app has been booted.
*
* @type {Boolean}
* @public
*/
public booted: boolean;
/**
* The key for an Alert that was shown as a result of an AJAX request error.
* If present, it will be dismissed on the next successful request.
*
* @type {int}
* @private
*/
private requestErrorAlert;
/**
* The page the app is currently on.
*
* This object holds information about the type of page we are currently
* visiting, and sometimes additional arbitrary page state that may be
* relevant to lower-level components.
*
* @type {PageState}
*/
current: PageState;
/**
* The page the app was on before the current page.
*
* Once the application navigates to another page, the object previously
* assigned to this.current will be moved to this.previous, while this.current
* is re-initialized.
*
* @type {PageState}
*/
previous: PageState;
modal: ModalManagerState;
/**
* An object that manages the state of active alerts.
*
* @type {AlertManagerState}
*/
alerts: AlertManagerState;
data: any;
title: string;
titleCount: number;
initialRoute: any;
load(payload: any): void;
boot(): void;
bootExtensions(extensions: any): void;
mount(basePath?: string): void;
drawer: Drawer | undefined;
/**
* Get the API response document that has been preloaded into the application.
*
* @return {Object|null}
* @public
*/
public preloadedApiDocument(): Object | null;
/**
* Determine the current screen mode, based on our media queries.
*
* @returns {String} - one of "phone", "tablet", "desktop" or "desktop-hd"
*/
screen(): string;
/**
* Set the <title> of the page.
*
* @param {String} title
* @public
*/
public setTitle(title: string): void;
/**
* Set a number to display in the <title> of the page.
*
* @param {Integer} count
*/
setTitleCount(count: any): void;
updateTitle(): void;
/**
* Make an AJAX request, handling any low-level errors that may occur.
*
* @see https://mithril.js.org/request.html
* @param {Object} options
* @return {Promise}
* @public
*/
public request(originalOptions: any): Promise<any>;
/**
* @param {RequestError} error
* @param {string[]} [formattedError]
* @private
*/
private showDebug;
/**
* Construct a URL to the route with the given name.
*
* @param {String} name
* @param {Object} params
* @return {String}
* @public
*/
public route(name: string, params?: Object): string;
}
import Forum from "./models/Forum";
import ItemList from "./utils/ItemList";
import Session from "./Session";
import Translator from "./Translator";
import Store from "./Store";
import PageState from "./states/PageState";
import ModalManagerState from "./states/ModalManagerState";
import AlertManagerState from "./states/AlertManagerState";
import Drawer from "./utils/Drawer";

102
js/dist-typings/common/Component.d.ts vendored Normal file
View File

@@ -0,0 +1,102 @@
import * as Mithril from 'mithril';
export interface ComponentAttrs extends Mithril.Attributes {
}
/**
* The `Component` class defines a user interface 'building block'. A component
* generates a virtual DOM to be rendered on each redraw.
*
* Essentially, this is a wrapper for Mithril's components that adds several useful features:
*
* - In the `oninit` and `onbeforeupdate` lifecycle hooks, we store vnode attrs in `this.attrs.
* This allows us to use attrs across components without having to pass the vnode to every single
* method.
* - The static `initAttrs` method allows a convenient way to provide defaults (or to otherwise modify)
* the attrs that have been passed into a component.
* - When the component is created in the DOM, we store its DOM element under `this.element`; this lets
* us use jQuery to modify child DOM state from internal methods via the `this.$()` method.
* - A convenience `component` method, which serves as an alternative to hyperscript and JSX.
*
* As with other Mithril components, components extending Component can be initialized
* and nested using JSX, hyperscript, or a combination of both. The `component` method can also
* be used.
*
* @example
* return m('div', <MyComponent foo="bar"><p>Hello World</p></MyComponent>);
*
* @example
* return m('div', MyComponent.component({foo: 'bar'), m('p', 'Hello World!'));
*
* @see https://mithril.js.org/components.html
*/
export default abstract class Component<T extends ComponentAttrs = ComponentAttrs> implements Mithril.ClassComponent<T> {
/**
* The root DOM element for the component.
*/
protected element: Element;
/**
* The attributes passed into the component.
*
* @see https://mithril.js.org/components.html#passing-data-to-components
*/
protected attrs: T;
/**
* @inheritdoc
*/
abstract view(vnode: Mithril.Vnode<T, this>): Mithril.Children;
/**
* @inheritdoc
*/
oninit(vnode: Mithril.Vnode<T, this>): void;
/**
* @inheritdoc
*/
oncreate(vnode: Mithril.VnodeDOM<T, this>): void;
/**
* @inheritdoc
*/
onbeforeupdate(vnode: Mithril.VnodeDOM<T, this>): void;
/**
* @inheritdoc
*/
onupdate(vnode: Mithril.VnodeDOM<T, this>): void;
/**
* @inheritdoc
*/
onbeforeremove(vnode: Mithril.VnodeDOM<T, this>): void;
/**
* @inheritdoc
*/
onremove(vnode: Mithril.VnodeDOM<T, this>): void;
/**
* Returns a jQuery object for this component's element. If you pass in a
* selector string, this method will return a jQuery object, using the current
* element as its buffer.
*
* For example, calling `component.$('li')` will return a jQuery object
* containing all of the `li` elements inside the DOM element of this
* component.
*
* @param [selector] a jQuery-compatible selector string
* @returns the jQuery object for the DOM node
* @final
*/
protected $(selector?: string): JQuery;
/**
* Convenience method to attach a component without JSX.
* Has the same effect as calling `m(THIS_CLASS, attrs, children)`.
*
* @see https://mithril.js.org/hyperscript.html#mselector,-attributes,-children
*/
static component(attrs?: {}, children?: null): Mithril.Vnode;
/**
* Saves a reference to the vnode attrs after running them through initAttrs,
* and checking for common issues.
*/
private setAttrs;
/**
* Initialize the component's attrs.
*
* This can be used to assign default values for missing, optional attrs.
*/
protected static initAttrs<T>(attrs: T): void;
}

53
js/dist-typings/common/Fragment.d.ts vendored Normal file
View File

@@ -0,0 +1,53 @@
import * as Mithril from 'mithril';
/**
* The `Fragment` class represents a chunk of DOM that is rendered once with Mithril and then takes
* over control of its own DOM and lifecycle.
*
* This is very similar to the `Component` wrapper class, but is used for more fine-grained control over
* the rendering and display of some significant chunks of the DOM. In contrast to components, fragments
* do not offer Mithril's lifecycle hooks.
*
* Use this when you want to enjoy the benefits of JSX / VDOM for initial rendering, combined with
* small helper methods that then make updates to that DOM directly, instead of fully redrawing
* everything through Mithril.
*
* This should only be used when necessary, and only with `m.render`. If you are unsure whether you need
* this or `Component, you probably need `Component`.
*/
export default abstract class Fragment {
/**
* The root DOM element for the fragment.
*/
protected element: Element;
/**
* Returns a jQuery object for this fragment's element. If you pass in a
* selector string, this method will return a jQuery object, using the current
* element as its buffer.
*
* For example, calling `fragment.$('li')` will return a jQuery object
* containing all of the `li` elements inside the DOM element of this
* fragment.
*
* @param {String} [selector] a jQuery-compatible selector string
* @returns {jQuery} the jQuery object for the DOM node
* @final
*/
$(selector: any): JQuery<any>;
/**
* Get the renderable virtual DOM that represents the fragment's view.
*
* This should NOT be overridden by subclasses. Subclasses wishing to define
* their virtual DOM should override Fragment#view instead.
*
* @example
* const fragment = new MyFragment();
* m.render(document.body, fragment.render());
*
* @final
*/
render(): Mithril.Vnode<Mithril.Attributes, this>;
/**
* Creates a view out of virtual elements.
*/
abstract view(): Mithril.Vnode<Mithril.Attributes, this>;
}

149
js/dist-typings/common/Model.d.ts vendored Normal file
View File

@@ -0,0 +1,149 @@
/**
* The `Model` class represents a local data resource. It provides methods to
* persist changes via the API.
*
* @abstract
*/
export default class Model {
/**
* Generate a function which returns the value of the given attribute.
*
* @param {String} name
* @param {function} [transform] A function to transform the attribute value
* @return {*}
* @public
*/
public static attribute(name: string, transform?: Function | undefined): any;
/**
* Generate a function which returns the value of the given has-one
* relationship.
*
* @param {String} name
* @return {Model|Boolean|undefined} false if no information about the
* relationship exists; undefined if the relationship exists but the model
* has not been loaded; or the model if it has been loaded.
* @public
*/
public static hasOne(name: string): Model | boolean | undefined;
/**
* Generate a function which returns the value of the given has-many
* relationship.
*
* @param {String} name
* @return {Array|Boolean} false if no information about the relationship
* exists; an array if it does, containing models if they have been
* loaded, and undefined for those that have not.
* @public
*/
public static hasMany(name: string): any[] | boolean;
/**
* Transform the given value into a Date object.
*
* @param {String} value
* @return {Date|null}
* @public
*/
public static transformDate(value: string): Date | null;
/**
* Get a resource identifier object for the given model.
*
* @param {Model} model
* @return {Object}
* @protected
*/
protected static getIdentifier(model: Model): Object;
/**
* @param {Object} data A resource object from the API.
* @param {Store} store The data store that this model should be persisted to.
* @public
*/
constructor(data?: Object, store?: any);
/**
* The resource object from the API.
*
* @type {Object}
* @public
*/
public data: Object;
/**
* The time at which the model's data was last updated. Watching the value
* of this property is a fast way to retain/cache a subtree if data hasn't
* changed.
*
* @type {Date}
* @public
*/
public freshness: Date;
/**
* Whether or not the resource exists on the server.
*
* @type {Boolean}
* @public
*/
public exists: boolean;
/**
* The data store that this resource should be persisted to.
*
* @type {Store}
* @protected
*/
protected store: any;
/**
* Get the model's ID.
*
* @return {Integer}
* @public
* @final
*/
public id(): any;
/**
* Get one of the model's attributes.
*
* @param {String} attribute
* @return {*}
* @public
* @final
*/
public attribute(attribute: string): any;
/**
* Merge new data into this model locally.
*
* @param {Object} data A resource object to merge into this model
* @public
*/
public pushData(data: Object): void;
/**
* Merge new attributes into this model locally.
*
* @param {Object} attributes The attributes to merge.
* @public
*/
public pushAttributes(attributes: Object): void;
/**
* Merge new attributes into this model, both locally and with persistence.
*
* @param {Object} attributes The attributes to save. If a 'relationships' key
* exists, it will be extracted and relationships will also be saved.
* @param {Object} [options]
* @return {Promise}
* @public
*/
public save(attributes: Object, options?: Object | undefined): Promise<any>;
/**
* Send a request to delete the resource.
*
* @param {Object} body Data to send along with the DELETE request.
* @param {Object} [options]
* @return {Promise}
* @public
*/
public delete(body: Object, options?: Object | undefined): Promise<any>;
/**
* Construct a path to the API endpoint for this resource.
*
* @return {String}
* @protected
*/
protected apiEndpoint(): string;
copyData(): any;
}

37
js/dist-typings/common/Session.d.ts vendored Normal file
View File

@@ -0,0 +1,37 @@
/**
* The `Session` class defines the current user session. It stores a reference
* to the current authenticated user, and provides methods to log in/out.
*/
export default class Session {
constructor(user: any, csrfToken: any);
/**
* The current authenticated user.
*
* @type {User|null}
* @public
*/
public user: any | null;
/**
* The CSRF token.
*
* @type {String|null}
* @public
*/
public csrfToken: string | null;
/**
* Attempt to log in a user.
*
* @param {String} identification The username/email.
* @param {String} password
* @param {Object} [options]
* @return {Promise}
* @public
*/
public login(body: any, options?: Object | undefined): Promise<any>;
/**
* Log the user out.
*
* @public
*/
public logout(): void;
}

97
js/dist-typings/common/Store.d.ts vendored Normal file
View File

@@ -0,0 +1,97 @@
/**
* The `Store` class defines a local data store, and provides methods to
* retrieve data from the API.
*/
export default class Store {
constructor(models: any);
/**
* The local data store. A tree of resource types to IDs, such that
* accessing data[type][id] will return the model for that type/ID.
*
* @type {Object}
* @protected
*/
protected data: Object;
/**
* The model registry. A map of resource types to the model class that
* should be used to represent resources of that type.
*
* @type {Object}
* @public
*/
public models: Object;
/**
* Push resources contained within an API payload into the store.
*
* @param {Object} payload
* @return {Model|Model[]} The model(s) representing the resource(s) contained
* within the 'data' key of the payload.
* @public
*/
public pushPayload(payload: Object): any | any[];
/**
* Create a model to represent a resource object (or update an existing one),
* and push it into the store.
*
* @param {Object} data The resource object
* @return {Model|null} The model, or null if no model class has been
* registered for this resource type.
* @public
*/
public pushObject(data: Object): any | null;
/**
* Make a request to the API to find record(s) of a specific type.
*
* @param {String} type The resource type.
* @param {Integer|Integer[]|Object} [id] The ID(s) of the model(s) to retrieve.
* Alternatively, if an object is passed, it will be handled as the
* `query` parameter.
* @param {Object} [query]
* @param {Object} [options]
* @return {Promise}
* @public
*/
public find(type: string, id?: any | any[] | Object, query?: Object | undefined, options?: Object | undefined): Promise<any>;
/**
* Get a record from the store by ID.
*
* @param {String} type The resource type.
* @param {Integer} id The resource ID.
* @return {Model}
* @public
*/
public getById(type: string, id: any): any;
/**
* Get a record from the store by the value of a model attribute.
*
* @param {String} type The resource type.
* @param {String} key The name of the method on the model.
* @param {*} value The value of the model attribute.
* @return {Model}
* @public
*/
public getBy(type: string, key: string, value: any): any;
/**
* Get all loaded records of a specific type.
*
* @param {String} type
* @return {Model[]}
* @public
*/
public all(type: string): any[];
/**
* Remove the given model from the store.
*
* @param {Model} model
*/
remove(model: any): void;
/**
* Create a new record of the given type.
*
* @param {String} type The resource type
* @param {Object} [data] Any data to initialize the model with
* @return {Model}
* @public
*/
public createRecord(type: string, data?: Object | undefined): any;
}

31
js/dist-typings/common/Translator.d.ts vendored Normal file
View File

@@ -0,0 +1,31 @@
declare type Translations = Record<string, string>;
declare type TranslatorParameters = Record<string, unknown>;
export default class Translator {
/**
* A map of translation keys to their translated values.
*/
translations: Translations;
/**
* The underlying ICU MessageFormatter util.
*/
protected formatter: any;
setLocale(locale: string): void;
addTranslations(translations: Translations): void;
/**
* An extensible entrypoint for extenders to register type handlers for translations.
*/
protected formatterTypeHandlers(): {
plural: any;
select: any;
};
/**
* A temporary system to preprocess parameters.
* Should not be used by extensions.
* TODO: An extender will be added in v1.x.
*
* @internal
*/
protected preprocessParameters(parameters: TranslatorParameters): TranslatorParameters;
trans(id: string, parameters?: TranslatorParameters): any;
}
export {};

172
js/dist-typings/common/compat.d.ts vendored Normal file
View File

@@ -0,0 +1,172 @@
declare var _default: {
extend: typeof extend;
Session: typeof Session;
Store: typeof Store;
'utils/BasicEditorDriver': typeof BasicEditorDriver;
'utils/evented': {
handlers: Object;
getHandlers(event: string): any[];
trigger(event: string, ...args: any[]): void;
on(event: string, handler: Function): void;
one(event: string, handler: Function): void;
off(event: string, handler: Function): void;
};
'utils/liveHumanTimes': typeof liveHumanTimes;
'utils/ItemList': typeof ItemList;
'utils/mixin': typeof mixin;
'utils/humanTime': typeof humanTime;
'utils/computed': typeof computed;
'utils/insertText': typeof insertText;
'utils/styleSelectedText': typeof styleSelectedText;
'utils/Drawer': typeof Drawer;
'utils/anchorScroll': typeof anchorScroll;
'utils/RequestError': typeof RequestError;
'utils/abbreviateNumber': typeof abbreviateNumber;
'utils/string': typeof string;
'utils/SubtreeRetainer': typeof SubtreeRetainer;
'utils/escapeRegExp': typeof escapeRegExp;
'utils/extract': typeof extract;
'utils/ScrollListener': typeof ScrollListener;
'utils/stringToColor': typeof stringToColor;
'utils/Stream': typeof Stream;
'utils/subclassOf': typeof subclassOf;
'utils/setRouteWithForcedRefresh': typeof setRouteWithForcedRefresh;
'utils/patchMithril': typeof patchMithril;
'utils/proxifyCompat': (compat: {
[key: string]: any;
}, namespace: string) => {
[key: string]: any;
};
'utils/classList': (...classes: import("clsx").ClassValue[]) => string;
'utils/extractText': typeof extractText;
'utils/formatNumber': typeof formatNumber;
'utils/mapRoutes': typeof mapRoutes;
'utils/withAttr': (key: string, cb: Function) => (this: Element) => void;
'utils/throttleDebounce': typeof ThrottleDebounce;
'models/Notification': typeof Notification;
'models/User': typeof User;
'models/Post': typeof Post;
'models/Discussion': typeof Discussion;
'models/Group': typeof Group;
'models/Forum': typeof Forum;
Component: typeof Component;
Fragment: typeof Fragment;
Translator: typeof Translator;
'components/AlertManager': typeof AlertManager;
'components/Page': typeof Page;
'components/Switch': typeof Switch;
'components/Badge': typeof Badge;
'components/LoadingIndicator': typeof LoadingIndicator;
'components/Placeholder': typeof Placeholder;
'components/Separator': typeof Separator;
'components/Dropdown': typeof Dropdown;
'components/SplitDropdown': typeof SplitDropdown;
'components/RequestErrorModal': typeof RequestErrorModal;
'components/FieldSet': typeof FieldSet;
'components/Select': typeof Select;
'components/Navigation': typeof Navigation;
'components/Alert': typeof Alert;
'components/Link': typeof Link;
'components/LinkButton': typeof LinkButton;
'components/Checkbox': typeof Checkbox;
'components/SelectDropdown': typeof SelectDropdown;
'components/ModalManager': typeof ModalManager;
'components/Button': typeof Button;
'components/Modal': typeof Modal;
'components/GroupBadge': typeof GroupBadge;
'components/TextEditor': typeof TextEditor;
'components/TextEditorButton': typeof TextEditorButton;
'components/Tooltip': typeof Tooltip;
'components/EditUserModal': typeof EditUserModal;
Model: typeof Model;
Application: typeof Application;
'helpers/fullTime': typeof fullTime;
'helpers/avatar': typeof avatar;
'helpers/icon': typeof icon;
'helpers/humanTime': typeof humanTimeHelper;
'helpers/punctuateSeries': typeof punctuateSeries;
'helpers/highlight': typeof highlight;
'helpers/username': typeof username;
'helpers/userOnline': typeof userOnline;
'helpers/listItems': typeof listItems;
'resolvers/DefaultResolver': typeof DefaultResolver;
'states/PaginatedListState': typeof PaginatedListState;
};
export default _default;
import * as extend from "./extend";
import Session from "./Session";
import Store from "./Store";
import BasicEditorDriver from "./utils/BasicEditorDriver";
import liveHumanTimes from "./utils/liveHumanTimes";
import ItemList from "./utils/ItemList";
import mixin from "./utils/mixin";
import humanTime from "./utils/humanTime";
import computed from "./utils/computed";
import insertText from "./utils/insertText";
import styleSelectedText from "./utils/styleSelectedText";
import Drawer from "./utils/Drawer";
import anchorScroll from "./utils/anchorScroll";
import RequestError from "./utils/RequestError";
import abbreviateNumber from "./utils/abbreviateNumber";
import * as string from "./utils/string";
import SubtreeRetainer from "./utils/SubtreeRetainer";
import escapeRegExp from "./utils/escapeRegExp";
import extract from "./utils/extract";
import ScrollListener from "./utils/ScrollListener";
import stringToColor from "./utils/stringToColor";
import Stream from "./utils/Stream";
import subclassOf from "./utils/subclassOf";
import setRouteWithForcedRefresh from "./utils/setRouteWithForcedRefresh";
import patchMithril from "./utils/patchMithril";
import extractText from "./utils/extractText";
import formatNumber from "./utils/formatNumber";
import mapRoutes from "./utils/mapRoutes";
import * as ThrottleDebounce from "./utils/throttleDebounce";
import Notification from "./models/Notification";
import User from "./models/User";
import Post from "./models/Post";
import Discussion from "./models/Discussion";
import Group from "./models/Group";
import Forum from "./models/Forum";
import Component from "./Component";
import Fragment from "./Fragment";
import Translator from "./Translator";
import AlertManager from "./components/AlertManager";
import Page from "./components/Page";
import Switch from "./components/Switch";
import Badge from "./components/Badge";
import LoadingIndicator from "./components/LoadingIndicator";
import Placeholder from "./components/Placeholder";
import Separator from "./components/Separator";
import Dropdown from "./components/Dropdown";
import SplitDropdown from "./components/SplitDropdown";
import RequestErrorModal from "./components/RequestErrorModal";
import FieldSet from "./components/FieldSet";
import Select from "./components/Select";
import Navigation from "./components/Navigation";
import Alert from "./components/Alert";
import Link from "./components/Link";
import LinkButton from "./components/LinkButton";
import Checkbox from "./components/Checkbox";
import SelectDropdown from "./components/SelectDropdown";
import ModalManager from "./components/ModalManager";
import Button from "./components/Button";
import Modal from "./components/Modal";
import GroupBadge from "./components/GroupBadge";
import TextEditor from "./components/TextEditor";
import TextEditorButton from "./components/TextEditorButton";
import Tooltip from "./components/Tooltip";
import EditUserModal from "./components/EditUserModal";
import Model from "./Model";
import Application from "./Application";
import fullTime from "./helpers/fullTime";
import avatar from "./helpers/avatar";
import icon from "./helpers/icon";
import humanTimeHelper from "./helpers/humanTime";
import punctuateSeries from "./helpers/punctuateSeries";
import highlight from "./helpers/highlight";
import username from "./helpers/username";
import userOnline from "./helpers/userOnline";
import listItems from "./helpers/listItems";
import DefaultResolver from "./resolvers/DefaultResolver";
import PaginatedListState from "./states/PaginatedListState";

View File

@@ -0,0 +1,19 @@
import Component, { ComponentAttrs } from '../Component';
import Mithril from 'mithril';
export interface AlertAttrs extends ComponentAttrs {
/** The type of alert this is. Will be used to give the alert a class name of `Alert--{type}`. */
type?: string;
/** An array of controls to show in the alert. */
controls?: Mithril.Children;
/** Whether or not the alert can be dismissed. */
dismissible?: boolean;
/** A callback to run when the alert is dismissed */
ondismiss?: Function;
}
/**
* The `Alert` component represents an alert box, which contains a message,
* some controls, and may be dismissible.
*/
export default class Alert<T extends AlertAttrs = AlertAttrs> extends Component<T> {
view(vnode: Mithril.Vnode): JSX.Element;
}

View File

@@ -0,0 +1,9 @@
/**
* The `AlertManager` component provides an area in which `Alert` components can
* be shown and dismissed.
*/
export default class AlertManager extends Component<import("../Component").ComponentAttrs> {
constructor();
state: any;
}
import Component from "../Component";

View File

@@ -0,0 +1,17 @@
/**
* The `Badge` component represents a user/discussion badge, indicating some
* status (e.g. a discussion is stickied, a user is an admin).
*
* A badge may have the following special attrs:
*
* - `type` The type of badge this is. This will be used to give the badge a
* class name of `Badge--{type}`.
* - `icon` The name of an icon to show inside the badge.
* - `label`
*
* All other attrs will be assigned as attributes on the badge element.
*/
export default class Badge extends Component<import("../Component").ComponentAttrs> {
constructor();
}
import Component from "../Component";

View File

@@ -0,0 +1,29 @@
/**
* The `Button` component defines an element which, when clicked, performs an
* action.
*
* ### Attrs
*
* - `icon` The name of the icon class. If specified, the button will be given a
* 'has-icon' class name.
* - `disabled` Whether or not the button is disabled. If truthy, the button
* will be given a 'disabled' class name, and any `onclick` handler will be
* removed.
* - `loading` Whether or not the button should be in a disabled loading state.
*
* All other attrs will be assigned as attributes on the button element.
*
* Note that a Button has no default class names. This is because a Button can
* be used to represent any generic clickable control, like a menu item.
*/
export default class Button extends Component<import("../Component").ComponentAttrs> {
constructor();
/**
* Get the template for the button's content.
*
* @return {*}
* @protected
*/
protected getButtonContent(children: any): any;
}
import Component from "../Component";

View File

@@ -0,0 +1,30 @@
/**
* The `Checkbox` component defines a checkbox input.
*
* ### Attrs
*
* - `state` Whether or not the checkbox is checked.
* - `className` The class name for the root element.
* - `disabled` Whether or not the checkbox is disabled.
* - `loading` Whether or not the checkbox is loading.
* - `onchange` A callback to run when the checkbox is checked/unchecked.
* - `children` A text label to display next to the checkbox.
*/
export default class Checkbox extends Component<import("../Component").ComponentAttrs> {
constructor();
/**
* Get the template for the checkbox's display (tick/cross icon).
*
* @return {*}
* @protected
*/
protected getDisplay(): any;
/**
* Run a callback when the state of the checkbox is changed.
*
* @param {Boolean} checked
* @protected
*/
protected onchange(checked: boolean): void;
}
import Component from "../Component";

View File

@@ -0,0 +1,22 @@
/**
* The `ConfirmDocumentUnload` component can be used to register a global
* event handler that prevents closing the browser window/tab based on the
* return value of a given callback prop.
*
* ### Attrs
*
* - `when` - a callback returning true when the browser should prompt for
* confirmation before closing the window/tab
*
* ### Children
*
* NOTE: Only the first child will be rendered. (Use this component to wrap
* another component / DOM element.)
*
*/
export default class ConfirmDocumentUnload extends Component<import("../Component").ComponentAttrs> {
constructor();
handler(): any;
boundHandler: (() => any) | undefined;
}
import Component from "../Component";

View File

@@ -0,0 +1,38 @@
/**
* The `Dropdown` component displays a button which, when clicked, shows a
* dropdown menu beneath it.
*
* ### Attrs
*
* - `buttonClassName` A class name to apply to the dropdown toggle button.
* - `menuClassName` A class name to apply to the dropdown menu.
* - `icon` The name of an icon to show in the dropdown toggle button.
* - `caretIcon` The name of an icon to show on the right of the button.
* - `label` The label of the dropdown toggle button. Defaults to 'Controls'.
* - `accessibleToggleLabel` The label used to describe the dropdown toggle button to assistive readers. Defaults to 'Toggle dropdown menu'.
* - `onhide`
* - `onshow`
*
* The children will be displayed as a list inside of the dropdown menu.
*/
export default class Dropdown extends Component<import("../Component").ComponentAttrs> {
static initAttrs(attrs: any): void;
constructor();
showing: boolean | undefined;
/**
* Get the template for the button.
*
* @return {*}
* @protected
*/
protected getButton(children: any): any;
/**
* Get the template for the button's content.
*
* @return {*}
* @protected
*/
protected getButtonContent(children: any): any;
getMenu(items: any): JSX.Element;
}
import Component from "../Component";

View File

@@ -0,0 +1,25 @@
/**
* The `EditUserModal` component displays a modal dialog with a login form.
*/
export default class EditUserModal extends Modal {
username: Stream<any> | undefined;
email: Stream<any> | undefined;
isEmailConfirmed: Stream<any> | undefined;
setPassword: Stream<boolean> | undefined;
password: Stream<any> | undefined;
groups: {} | undefined;
fields(): ItemList;
activate(): void;
data(): {
relationships: {};
};
nonAdminEditingAdmin(): any;
/**
* @internal
* @protected
*/
protected userIsAdmin(user: any): any;
}
import Modal from "./Modal";
import Stream from "../utils/Stream";
import ItemList from "../utils/ItemList";

View File

@@ -0,0 +1,13 @@
/**
* The `FieldSet` component defines a collection of fields, displayed in a list
* underneath a title. Accepted properties are:
*
* - `className` The class name for the fieldset.
* - `label` The title of this group of fields.
*
* The children should be an array of items to show in the fieldset.
*/
export default class FieldSet extends Component<import("../Component").ComponentAttrs> {
constructor();
}
import Component from "../Component";

View File

@@ -0,0 +1,4 @@
export default class GroupBadge extends Badge {
static initAttrs(attrs: any): void;
}
import Badge from "./Badge";

View File

@@ -0,0 +1,12 @@
/**
* The link component enables both internal and external links.
* It will return a regular HTML link for any links to external sites,
* and it will use Mithril's m.route.Link for any internal links.
*
* Links will default to internal; the 'external' attr must be set to
* `true` for the link to be external.
*/
export default class Link extends Component<import("../Component").ComponentAttrs> {
constructor();
}
import Component from "../Component";

View File

@@ -0,0 +1,24 @@
/**
* The `LinkButton` component defines a `Button` which links to a route.
*
* ### Attrs
*
* All of the attrs accepted by `Button`, plus:
*
* - `active` Whether or not the page that this button links to is currently
* active.
* - `href` The URL to link to. If the current URL `m.route()` matches this,
* the `active` prop will automatically be set to true.
* - `force` Whether the page should be fully rerendered. Defaults to `true`.
*/
export default class LinkButton extends Button {
static initAttrs(attrs: any): void;
/**
* Determine whether a component with the given attrs is 'active'.
*
* @param {Object} attrs
* @return {Boolean}
*/
static isActive(attrs: Object): boolean;
}
import Button from "./Button";

View File

@@ -0,0 +1,56 @@
/// <reference types="mithril" />
import Component, { ComponentAttrs } from '../Component';
export interface LoadingIndicatorAttrs extends ComponentAttrs {
/**
* Custom classes for the loading indicator's container.
*/
className?: string;
/**
* Custom classes for the loading indicator's container.
*/
containerClassName?: string;
/**
* Optional size for the loading indicator.
*/
size?: 'large' | 'medium' | 'small';
/**
* Optional attributes to apply to the loading indicator's container.
*/
containerAttrs?: Partial<ComponentAttrs>;
/**
* Display type of the spinner.
*
* @default 'block'
*/
display?: 'block' | 'inline' | 'unset';
}
/**
* The `LoadingIndicator` component displays a simple CSS-based loading spinner.
*
* To set a custom color, use the CSS `color` property.
*
* To increase spacing around the spinner, use the CSS `height` property on the
* spinner's **container**. Setting the `display` attribute to `block` will set
* a height of `100px` by default.
*
* To apply a custom size to the loading indicator, set the `--size` and
* `--thickness` CSS custom properties on the loading indicator container.
*
* If you *really* want to change how this looks as part of your custom theme,
* you can override the `border-radius` and `border` then set either a
* background image, or use `content: "\<glyph>"` (e.g. `content: "\f1ce"`)
* and `font-family: 'Font Awesome 5 Free'` to set an FA icon if you'd rather.
*
* ### Attrs
*
* - `containerClassName` Class name(s) to apply to the indicator's parent
* - `className` Class name(s) to apply to the indicator itself
* - `display` Determines how the spinner should be displayed (`inline`, `block` (default) or `unset`)
* - `size` Size of the loading indicator (`small`, `medium` or `large`)
* - `containerAttrs` Optional attrs to be applied to the container DOM element
*
* All other attrs will be assigned as attributes on the DOM element.
*/
export default class LoadingIndicator extends Component<LoadingIndicatorAttrs> {
view(): JSX.Element;
}

View File

@@ -0,0 +1,67 @@
/**
* The `Modal` component displays a modal dialog, wrapped in a form. Subclasses
* should implement the `className`, `title`, and `content` methods.
*
* @abstract
*/
export default class Modal extends Component<import("../Component").ComponentAttrs> {
/**
* Determine whether or not the modal should be dismissible via an 'x' button.
*/
static isDismissible: boolean;
constructor();
/**
* Attributes for an alert component to show below the header.
*
* @type {object}
*/
alertAttrs: object;
/**
* Get the class name to apply to the modal.
*
* @return {String}
* @abstract
*/
className(): string;
/**
* Get the title of the modal dialog.
*
* @return {String}
* @abstract
*/
title(): string;
/**
* Get the content of the modal.
*
* @return {VirtualElement}
* @abstract
*/
content(): any;
/**
* Handle the modal form's submit event.
*
* @param {Event} e
*/
onsubmit(): void;
/**
* Focus on the first input when the modal is ready to be used.
*/
onready(): void;
/**
* Hide the modal.
*/
hide(): void;
/**
* Stop loading.
*/
loaded(): void;
loading: boolean | undefined;
/**
* Show an alert describing an error returned from the API, and give focus to
* the first relevant field.
*
* @param {RequestError} error
*/
onerror(error: any): void;
}
import Component from "../Component";

View File

@@ -0,0 +1,11 @@
/**
* The `ModalManager` component manages a modal dialog. Only one modal dialog
* can be shown at once; loading a new component into the ModalManager will
* overwrite the previous one.
*/
export default class ModalManager extends Component<import("../Component").ComponentAttrs> {
constructor();
animateShow(readyCallback: any): void;
animateHide(): void;
}
import Component from "../Component";

View File

@@ -0,0 +1,40 @@
/**
* The `Navigation` component displays a set of navigation buttons. Typically
* this is just a back button which pops the app's History. If the user is on
* the root page and there is no history to pop, then in some instances it may
* show a button that toggles the app's drawer.
*
* If the app has a pane, it will also include a 'pin' button which toggles the
* pinned state of the pane.
*
* Accepts the following attrs:
*
* - `className` The name of a class to set on the root element.
* - `drawer` Whether or not to show a button to toggle the app's drawer if
* there is no more history to pop.
*/
export default class Navigation extends Component<import("../Component").ComponentAttrs> {
constructor();
/**
* Get the back button.
*
* @return {Object}
* @protected
*/
protected getBackButton(): Object;
/**
* Get the pane pinned toggle button.
*
* @return {Object|String}
* @protected
*/
protected getPaneButton(): Object | string;
/**
* Get the drawer toggle button.
*
* @return {Object|String}
* @protected
*/
protected getDrawerButton(): Object | string;
}
import Component from "../Component";

View File

@@ -0,0 +1,27 @@
/**
* The `Page` component
*
* @abstract
*/
export default class Page extends Component<import("../Component").ComponentAttrs> {
constructor();
/**
* A class name to apply to the body while the route is active.
*
* @type {String}
*/
bodyClass: string | undefined;
/**
* Whether we should scroll to the top of the page when its rendered.
*
* @type {Boolean}
*/
scrollTopOnCreate: boolean | undefined;
/**
* Whether the browser should restore scroll state on refreshes.
*
* @type {Boolean}
*/
useBrowserScrollRestoration: boolean | undefined;
}
import Component from "../Component";

View File

@@ -0,0 +1,12 @@
/**
* The `Placeholder` component displays a muted text with some call to action,
* usually used as an empty state.
*
* ### Attrs
*
* - `text`
*/
export default class Placeholder extends Component<import("../Component").ComponentAttrs> {
constructor();
}
import Component from "../Component";

View File

@@ -0,0 +1,3 @@
export default class RequestErrorModal extends Modal {
}
import Modal from "./Modal";

View File

@@ -0,0 +1,13 @@
/**
* The `Select` component displays a <select> input, surrounded with some extra
* elements for styling. It accepts the following attrs:
*
* - `options` A map of option values to labels.
* - `onchange` A callback to run when the selected value is changed.
* - `value` The value of the selected option.
* - `disabled` Disabled state for the input.
*/
export default class Select extends Component<import("../Component").ComponentAttrs> {
constructor();
}
import Component from "../Component";

View File

@@ -0,0 +1,13 @@
/**
* The `SelectDropdown` component is the same as a `Dropdown`, except the toggle
* button's label is set as the label of the first child which has a truthy
* `active` prop.
*
* ### Attrs
*
* - `caretIcon`
* - `defaultLabel`
*/
export default class SelectDropdown extends Dropdown {
}
import Dropdown from "./Dropdown";

View File

@@ -0,0 +1,11 @@
export default Separator;
/**
* The `Separator` component defines a menu separator item.
*/
declare class Separator extends Component<import("../Component").ComponentAttrs> {
constructor();
}
declare namespace Separator {
const isListItem: boolean;
}
import Component from "../Component";

View File

@@ -0,0 +1,15 @@
/**
* The `SplitDropdown` component is similar to `Dropdown`, but the first child
* is displayed as its own button prior to the toggle button.
*/
export default class SplitDropdown extends Dropdown {
/**
* Get the first child. If the first child is an array, the first item in that
* array will be returned.
*
* @return {*}
* @protected
*/
protected getFirstChild(children: any): any;
}
import Dropdown from "./Dropdown";

View File

@@ -0,0 +1,8 @@
/**
* The `Switch` component is a `Checkbox`, but with a switch display instead of
* a tick/cross one.
*/
export default class Switch extends Checkbox {
static initAttrs(attrs: any): void;
}
import Checkbox from "./Checkbox";

View File

@@ -0,0 +1,61 @@
/**
* The `TextEditor` component displays a textarea with controls, including a
* submit button.
*
* ### Attrs
*
* - `composer`
* - `submitLabel`
* - `value`
* - `placeholder`
* - `disabled`
* - `preview`
*/
export default class TextEditor extends Component<import("../Component").ComponentAttrs> {
constructor();
/**
* The value of the editor.
*
* @type {String}
*/
value: string | undefined;
/**
* Whether the editor is disabled.
*/
disabled: any;
buildEditorParams(): {
classNames: string[];
disabled: any;
placeholder: any;
value: string | undefined;
oninput: (value: string) => void;
inputListeners: never[];
onsubmit: () => void;
};
buildEditor(dom: any): BasicEditorDriver;
/**
* Build an item list for the text editor controls.
*
* @return {ItemList}
*/
controlItems(): ItemList;
/**
* Build an item list for the toolbar controls.
*
* @return {ItemList}
*/
toolbarItems(): ItemList;
/**
* Handle input into the textarea.
*
* @param {String} value
*/
oninput(value: string): void;
/**
* Handle the submit button being clicked.
*/
onsubmit(): void;
}
import Component from "../Component";
import BasicEditorDriver from "../utils/BasicEditorDriver";
import ItemList from "../utils/ItemList";

View File

@@ -0,0 +1,8 @@
/**
* The `TextEditorButton` component displays a button suitable for the text
* editor toolbar.
*/
export default class TextEditorButton extends Button {
static initAttrs(attrs: any): void;
}
import Button from "./Button";

View File

@@ -0,0 +1,116 @@
import Component from '../Component';
import type Mithril from 'mithril';
export interface TooltipAttrs extends Mithril.CommonAttributes<TooltipAttrs, Tooltip> {
/**
* Tooltip textual content.
*
* String arrays, like those provided by the translator, will be flattened
* into strings.
*/
text: string | string[];
/**
* Manually show tooltip. `false` will show based on cursor events.
*
* Default: `false`.
*/
tooltipVisible?: boolean;
/**
* Whether to show on focus.
*
* Default: `true`.
*/
showOnFocus?: boolean;
/**
* Tooltip position around element.
*
* Default: `'top'`.
*/
position?: 'top' | 'bottom' | 'left' | 'right';
/**
* Whether HTML content is allowed in the tooltip.
*
* **Warning:** this is a possible XSS attack vector. This option shouldn't
* be used wherever possible, and may not work when we migrate to another
* tooltip library. Be prepared for this to break in Flarum stable.
*
* Default: `false`.
*
* @deprecated
*/
html?: boolean;
/**
* Sets the delay between a trigger state occurring and the tooltip appearing
* on-screen.
*
* **Warning:** this option may be removed when switching to another tooltip
* library. Be prepared for this to break in Flarum stable.
*
* Default: `0`.
*
* @deprecated
*/
delay?: number;
/**
* Used to disable the warning for passing text to the `title` attribute.
*
* Tooltip text should be passed to the `text` attribute.
*/
ignoreTitleWarning?: boolean;
}
/**
* The `Tooltip` component is used to create a tooltip for an element. It
* requires a single child element to be passed to it. Passing multiple
* children or fragments will throw an error.
*
* You should use this for any tooltips you create to allow for backwards
* compatibility when we switch to another tooltip library instead of
* Bootstrap tooltips.
*
* If you need to pass multiple children, surround them with another element,
* such as a `<span>` or `<div>`.
*
* **Note:** this component will overwrite the `title` attribute of the first
* child you pass to it, as this is how the current tooltip system works in
* Flarum. This shouldn't be an issue if you're using this component correctly.
*
* @example <caption>Basic usage</caption>
* <Tooltip text="You wish!">
* <Button>
* Click for free money!
* </Button>
* </Tooltip>
*
* @example <caption>Use of `position` and `showOnFocus` attrs</caption>
* <Tooltip text="Woah! That's cool!" position="bottom" showOnFocus>
* <span>3 replies</span>
* </Tooltip>
*
* @example <caption>Incorrect usage</caption>
* // This is wrong! Surround the children with a <span> or similar.
* <Tooltip text="This won't work">
* Click
* <a href="/">here</a>
* </Tooltip>
*/
export default class Tooltip extends Component<TooltipAttrs> {
private firstChild;
private childDomNode;
private oldText;
private oldVisibility;
private shouldRecreateTooltip;
private shouldChangeTooltipVisibility;
view(vnode: Mithril.Vnode<TooltipAttrs, this>): Mithril.ChildArray;
oncreate(vnode: Mithril.VnodeDOM<TooltipAttrs, this>): void;
onupdate(vnode: Mithril.VnodeDOM<TooltipAttrs, this>): void;
private recreateTooltip;
private updateVisibility;
private createTooltip;
private getRealText;
/**
* Checks if the tooltip DOM node has changed.
*
* If it has, it updates `this.childDomNode` to the new node, and sets
* `shouldRecreateTooltip` to `true`.
*/
private checkDomNodeChanged;
}

54
js/dist-typings/common/extend.d.ts vendored Normal file
View File

@@ -0,0 +1,54 @@
/**
* Extend an object's method by running its output through a mutating callback
* every time it is called.
*
* The callback accepts the method's return value and should perform any
* mutations directly on this value. For this reason, this function will not be
* effective on methods which return scalar values (numbers, strings, booleans).
*
* Care should be taken to extend the correct object in most cases, a class'
* prototype will be the desired target of extension, not the class itself.
*
* @example <caption>Example usage of extending one method.</caption>
* extend(Discussion.prototype, 'badges', function(badges) {
* // do something with `badges`
* });
*
* @example <caption>Example usage of extending multiple methods.</caption>
* extend(IndexPage.prototype, ['oncreate', 'onupdate'], function(vnode) {
* // something that needs to be run on creation and update
* });
*
* @param {object} object The object that owns the method
* @param {string|string[]} methods The name or names of the method(s) to extend
* @param {function} callback A callback which mutates the method's output
*/
export function extend(object: object, methods: string | string[], callback: Function): void;
/**
* Override an object's method by replacing it with a new function, so that the
* new function will be run every time the object's method is called.
*
* The replacement function accepts the original method as its first argument,
* which is like a call to `super`. Any arguments passed to the original method
* are also passed to the replacement.
*
* Care should be taken to extend the correct object in most cases, a class'
* prototype will be the desired target of extension, not the class itself.
*
* @example <caption>Example usage of overriding one method.</caption>
* override(Discussion.prototype, 'badges', function(original) {
* const badges = original();
* // do something with badges
* return badges;
* });
*
* @example <caption>Example usage of overriding multiple methods.</caption>
* extend(Discussion.prototype, ['oncreate', 'onupdate'], function(original, vnode) {
* // something that needs to be run on creation and update
* });
*
* @param {object} object The object that owns the method
* @param {string|string[]} method The name or names of the method(s) to override
* @param {function} newMethod The method to replace it with
*/
export function override(object: object, methods: any, newMethod: Function): void;

View File

@@ -0,0 +1,12 @@
export default class Model {
constructor(type: any, model?: any);
type: any;
attributes: any[];
hasOnes: any[];
hasManys: any[];
model: any;
attribute(name: any): Model;
hasOne(type: any): Model;
hasMany(type: any): Model;
extend(app: any, extension: any): void;
}

View File

@@ -0,0 +1,5 @@
export default class PostTypes {
postComponents: {};
add(name: any, component: any): PostTypes;
extend(app: any, extension: any): void;
}

View File

@@ -0,0 +1,5 @@
export default class Routes {
routes: {};
add(name: any, path: any, component: any): Routes;
extend(app: any, extension: any): void;
}

View File

@@ -0,0 +1,3 @@
export { default as Model } from "./Model";
export { default as PostTypes } from "./PostTypes";
export { default as Routes } from "./Routes";

View File

@@ -0,0 +1,9 @@
import * as Mithril from 'mithril';
import User from '../models/User';
/**
* The `avatar` helper displays a user's avatar.
*
* @param user
* @param attrs Attributes to apply to the avatar element
*/
export default function avatar(user: User, attrs?: Object): Mithril.Vnode;

View File

@@ -0,0 +1,6 @@
import * as Mithril from 'mithril';
/**
* The `fullTime` helper displays a formatted time string wrapped in a <time>
* tag.
*/
export default function fullTime(time: Date): Mithril.Vnode;

View File

@@ -0,0 +1,11 @@
import * as Mithril from 'mithril';
/**
* The `highlight` helper searches for a word phrase in a string, and wraps
* matches with the <mark> tag.
*
* @param string The string to highlight.
* @param phrase The word or words to highlight.
* @param [length] The number of characters to truncate the string to.
* The string will be truncated surrounding the first match.
*/
export default function highlight(string: string, phrase: string | RegExp, length?: number): Mithril.Vnode<any, any> | string;

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