Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New extension WordHighlighter - for highlighting words. #238

Merged
merged 11 commits into from
Aug 1, 2024

Conversation

lukasMega
Copy link
Contributor

init commit for new extension WordHighlighter - for highlighting words.

discussion, how it started: FreshRSS/FreshRSS#6475

} elseif (Minz_Request::isPost()) {
$config = html_entity_decode(Minz_Request::paramString('word-highlighter-conf'));
file_put_contents($configFileWithWords, $config);
file_put_contents(join_path($staticPath, ('config-words.' . $current_user . '.js')), $this->toJSArray($config));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm generating 2 files for configuration.

  • .txt which represents words to highlight - saved by user (as plaintext, one string per line)
  • .js is based of .txt which is loaded to page as javascript

Example:

  • .txt content (config-words.admin.txt):
    • raspberry pi
      FreshRSS
      
  • and generated .js (config-words.admin.js):
    • window.WordHighlighterConf = [
      'raspberry pi',
      'FreshRSS',
      ]; console.log({ wordsLoaded: window.WHConfig })
      
    • (log will be removed later)

HIGHLIGHT_OPTIONS.enableLogs && console.log('WordHighlighter: script load...', { words: window.WordHighlighterConf });

/* eslint-disable */
//#region <mark.js v9.0.0>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//#region <mark.js v9.0.0> ... //#endregion
used in order to collapse included minified mark.js lib:
it's supported in IntelliJ IDE (Idea, WebStorm, PhpStorm, …) or VSCode:
Screen 2024-05-21 at 23 37 09

@lukasMega
Copy link
Contributor Author

currently in this very first version (0.0.1) only one highlighting type (primary) is implemented:
Screen 2024-05-21 at 23 45 27

@math-GH
Copy link
Contributor

math-GH commented May 22, 2024

Let me know how I can assist you.

@lukasMega
Copy link
Contributor Author

lukasMega commented May 22, 2024

Let me know how I can assist you.

@math-GH I would appreciate if you go through PHP code because I'm not familiar with PHP ecosystem (I have used PHP probably 10 years ago). Thank you.

Note that I was heavily inspired by extension Custom JS.

After update, config section now looks like:

Screen 2024-05-22 at 22 16 17

Lukáš Melega added 3 commits May 22, 2024 21:49
…(enable_in_article, enable_logs, case_sensitive, separate_word_search) and refactored & simplified code
@lukasMega
Copy link
Contributor Author

also I need help with fixing errors from PHPStan. And I don't know how to trigger automated checks via Github Actions / workflows.

@math-GH
Copy link
Contributor

math-GH commented May 22, 2024

I don't know how to trigger automated checks via Github Actions / workflows.

First-time contributors needs a manual start from an repository admin. I do it for you

@Alkarex
Copy link
Member

Alkarex commented May 22, 2024

You can run make test-all locally (this assumes that you have your ./Extensions/ and ./FreshRSS/ folders as siblings (i.e. next to each other in the same directory).
See also https://github.com/FreshRSS/Extensions/blob/master/README.md#commands-for-developers

@math-GH
Copy link
Contributor

math-GH commented May 22, 2024

The TR and FR translations does not to be supported if the translation is not done.
English/EN is fine for a start.

@lukasMega
Copy link
Contributor Author

lukasMega commented May 23, 2024

You can run make test-all locally (this assumes that you have your ./Extensions/ and ./FreshRSS/ folders as siblings (i.e. next to each other in the same directory). See also https://github.com/FreshRSS/Extensions/blob/master/README.md#commands-for-developers

unfortunately I don't have proper DEV environment yet. I just edited files on my live running server (RPi5 via SSH)

The TR and FR translations does not to be supported if the translation is not done.
English/EN is fine for a start.

What is the process with translations? Should I delete non English translations? Or should I somehow (with help of Google Translate / DeepL) translate it to other supported languages?

Thank you @math-GH for your help and patience.

Comment on lines +80 to +81
$confJson = json_decode(file_get_contents($configFileJson) ?: '', true, 8, JSON_THROW_ON_ERROR);
if (json_last_error() !== JSON_ERROR_NONE || !is_array($confJson)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not believe json_last_error() !== JSON_ERROR_NONE will ever be relevant when you also use JSON_THROW_ON_ERROR. I believe the idea is to use one or the other, not both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please propose a code change for it as I'm not a PHP dev. I just added that check in order to fix some PHPStan error regarding parsing json.

Screen 2024-05-23 at 11 36 17

@math-GH
Copy link
Contributor

math-GH commented May 23, 2024

The TR and FR translations does not to be supported if the translation is not done.
English/EN is fine for a start.

What is the process with translations? Should I delete non English translations? Or should I somehow (with help of Google Translate / DeepL) translate it to other supported languages?

There is no process at all.

Minimum requirement is to have the EN (English) translation that is the fallback for all other languages.

If you like you could add SK (Slovakian) - as I can see in your profile it could be your native language.

If you would like to have German, French and Dutch as translation then ping @Alkarex , @Frenzie and me.

I would suggest not to use an automatic translation to keep the quality and context.

If someone wants to have his/her language in this extension then the source is open to send a PR ;)

@Frenzie
Copy link
Member

Frenzie commented May 23, 2024

In theory machine translation could be a decent starting point (marked as dirty of course), but in practice it'd probably be unnecessarily annoying to have to double check it against the original.

@Alkarex
Copy link
Member

Alkarex commented Aug 1, 2024

Sorry for the delay - I had forgotten about this PR...

@Alkarex Alkarex merged commit 31bbdb5 into FreshRSS:master Aug 1, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants