Commit Graph

561 Commits

Author SHA1 Message Date
Toby Zerner
2a5c0c1c7a Improve request error debug output 2015-10-21 10:47:07 +10:30
Toby Zerner
14af6c0e8b Remove app.trans shortcut
Use `app.translator.trans` instead.
2015-10-21 10:31:28 +10:30
Toby Zerner
c2f802878a Fix translation keys 2015-10-21 10:27:09 +10:30
Toby Zerner
b23e821013 Merge branch 'key-adjustment' of https://github.com/dcsjapan/flarum-core into dcsjapan-key-adjustment
# Conflicts:
#	js/forum/src/components/LogInModal.js
2015-10-21 10:02:07 +10:30
Toby Zerner
12830265d9 Change back to 401 error on invalid login
See 26a821e3e2 (commitcomment-13866552)
2015-10-21 09:04:58 +10:30
Toby Zerner
6d7b826133 Fix bad filename 2015-10-20 22:52:47 +10:30
Toby Zerner
9b0aa574f0 Update broken bower resource paths 2015-10-20 22:48:32 +10:30
Toby Zerner
067552efe5 Revert error handling regression 2015-10-20 22:07:08 +10:30
dcsjapan
659cfb72ad Fix the double correction
- Fixes one mangled app.translator call.
2015-10-20 15:44:58 +09:00
dcsjapan
49d59089e4 Add third tier to key namespacing
- Changes all `app.trans` calls to `app.translator.trans` calls.
- Changes existing keys to [three-tier namespace structure](https://github.com/flarum/english/pull/12).
- Extracts additional strings for `lib:` namespace.
- Extracts two previously missed strings for EditGroupModal.js.
2015-10-20 13:04:43 +09:00
Toby Zerner
a9eb62880e Remove behaviour where backspace re-focuses on title field 2015-10-20 12:49:19 +10:30
Toby Zerner
26a821e3e2 Improve client XHR error handling
The default XHR error handler produce an alert which is appropriate to the response status code. It can be overridden per-request (by specifying the `errorHandler` option) so that the alert can be suppressed or displayed in a different position (e.g. inside a modal).

ref #118
2015-10-20 12:48:26 +10:30
Toby Zerner
5cd2d6a79f Add error handling to edit group modal 2015-10-19 15:44:00 +10:30
Toby Zerner
a3a64749c5 Only decrease unread count if notification is unread
closes #590
2015-10-19 15:27:46 +10:30
Toby Zerner
d8eed9d171 Allow pluralisation of event post description 2015-10-16 12:50:12 +10:30
Toby Zerner
c08b62af80 Refactor translation and validation
We now use Symfony's Translation component. Yay! We get more powerful pluralisation and better a fallback mechanism. Will want to implement the caching mechanism at some point too. The API is replicated in JavaScript, which could definitely use some testing.

Validators have been refactored so that they are decoupled from models completely (i.e. they simply validate arrays of user input). Language packs should include Laravel's validation messages.

ref #267
2015-10-15 22:30:45 +10:30
Toby Zerner
044d730480 Potential fix for #381
Have not yet been able to test in situ.
2015-10-14 16:35:48 +10:30
Toby Zerner
4b3e1b16d9 Remove forum. prefix from permissions
closes #425
2015-10-14 16:11:00 +10:30
Toby Zerner
bdf626b552 Basic parsing of HTML tags in translations
This allows text to be wrapped with a virtual element:

	key: "This is a <test>Test</test>"

	app.trans('key', {test: <a href="#"/>});

closes #574
2015-10-14 15:24:28 +10:30
Toby Zerner
68a7886cec Merge pull request #577 from dcsjapan/leftover-string-extraction
Extract leftover core strings
2015-10-14 14:48:02 +10:30
Toby Zerner
a3c11587b7 Merge pull request #575 from dcsjapan/admin-string-extraction 2015-10-14 14:45:29 +10:30
Toby Zerner
c7c2d9a755 Fake PATCH/PUT/DELETE requests
closes #502
2015-10-14 12:46:59 +10:30
Toby Zerner
9772e398f6 Evaluate <script> tags in TextFormatter output
This allows us to rely on TextFormatter's highlight.js loading code instead of implementing our own.

closes #532
2015-10-14 11:45:33 +10:30
Toby Zerner
e3569d39cc Clean up, don't use mixin
PhpStorm/WebStorm doesn't like the mixin syntax, and it's clearer to just use Object.assign.
2015-10-13 16:57:18 +10:30
Toby Zerner
33dd5fff36 Initialise component state in init() instead of constructor
This allows component state to be overridden via monkey-patch. ref #246
2015-10-13 16:55:56 +10:30
Toby Zerner
6f7cce5adf Further refinements to admin extensions page 2015-10-13 12:27:10 +10:30
Toby Zerner
4c2ff6e82d Revamp admin extensions page
- New look
- Groups extensions by keywords
2015-10-12 15:02:59 +10:30
Toby Zerner
208d90293d Fix extension settings 2015-10-11 23:18:57 +10:30
Toby Zerner
4580ebe100 Show posts even if they don't have a user 2015-10-11 22:28:23 +10:30
Toby Zerner
cf42765513 External helpers are included by default now 2015-10-11 11:37:23 +10:30
Toby Zerner
7387dfb7da Concatenate items in {second}, not {first} 2015-10-11 10:09:22 +10:30
Toby Zerner
18def302d6 Bundle unminified JS; minify via ClosureCompilerService when in production
Falls back to a less effective minification library if ClosureCompilerService errors or is unavailable. Minification takes a while (20 seconds or so), but it only happens when assets are modified. Still, this means enabling/disabling extensions is taking far too long. Possible solutions:

- Don't minify initially; set a process running in the background to do minification, and server unminified assets in the meantime.
- Refactor compiler to send each JS file to CCS individually, only if that particular file has been modified.

flarum/gulp has also been updated to no longer support uglification.

closes #582
2015-10-09 00:33:53 +10:30
Toby Zerner
bddbf24055 Make punctuate translatable, rename to punctuateSeries 2015-10-08 22:42:03 +10:30
Toby Zerner
c3cf5fe074 Only show restore button for comment posts 2015-10-08 17:45:44 +10:30
Toby Zerner
dd67291ce0 Major refactor and improvements
- Reorganised all namespaces and class names for consistency and structure. Following PSR bylaws (Abstract prefix, Interface/Trait suffix).
  - Move models into root of Core, because writing `use Flarum\Core\Discussion` is nice. Namespace the rest by type. (Namespacing by entity was too arbitrary.)
  - Moved some non-domain stuff out of Core: Database, Formatter, Settings.
  - Renamed config table and all references to "settings" for consistency.
  - Remove Core class and add url()/isInstalled()/inDebugMode() as instance methods of Foundation\Application.
  - Cleanup, docblocking, etc.

- Improvements to HTTP architecture
  - API and forum/admin Actions are now actually all the same thing (simple PSR-7 Request handlers), renamed to Controllers.
  - Upgrade to tobscure/json-api 0.2 branch.
  - Where possible, moved generic functionality to tobscure/json-api (e.g. pagination links). I'm quite happy with the backend balance now re: #262

- Improvements to other architecture
  - Use Illuminate's Auth\Access\Gate interface/implementation instead of our old Locked trait. We still use events to actually determine the permissions though. Our Policy classes are actually glorified event subscribers.
  - Extract model validation into Core\Validator classes.
  - Make post visibility permission stuff much more efficient and DRY.

- Renamed Flarum\Event classes for consistency. ref #246
  - `Configure` prefix for events dedicated to configuring an object.
  - `Get` prefix for events whose listeners should return something.
  - `Prepare` prefix when a variable is passed by reference so it can be modified.
  - `Scope` prefix when a query builder is passed.

- Miscellaneous improvements/bug-fixes. I'm easily distracted!
  - Increase default height of post composer.
  - Improve post stream redraw flickering in Safari by keying loading post placeholders with their IDs. ref #451
  - Use a PHP JavaScript minification library for minifying TextFormatter's JavaScript, instead of ClosureCompilerService (can't rely on external service!)
  - Use UrlGenerator properly in various places. closes #123
  - Make Api\Client return Response object. closes #128
  - Allow extensions to specify custom icon images.
  - Allow external API/admin URLs to be optionally specified in config.php. If the value or "url" is an array, we look for the corresponding path inside. Otherwise, we append the path to the base URL, using the corresponding value in "paths" if present. closes #244
2015-10-08 14:28:02 +10:30
dcsjapan
1a3e085a9c Fixes namespace errors in keys for the two extracted strings. 2015-10-06 09:56:12 +09:00
dcsjapan
78cd35d93c Extract leftover core strings
Adds app.trans calls for a couple strings in core:
- The "there are no discussions" message in DiscussionList.js
- The user deletion confirmation message in UserControls.js
- Also adds new HTML-style tags to LogInModal.js and SignUpModal.js
2015-10-06 05:52:03 +09:00
dcsjapan
4725ac4131 Extract admin strings
Adds app.trans calls for strings used by the admin UI.
- Strings for AddExtensionModal.js not included.
- Corresponding YAML will be sent later w/ more extracted strings.
2015-10-05 19:06:41 +09:00
Toby Zerner
2223e1a13c Add compiled JS 2015-10-03 16:59:53 +09:30
Toby Zerner
296b822636 Merge branch 'master' into composer 2015-10-03 16:41:23 +09:30
Mike Nolan
56e10ce6ba Read documentation link broken
This fixes #510 by putting in the link to the themes documentation
2015-10-02 17:24:01 +01:00
Toby Zerner
03f862fe8c Merge branch 'master' into composer 2015-10-02 17:57:24 +09:30
Toby Zerner
e251cf34c4 Use composer.json for extension metadata 2015-10-02 17:49:16 +09:30
dcsjapan
a590150698 Fixes core.deleted_username as well. 2015-10-02 16:37:09 +09:00
dcsjapan
0a66229169 Add "forum" namespacing to previously renamed core keys
- Does not affect "core.deleted_user" global string.
- Corresponding YAML will be sent later w/ more extracted strings.
2015-10-02 15:54:39 +09:00
Toby Zerner
4e5b3099f8 Fix scrubber dragging division by zero
closes #64
2015-09-29 17:46:05 +09:30
Toby Zerner
e0aa99fabb Properly mark all notifications as read
Previously, clicking the "mark all notifications as read" button would individually mark each of the visible notifications as read. Since we now always show a badge with the number of unread notifications, we need to make sure that all notifications (not just the visible ones) can be marked as read. Otherwise it would be possible to get stuck with an unread badge there.

