[UI] Add RTL support with CSSJanus#2678
Conversation
Co-Authored-By: Alexandre Alapetite <[email protected]>
| } | ||
| $content = file_get_contents(PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename_ltr); | ||
| $rtl_content = CSSJanus::transform($content); | ||
| file_put_contents($path_rtl, $rtl_content); |
There was a problem hiding this comment.
If this requires write access, we might consider treating the results as cache, and put them somewhere under ./data/
We have ext.php to serve files that are not directly exposed publicly, which we could generalise.
There was a problem hiding this comment.
@Alkarex Unfortunately I just noticed a problem.
Ansum, for example, contains things like this:
background-image: url(icons/magnifier.svg);The less elegant approach of just generating it locally and committing it all would be an easy way around that, but of course I wrote this PR to avoid such a thing. It's an action you can forget and it adds extra noise in commits/diffs.
One possible approach would be to copy the whole thing, along these lines (except in PHP instead of shell for Windows compatibility):
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index 14995d5e..4ca026e1 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -104,23 +104,27 @@ class FreshRSS extends Minz_FrontController {
$filename_ltr = $file;
}
$filename_rtl = $filename_ltr . '.rtl.css';
- $path_ltr = PUBLIC_PATH . '/themes/' . $theme_id . '/' . $filename_ltr;
- $path_rtl = DATA_PATH . '/rtl/'. $theme_id . '.' . $filename_rtl;
+ $path_ltr = PUBLIC_PATH . '/themes/' . $theme_id;
+ $path_rtl = DATA_PATH . '/rtl/'. $theme_id;
+ $path_full_ltr = $path_ltr . '/' . $filename_ltr;
+ $path_full_rtl = $path_rtl . '/' . $filename_rtl;
- $filetime = @filemtime($path_ltr);
+ $filetime = @filemtime($path_full_ltr);
$url = '/themes/' . $theme_id . '/' . $filename_ltr . '?' . $filetime;
if (_t('gen.dir') === 'rtl') {
- if (!file_exists($path_rtl) || filemtime($path_rtl) < $filetime) {
+ if (!file_exists($path_full_rtl) || filemtime($path_full_rtl) < $filetime) {
+ `rm -rf $path_full_rtl`;
+ `cp -r $path_ltr $path_rtl`;
// generate RTL CSS
if (!class_exists('CSSJanus')) {
require_once LIB_PATH . '/lib_CSSJanus.php';
}
- $content = file_get_contents($path_ltr);
+ $content = file_get_contents($path_full_ltr);
$rtl_content = CSSJanus::transform($content);
- file_put_contents($path_rtl, $rtl_content);
+ file_put_contents($path_full_rtl, $rtl_content);
}
- $url = '/ext.php?f='. $theme_id . '.' . $filename_rtl . '&t=css&c=rtl&' . $filetime;
+ $url = '/ext.php?f='. $theme_id . '/' . $filename_rtl . '&t=css&c=rtl&' . $filetime;
}
Minz_View::prependStyle(Minz_Url::display($url));That principle works fine, setting aside that the icon URLs still don't actually work at this point.
I looked around a bit and this PR simply puts them in the theme directory, but I figure having those writable isn't exactly desirable.
Also pinging @aledeg @marienfressinaud for their thoughts.
There was a problem hiding this comment.
There are two things that bother me.
The first one is to put CSS theme files under the ./data folder (actually, there are a lot of files that I would not put in this folder, it's another non-critical subject). I was even considering dropping the ext.php and f.php mechanisms by replacing them by a dynamic system of "assets collection", to move all CSS and JS under the /p folder and to allow pre-processing. It's a long-term idea that I will not develop soon, but just to say that I don't mind if the server write files in the public folder: I find it's more logical.
The second thing is to do that in loadStylesAndScripts. Writing these files is a huge side-effect of the method. I would have done it at least in a different method of this class (and yet I don't think it's the ideal solution, but I can't find one for the moment ^^)
Last thing: I would like to have the feedback of someone who is used to RTL interfaces. I find the interfaces look pretty weird (but hey, it's normal since I never use RTL interfaces ^^) and I'm wondering if the solution is to simply reverse the rules or if there are trickier things to think about.
There was a problem hiding this comment.
A note regarding were to place files: key aspects include whether the folder is writeable by the Web server, and whether the whole folder can be erased and replaced when there is a new FreshRSS version.
There was a problem hiding this comment.
Oh right, I see what I wrote, haha. My apologies. I meant this:
Minor details like the arrows (which are in the wrong direction)
and
some missing UI elements.
There was a problem hiding this comment.
@WaseemAlkurdi Btw, you can see for yourself over on https://demo.freshrss.org/ if you're curious.
There was a problem hiding this comment.
@Frenzie I've taken a look. Very awesome project! I'm thinking of deploying it sometime.
You're correct: the bottom (previous/next) arrows are indeed reversed. Other than that, no issues at all that I can see in the screenshots above vs. the demo.
Edit: Missing UI elements? I can't see any in the screenshots above.
There was a problem hiding this comment.
@WaseemAlkurdi I didn't see your edit. It's not the UI elements that are missing per se, but the icons on them (on the second and fourth screenshot).
There was a problem hiding this comment.
@Frenzie I had to stare at the screenshots for a couple minutes to even know what was missing! :-)
But true, the icons are missing (the toolbar and search bar, as far as I can see).
|
Let me know when this is ready for another review. As I am not familiar with RTL, I am only looking at potential negative side effects (e.g. performance) on LTR. |
|
For (future?) inspiration https://css-tricks.com/css-logical-properties/ |
|
I was aware of those when I started, yes. :-) Also see #2658 (comment) |
|
@Alkarex @marienfressinaud @aledeg For the short term I think it would be best to change this into a simple CSSJanus call on the development machine, for example through Since that shouldn't take long to draft up I'll probably open a third PR to show what that looks like, leaving this one as is. All of my effort here was intended to avoid putting it in the repo, but I don't see a clear weekend-hack path toward actually doing so right now. |
|
Merged #2776 instead. |
This PR supersedes #2658 and fixes #673. It's a slightly different (automated) principle, which requires significantly less manual attention. The entire file is automatically processed and adjusted. It adds the new 19 kB library CSSJanus, but that's pretty much it.
I didn't really know where to put the auto-generator code; it should presumably be its own method somewhere. It sticks the generated files in themes/rtl and regenerates them if the original was modified more recently than the generated RTL file.
This change is