-
Posts
6,671 -
Joined
-
Last visited
-
Days Won
366
Everything posted by bernhard
-
Creating thousands of pages via the API
bernhard replied to David Beesley's topic in API & Templates
Thx, yes I thought that would be the case. But without any logging you never know whether the script is still running or not (or what the progress is). Console + echo is really nice for such situations where the tracy console does not fit ? -
Creating thousands of pages via the API
bernhard replied to David Beesley's topic in API & Templates
without uncacheAll and gc_collect_cycles() created 500 pages in 24.82s, 0.05s per page, used 20.88 mb memory using only gc_collect_cycles() created 500 pages in 24.074s, 0.048s per page, used 15.16 mb memory using only $pages->uncacheAll() created 500 pages in 24.366s, 0.049s per page, used 20.88 mb memory created 2000 pages in 96.191s, 0.048s per page, used 25.07 mb memory Seems that gc_collect_cycles() is the best option?! Not sure if I'm using it correctly, though: https://stackoverflow.com/questions/19715048/what-gc-collect-cycles-function-is-useful-for -
Creating thousands of pages via the API
bernhard replied to David Beesley's topic in API & Templates
I just want to share my findings from today when I wanted to create one million pages quickly: First, via Tracy Console: ini_set('max_execution_time', 150); $last = $pages->findOne("parent=/data,include=all,sort=-id"); $last = (int)$last->title ?: 0; for($i=$last+1;$i<$last+1000;$i++) { // create page $p = new Page(); $p->template = 'basic-page'; $p->parent = '/data'; $p->title = $i; $p->save(); l("saved page $i"); $pages->uncacheAll(); gc_collect_cycles(); } d('done'); It started at 23 pages per second: And at the end of the 150 seconds it was already down at 4 pages per second: Testing without logging: Memory usage also increased proportionally. Finally running a PHP script from the command line that bootstrapped PW worked well: <?php namespace ProcessWire; $time_pre = microtime(true); include("../../../index.php"); // bootstrap ProcessWire $last = $pages->findOne("parent=/data,sort=-id"); $i = (int)(string)$last->title ?: 0; // multilang quickfix convert to string // foreach($pages->find('parent=/data') as $p) { // $p->delete(); // echo "deleted $p\n"; // } // return; $i++; $num = 0; while($i <= 1000000) { // create page $p = new Page(); $p->template = 'basic-page'; $p->parent = '/data'; $p->title = $i; $p->save(); $pages->uncacheAll(); gc_collect_cycles(); $num++; echo "done: $num ($i)\n"; $i++; } function convert($size) { $unit=array('b','kb','mb','gb','tb','pb'); return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i]; } $time_post = microtime(true); $t = $time_post - $time_pre; $m = memory_get_usage(); echo "created $num pages in " . round($t, 3) . "s, " . round($t/$num, 3) . "s per page, used " . convert($m) . " memory\n"; Benefits: quick runs in the background and does not lock the site direct feedback via echo without creating huge log files cancel via ctrl+c any time easy persistant saving of your scripts- 24 replies
-
- 16
-
-
-
Well, that would not be a problem at all, but don't you think this would be a good opportunity to create an account there and simply click the "new issue" button on your own (https://github.com/processwire/processwire-issues/issues) to show that you are willing to help resolving this issue? Using GIT was one the the major steps forward in the last few years for myself, so I'm quite sure you won't regret. PS: I haven't followed this topic; I'm sorry that I can't provide any help.
-
MS Office Fusion360 ... Besides that I was quite happy with Ubuntu on my Carbon X1, but I don't want to switch OS all the time and Office is just a must have for me ?
-
Well, a real linux kernel inside windows... And proper copy&paste. And having one single config json sounds awesome. Hope that principle will find its way to VSCode, then it would finally be really easy to share your dev environment across multiple machines ?
-
Interesting, thx for sharing!
-
Because it brings a lot of tools out of the box and makes everything really simple: New project --> create a new folder and klick reload MySQL --> HeidiSQL on board Testing E-Mails --> Mailcatcher on board Share your current work with a client --> ngrok on board But yes, sometimes it would be great to have a "real" linux machine for development. I've never tried WSL, but I've tried devilbox and came back to laragon because of its simplicity.
-
https://github.com/processwire/processwire/pulls There are still pull requests from 2016... Please @ryan could you take a look at the PR repository just like you did with the issues over the last weeks? There are many simple ones that really just need to be merged (like https://github.com/processwire/processwire/pull/143/commits/80aa0ac2e6383b32a4d0a932d5bec78a8fb5bf14 ). It's really frustrating if one tries to contribute and this contributions just seem to be ignored ?
-
module SnipWire - Snipcart integration for ProcessWire
bernhard replied to Gadgetto's topic in Modules/Plugins
Sounds great! ?- 235 replies
-
- shopping cart
- snipcart
-
(and 2 more)
Tagged with:
-
Hi @Himanshu Modi and welcome to the forum, there is a reason why ckeditor does usually NOT format everything as word does... The HTML code that is usually produced by copy-pasting from word is a nightmare. You'll have all kinds of styling attributes inside your code that has several disadvantages (SEO, different stylings across your site like size, font, colors etc).
-
module SnipWire - Snipcart integration for ProcessWire
bernhard replied to Gadgetto's topic in Modules/Plugins
You mean the config of the chart? Like type of chart, data, colors etc? Of course it would not make sense to put all that into the module config. But it could make sense to have a fieldtype (or at least an inputfield) that can easily be added to a process module (or page edit screen) and that makes it easier and more streamlined to build those charts. In RockGrid (which also has lots of options) I use a PHP file to get the data (via RockFinder) and a JS file for the grid config. I've started building a Chart module earlier this year, but did not release it: https://github.com/BernhardBaumrock/FieldtypeRockCharts Maybe you want to have a look and grab some ideas?- 235 replies
-
- shopping cart
- snipcart
-
(and 2 more)
Tagged with:
-
spa Architekturführer Köln - SPA in the front, ProcessWire in the back
bernhard replied to schwarzdesign's topic in Showcase
Same experience I got when I wanted to try it on mobile. I thought that was because it was too new when I tried first ? -
module SnipWire - Snipcart integration for ProcessWire
bernhard replied to Gadgetto's topic in Modules/Plugins
Looking great! Thx! Nice to see apex charts in action. Did you build it as a module (or have thought about that) or is it implemented manually?- 235 replies
-
- shopping cart
- snipcart
-
(and 2 more)
Tagged with:
-
Same here, now I know why I didn't know about it ? I'm using version 3.1 because I had something not working on 4.0 - I guess you are on a newer version?
-
Just had a glance. German umlauts seem to not work:
-
So would caching be an (easy) option? At the moment this is how RockGrid works: It makes one query to get one row (so the query should have limit=0,1) so that it knows which columns to setup for the grid. Then the second request is to get all data (and this is also used for all subsequent requests when reloading the grid). This is not the best solution, but I have no plans to change that for RockGrid. I start working on RockTabulator today where it will load all the data at the first request and display it instantly ?
-
That's strange, thx for checking @Robin S ! I'll report back...
-
Thx, but this does only allow P tags and strips all H, UL, etc ?
-
Thank you @Robin S for this one! Do you know the syntax for "disallow all styles except text-align:left|center|right|justify ? The docs only show how to allow everything except: https://ckeditor.com/docs/ckeditor4/latest/guide/dev_disallowed_content.html#how-to-allow-everything-except Or in other words: How can I disallow all styles so that they are removed when pasted from word (which works great with your custom config rule), but allow some formattings, like text-align features?
-
single line for very long text in admin page list
bernhard replied to pwfans's topic in General Support
Thx for the reminder about admin.php - I'm always creating hooks for injecting custom scripts. admin.php might be easier and a better place ? -
Hi @gbball, that's similar questions I asked when I shared my first project here in the forum, which was also a webapp with lots of mixed javascript + php involved. And I also stored lots of JavaScript in textarea fields: The project is dead, but you might still find some interesting code snippets in it - even though I would do everything completely different now ? Back to your questions: 1) What is JSON? https://en.wikipedia.org/wiki/JSON Modules are always the way to go when you want/need to reuse or share your code at some time. It's easier to just start writing code in the templates, but it's a lot more flexible, powerful and robust when you start writing modules and to understand OOP concepts of PHP. Which road you want to take depends on you, on the project, on the deadlines... If you want to start quick, just go ahead, get something done, have fun, hit some walls, learn, improve ? To my code example: Just take this in your home.php file to get the idea. <?php $js = (object)[ 'page' => [ 'id' => $page->id, 'path' => $page->path, 'name' => $page->name, 'title' => $page->title, ], 'foo' => 'bar', ]; ?> <script> mySettings = <?= json_encode($js) ?>; console.log(mySettings); </script> That way you can communicate between PHP and JS without mixing both languages in one file too much. Of course you assign the PHP $js settings to mySettings JS variable once, but then you can just access those variables from within JS. You could then include a regular JS file that shows your animations... checking for specific variables and values and then changing its look or features based on the value of those variables.
-
Yeah, really easy. I'd write your own implementation: <?php $js = (object)[ 'foo' => 'bar', ]; ?> <script> mySettings = <?= json_encode($js) ?>; var yourLibrary = new yourLibrary(); yourLibrary.setWhatever(mySettings.foo); // mySettings.foo = bar </script> Escaping might be a problem sometimes. Just see how $config->js() does it; I think it would be nice to have such a feature built into ProcessWire - but a JS API is on the roadmap for a long time...
-
Access $page and $pages Variables from inside a Javascript File?
bernhard replied to bytesource's topic in API & Templates
Only thing I want to mention is that you do expose some date from the PW backend to the public that you might not want to expose, eg ProcessWire.config.urls.admin: It's not critical, but it's also not necessary, so you might be better off using your own implementation of that principle: https://processwire.com/talk/topic/14077-config-js-only-working-when-logged-in/?do=findComment&comment=126552 I think that is easier than unsetting/masking the admin url property in the js object (because that would have to be done on the server side).