This commit adds a new API endpoint which marks *all* of a user's notifications as read. The JSON-API spec doesn't cover this kind of thing (updating all instances of a certain resource type), so I'm a bit unsure regarding what the endpoint should actually be. For now I've gone with POST /notifications/read, but I'm open to suggestions.

ref #500
2015-09-29 16:41:05 +09:30
Toby Zerner
6463d912a9 Properly handle errors in change email modal 2015-09-29 15:19:06 +09:30
Toby Zerner
b39a991940 Remove "go to email provider" buttons
closes #541
2015-09-29 15:18:55 +09:30
Toby Zerner
0db4708ef9 Add missing semicolon 2015-09-29 14:29:40 +09:30
Franz Liedke
ce094be83e Sync notification count when clicking on them or marking all as read
Refs #500.
2015-09-29 01:28:47 +02:00
Franz Liedke
f5b5d9ca5c Use correct method for notification drawer on mobile
Refs #500.
2015-09-29 01:28:47 +02:00
Franz Liedke
040ce52724 Return both unread and new notification count from the API
Related to #500.
2015-09-29 01:28:47 +02:00
Franz Liedke
1f7afb3e4a Implement third state for notification list dropdown
Related to #500.
2015-09-29 00:50:28 +02:00
Toby Zerner
538a3e5e98 Prevent infinite redraw loop in IE
Welp, this is probably the most subtle bug I've ever tracked down and fixed.

Turns out that IE has this bug where the "oninput" event will be triggered whenever the "placeholder" attribute is changed. Most placeholders get their value from app.trans. The app.trans method returns a VirtualElement – which is an array, not a string! That means when Mithril's diffing algorithm was comparing the old value to the new value, it was comparing two different array instances, and thus deciding the value was dirty and the placeholder attribute needed to be updated. Due to the IE bug, that was leading to the "oninput" event being triggered... and then through Mithril's auto-redraw mechanism, a redraw would be triggered, and so the cycle continued.

