Jump to content

kuba

Members
  • Posts

    11
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

kuba's Achievements

Jr. Member

Jr. Member (3/6)

5

Reputation

  1. @ryan OK, I will let you know. This update fixes probably all the issues.
  2. @Sandy Did you manage to discover what was the issue that hooks don't work inside /site/ready.php?
  3. @ryan Should the AutoLinks module not save all settings for ConfigurableModule interface? After saving it adds all links to articles, but the textarea with all provided terms is set to empty. After saving again all links are removed.
  4. Thank you for the update. I did exactly that. The file permission of the .js file was the issue. There was no execution allowed. Now it works ? To calculate reading time I use this code on my website. 250 words per minute is the recommended value for English language. function calculateReadTime($text) { // Average reading speed in words per minute $averageReadingSpeed = 200; // Strip HTML tags and count the words $wordCount = str_word_count(strip_tags($text)); // Calculate the read time in minutes $readTime = ceil($wordCount / $averageReadingSpeed); return $readTime; }
  5. I followed the steps exactly. The plugin appears in the External Plugins section, but when I enable it, it's not accessible. It should add a button and show up in the Tools drop-down menu.
  6. I created a script for TinyMCE that calculates the readability of a given text using the Flesch Reading Ease formula based on a 0-100 scale. A high score means the text is easier to read for users (recommended score 60+). Low scores suggest the text is complicated to understand with too long paragraphs. It works with standard TinyMCE, however the question is how to make it run with ProcessWire? tinymce.init({ selector: 'textarea#template', plugins: 'readability', toolbar: 'readability', menubar: 'tools', menu: { tools: { title: 'Tools', items: 'readabilityTool' } } }); tinymce.PluginManager.add('readability', (editor, url) => { editor.ui.registry.addButton('readability', { text: 'Readability', icon: 'book', onAction: function() { const content = editor.getContent({format: 'text'}); const readabilityScore = calculateReadability(content); alert('Readability Score: ' + readabilityScore); } }); editor.ui.registry.addMenuItem('readability', { text: 'Readability', icon: 'book', onAction: function() { const content = editor.getContent({format: 'text'}); const readabilityScore = calculateReadability(content); alert('Readability Score: ' + readabilityScore); } }); editor.ui.registry.addMenuItem('readabilityTool', { text: 'Readability', context: 'tools', icon: 'book', onAction: function() { const content = editor.getContent({format: 'text'}); const readabilityScore = calculateReadability(content); alert('Readability Score: ' + readabilityScore); } }); return { getMetadata: () => ({ name: 'Readability' }) }; }); function calculateReadability(text) { var sentences = text.split(/[\.\!\?]/).filter(Boolean); var numSentences = sentences.length; var words = text.split(/\s+/).filter(Boolean).length; var syllables = 0; var wordArray = text.split(/\s+/).filter(Boolean); wordArray.forEach(function(word) { syllables += countSyllables(word); }); if (words > 0 && numSentences > 0) { var wordsPerSentence = words / numSentences; var syllablesPerWord = syllables / words; var readability = 206.835 - (1.015 * wordsPerSentence) - (84.6 * syllablesPerWord); return readability.toFixed(2); } else { return 0; } } function countSyllables(word) { word = word.toLowerCase(); var vowels = 'aeiouy'; var numVowels = 0; var prevCharWasVowel = false; if (word.length > 2 && word.substr(-2) == 'es') { word = word.slice(0, -2); } else if (word.length > 1 && word.substr(-1) == 'e') { word = word.slice(0, -1); } for (var i = 0; i < word.length; i++) { if (vowels.indexOf(word[i]) !== -1) { if (!prevCharWasVowel) { numVowels++; } prevCharWasVowel = true; } else { prevCharWasVowel = false; } } return numVowels > 0 ? numVowels : 1; }
  7. @ryan Hey, when can we expect the release of those modules TextBlocks and AutoLinks?
×
×
  • Create New...