Nextcloud Uploader - php

I just got some questions, maybe some of you can answer.
The benefit by Nextcloud / Owncloud and so on is more than just uploading taking files with you and so on.
It does version the files, make them downloadable - as well secure behind.
It would be benefitial for me and most everyone who is dealing with the Question:
"How to upload documents, link them in some kind of Database (which main purpose is to operate with information) and versioning, saving, editing and so on does not need to be implemented by me / others, because it is handled by Nextcloud (in my case prefered)?"
Is there any script outside, or maybe some kind of plugin to have that benefit?
In my vision I would need:
One "Drag and Drop" Area for Documents / Pictures etc.
This should have a hidden field, which is filled with a id, with which the system can identify the file.
a onetime Link (with retention of that link by one day or so) what is generated by php (could also be a script) and generates a share Link for given id.
(not needed since now, but nice to have:) some script as in 2, where versions of some given File should be viewed.
Some solution could be:
something similar to an "iframe" for a shared link with public upload.
But Im not very happy of using IFrames... Something better would be nice.

Drag & Drop is available in the Web UI. For additional meta data, use a hook mechanism on postCreate (\OCP\Files\Node $node) within a custom app/module you'd need to deploy. For hooks, see https://docs.nextcloud.com/server/12/developer_manual/app/hooks.html.
About meta data: you don't need to store them in a database necessarily, you can also use custom WebDav properties. I wrote a blog post about it recently: https://medium.com/#mathiasconradt/how-to-assign-custom-meta-data-to-your-documents-on-nextcloud-23356cf3f926
Links with a time limit to be valid can be generated manually via Web UI. If you need it automated on upload, use the same approach as in (1): hook mechanism that listens to file creations, as part of a custom app.
at the moment, you can only restore old versions. I think you cannot diff/view them. Would require a custom app.
General info on how to write your own module / app: https://docs.nextcloud.com/server/12/developer_manual/app/index.html

Related

Wordpress Plugin. Where should I save my simple cache?

I am writing a little plugin to access the Instagram API for one account with some simple custom methods. I am curious as to how/where one should save this type of cache within the Wordpress system to be standard? (i.e. Flat file, stored in X location with other cache files.)
Standalone, I would probably use a flat file to store the cache being it will only be updated periodically and only pulls a few posts from one account. But perhaps there is a good way to use Wordpress to store this data to the DB. Either way I am not sure where this should be located within Wordpress's DB or file structure. Thank you!

How does cushy cms implement its features?

I am curious if anyone can explain how does Cushy CMS implement its features. What I am referring to is adding a class in html , like <div class="cms-editable"></div> and automatically make that div editable and save contents to database. Do they use a parser and write the file? I do not think they save the data to the database.
Cushy is FTP-based, meaning it works directly on your file structure. When you view your website after logging into Cushy's website it is this website interface that pulls in the page you are editing on and inspects the places where the class file exists and makes this an editable item. It uses the FTP credentials you have entered to make the call via FTP protocol to pull in your website pages. It also parses the dom and checks for the class name "cms-editable" and makes this content editable through an HTML editor after some configuration steps after installation. When you make changes and save them, it directly modifies the content area that you defined as editable via FTP again. There are many tools in any server-side language to accomplish this for FTP protocol and DOM parsing.
The Good thing about Cushy CMS
It works for static websites so easily, a designer could set it up.
The Bad thing about Cushy CMS
Its terrible for dynamic websites as your clients are directly editing on your pages and will easily break the website with accidental syntax errors. It does not fit for MVC-style and web programming in general.
It requires too much administration after setup as you have to first set an item to be editable on your file directly, then you must give permission through its interface. Imagine doing this for a templated pages being reused. Basically you can't.
It cannot handle the same file being edited in different parts at the same time by different users because its actually just a source file being edited upon. Here is where overwrites become an issue when someone saves something thinking they are only saving the part they edited, not realizing they just saved the entire document.
To give background to my answer, I wrote a CMS tool that is cloud-based and built in a completely different manner than Cushy because its for developers as FTP is a huge limitation when a feed-based approach is much more appropriate. Also, having to log into another website to edit your stuff just sucks. In fact, why even have a back office at all when you have HTML5 client-side editing capabilities and postMessage for cross-domain communication? My profile has more details on this approach.

A/B Development in Joomla?

I've been asked to update a client's Joomla! template to have a new header image, but I'd ideally like a way to make the change and display it to a client in a special area, without it compromising their main website until approved.
Is there any way of doing this without checking out their entire website, installing it as a local development branch, checking it into another development server, and then migrating the change after approval?
I use the term "A/B Development" in the way that "A/B Testing" is used -- ultimately forking small changes to different users, except used on a micro scale (unlike normal A/B Testing, where a small variation is pushed to a wide user base, from which some sense of empirical effectiveness can be tested).
Thanks!
In your Joomla backend duplicate the template and make the changes to it. You can then set your customers user account to use the dev-template, or assign it specific menu items that are hidden (so you can just pass a link, no account and login needed) or match appropriate permissions.
Sure it can be done, but it really depends on how your template is coded. Here are the two most common I can think of -
If your header image is in a module simply create a new module with the new image. Then create a hidden menu item and assign the new header to that page.
If your header image is a background image, then you will need to use the page class suffix to make it work. You'll need to make sure that your template adds the page class suffix to the body tag. Create a hidden menu item and give it a unique page class suffix. Then it is simply a matter of adding the CSS to switch the image on the hidden page.
The correct software engineering approach is to automate your build/deployment processes so that it's trivial for you to deploy to multiple environments. Usually ANT scripts are the glue while TeamCity or Hudson are the project-container frameworks used to package your build processes.
This is all part of a concept called continuous integration, which leads you down the path of automated testing and push-button deployments.

Where to store and mantain production code making it available for users to include its url

Let's say we created a small widget or web app. or just a plugin - and we want to distribute it to the public. (JS, jQuery...)
...and we have no server- or we are afraid it will close one day.
...and we'd like to provide that script like an url-to-script to be included into a script tag.Like we do with the jQ library -- Is there any provider that allows us to store codes and generates a livetime url to it?? That we can mantain, change or fix it anytime without the need to inform all users?
Have Google something like that?
Or am I dreaming?
You can upload on github. It's free for open-source projects, and you can even link directly to the repo's master branch; example:
https://github.com/douglascrockford/JSON-js/raw/master/json_parse.js
(There are good reasons not to do that as a general rule — the master branch could get a breaking change committed to it, for example — but it's there if you need it.)

Drupal / ubercart remote node addition

I am developing my first large Ubercart site, which needs to have a daily product database update from an existing xBase (DBF format). The conversion from DBF to MySQL/PHP is handled on the same server as the Drupal installation, using some custom scripting I have done, and works well. However, the next step is to get my script to talk to Drupal and update the product nodes with pricing/stock level/etc.
Googling hasn't resulted in any good hits, at least in PHP terms.
So how do I go about this? Can I just use a POST to a particular page in Drupal, ie RESTful, or do I have to use some more arcane xmlrpc method?
There's a couple ways to approach this. If you need to de-couple your import system from php you could create a api that would allow you products to be updated from an authenticated data provider.
http://drupal.org/project/services
The simpler method though is if your working in php you should bootstrap drupal and insert / update the nodes from php:
Here's a great howto on doing that: hxxp://www.group42.ca/drupal_command_line_script_template

Categories