Since the inputs in the LogInModal (among others) only update the component state on the "onchange" event (i.e. when the input loses focus), the intermittent redraws would cause the input's value to be cleared continuously. That's what was causing #464. Could've been easily and superficially patched by changing them to use "oninput" events, but luckily I dived a little deeper!

Glad that's over. Running IE11's buggy dev tools in an underpowered VM isn't fun. Would not recommend.

closes #464
2015-09-25 23:44:15 +09:30
Toby Zerner
f1c40eeccc Prevent empty beforeunload dialog on Internet Explorer 2015-09-25 23:21:10 +09:30
dcsjapan
4851596c78 Revises the dashboard links to emphasize beta testing procedure.
Closes flarum/core#542
- Includes a disclaimer stating that the software is provided mainly
for testing.
- Directs bug reports to the Support tag in the forums instead of the
issue tracker
- Directs feedback to the Features tag in the forums
2015-09-25 12:55:13 +09:00
Toby Zerner
88372640aa Remove core key reorganization comments 2015-09-24 14:22:32 +09:30
Toby Zerner
fdb598187f Revert to "go to email provider" button 2015-09-24 14:22:14 +09:30
Toby Zerner
b126055611 Add "last reply" icon to discussion list 2015-09-24 09:05:52 +09:30
dcsjapan
c2ad1181b1 Merge remote-tracking branch 'flarum/master' into core-key-reorganization 2015-09-23 14:58:34 +09:00
dcsjapan
d5d7185794 Primary key renaming
Improved consistency for existing core translation key names.

See flarum/core#265
- Completely overhauled core en.yml
- Replaced existing key names in all core JS files to match
- Extracted a hardcoded string in IndexPage.js
- Combined two app.trans calls in DiscussionControls.js
- Removed hardcoded spaces from LogInModal.js and SignUpModal.js
- Added two new keys from DiscussionControls.js (soft delete)
- Created two new “reused keys” to YML to accommodate same
2015-09-23 14:58:33 +09:00
Toby Zerner
a0267d9515 Add extra check to make sure post has been fully loaded
Ref #295
2015-09-23 12:22:37 +09:30
Toby Zerner
3020710959 Move post Restore control into same section as Delete Forever 2015-09-22 17:58:19 +09:30
Toby Zerner
5598e885b7 Improve admin permissions page with icons, visual tweaks 2015-09-22 17:52:16 +09:30
Toby Zerner
264725d872 Allow discussions to be hidden and restored 2015-09-22 17:48:21 +09:30
Toby Zerner
c7ed189cf3 Use ES6 syntax 2015-09-22 17:23:47 +09:30
Toby Zerner
ab6e3351b4 Redraw old data after unsuccessful save 2015-09-22 17:23:28 +09:30
Toby Zerner
f591851cb2 Patch Mithril with a route shortcut attribute
Instead of:

<a href={app.route.user(user)} config={m.route}>

We can use:

<a route={app.route.user(user)}>
2015-09-22 17:09:38 +09:30
Toby Zerner
f55d95c9b7 Select contents of search input on focus 2015-09-22 17:06:06 +09:30
Toby Zerner
d610ea663f Keep post actions visible when controls dropdown is open
Also show without hover on touch devices
2015-09-22 17:05:14 +09:30
Toby Zerner
8ab0686666 Properly hide loading spinner on unsuccessful post edit 2015-09-22 16:57:06 +09:30
Toby Zerner
efca923d30 Add "Debug" button to inspect the response of a failed AJAX request
Related to #118
2015-09-18 16:46:46 +09:30
Toby Zerner
4041c18014 Further tweaks to post layout
Move footer after actions so that we'll be able to have larger things
in the footer (e.g. Answers) without pushing down the controls.
2015-09-18 14:38:57 +09:30
Toby Zerner
514eec7466 Clean up 2015-09-18 13:29:50 +09:30
Toby Zerner
4752142c11 Reflect composer's focus state in a property 2015-09-18 13:15:58 +09:30
Toby Zerner
6582c5fcf0 Smooth out initial composer slide animation 2015-09-18 13:14:12 +09:30
Toby Zerner
6fff3cc0dc Add abstract SettingsModal component in admin app
Makes building settings modals (that update basic config values) a
whole lot quicker/easier.
2015-09-18 13:13:25 +09:30
Toby Zerner
0b406a06a1 Patch Mithril with a bidi attribute
Enables quick bidirectional bindings. So instead of this:

<input value={prop()} oninput={m.withAttr('value', prop)}/>

... we can do this:

<input bidi={prop}/>
2015-09-18 13:06:37 +09:30
Toby Zerner
1fc369c59e Cleanup, update changelog 2015-09-18 13:01:31 +09:30
Toby Zerner
dbd33f687c Remove "custom" home page input
Also add an API to let extensions define additional default route
options.

Allowing default routes with parameters (e.g. /d/123) is very difficult
because of the way Mithril routing works, and it doesn't have a
convincing use-case to justify the trouble. So I've removed the custom
input altogether.

closes #427
2015-09-17 12:56:39 +09:30
Franz Liedke
9767bce1e3 Move dropdown mouseover to correct location
Related to #496.
2015-09-16 09:00:33 +02:00
Franz Liedke
ffcba1f173 Always use label as tooltip for header icons
Closes #496.
2015-09-16 08:45:45 +02:00
Toby Zerner
b0da51309e Copy properties when monkey-patching 2015-09-16 16:03:25 +09:30
Toby Zerner
8414a59908 Don't use a default dropdown label 2015-09-16 10:12:49 +09:30
Toby Zerner
e524c59f97 Improve external authentication API
Some providers (e.g. Twitter) don't expose user email addresses, so it
turns out we can't use that as the sole form of identification/account
matching.

This commit introduces a new `auth_tokens` table which stores arbitrary
attributes during the sign up process. For example, when Twitter is
authenticated, a new auth token containing the user's Twitter ID will
be created. When sign up is completed with this token, that Twitter ID
will be set as an attribute on the user's account.
2015-09-15 15:56:48 +09:30
Toby Zerner
cac670e699 Focus on username field when login buttons are present 2015-09-15 13:04:45 +09:30
Toby Zerner
fa265152c7 Clean up new post layout 2015-09-15 12:42:03 +09:30
Toby Zerner
5c98a08e0f Merge branch 'master' into compact-posts 2015-09-15 11:27:49 +09:30
Toby Zerner
6beb4fe898 Add external authenticator (social login) API
Allows registrations to be completed with a pre-confirmed email address
and no password.
2015-09-15 11:27:31 +09:30
Toby Zerner
8cccaaaf6b Improve API error handling
- Change 'path' key to 'source.pointer', as per spec
- Add 500 error detail if debug mode is on
2015-09-14 15:40:07 +09:30
Toby Zerner
d5b58b3146 Only set XHR authorization header if token isn't empty 2015-09-14 14:49:11 +09:30
Toby Zerner
f00d2b1363 Remove unused component 2015-09-14 14:48:05 +09:30
Toby Zerner
efff485d6c Restyle posts to be more compact, relocate controls 2015-09-08 10:29:00 +09:30
Toby Zerner
6a5427b600 Make unread discussion titles less overwhelming 2015-09-08 10:27:50 +09:30
Toby Zerner
e8621636c5 Add init hook as a way to effectively monkey patch constructors
Related to #246
2015-09-08 10:27:02 +09:30
Toby Zerner
8c4e095f23 Allow first post to be hidden/restored
Anti-spam extensions may automatically hide the first post in a
discussion, and thus we had to implement smarter permissions so
discussions with zero posts wouldn't be visible to users other than the
author/mods. This change allows those hidden posts to be restored again.
2015-09-07 16:03:45 +09:30
Toby Zerner
f6e21b75e1 Remove unused translations 2015-09-05 16:05:02 +09:30
Toby Zerner
695df18be0 Don't show placeholder when loading discussions 2015-09-04 13:50:17 +09:30
Toby Zerner
7a6c48c30b Correct check that a translation is an object
typeof translation === 'object' returns true when translation is null
2015-09-04 12:19:02 +09:30