Comments (9)
Hi @SteelWagstaff,
thanks for the details!
(At first a remark regarding WXR: TablePress does integrate into the WordPress export/import system to some degree: If it's activated while a WordPress WXR export is triggered, it will add the table ID to the post's meta data. Then, likely on a different/new site, if TablePress is activated before a WordPress WXR import is performed (which needs the WordPress Importer plugin), it will retrieve the table ID from that added meta field and use it to reconstruct the table ID to post ID relationship. See the referenced hook functions. I don't think that all this helps in your workflow, but I wanted to mention it just in case.)
Now, I haven't looked at the media/H5P code that you linked to in too much detail, but from what I summarize from your description, you need two things:
- A GET endpoint for retrieving an individual table's full internal data on the source book site, e.g.
/wp-json/tablepress/v1/tables/<table-id>
. - On the target site, call e.g.
TablePress::$model_table->prepare_table()
,TablePress::$model_table->add()
andTablePress::$model_table->change_table_id()
(essentially the way howTablePress_Admin_Controller->_import_tablepress_table()
does it) with the retrieved data.
(In a second step, this could probably be embedded into a POST endpoint, so that your book migration system could make a REST API call to the target site, and wouldn't actually have to run on the target site anymore.)
Is that about correct? If so, we could look into developing a GET endpoint for retrieving the tables via the REST API. My preferred way would be to do this as a TablePress Extension in the beginning, so that development, testing, etc. can happen outside of the main plugin. I could probably use that mentioned boilerplate code as a start.
And just so that I understand this correctly: According to https://guide.pressbooks.com/chapter/book-cloning/, one can currently clone into PressbooksEDU networks only, but one can clone from any (openly licensed) Pressbooks site (included e.g. self-hosted)? If so, the GET endpoint should eventually be part of TablePress itself (so that Pressbooks sites don't have to separately have to install the TablePress REST API Extension)? The code from bullet point 2 above (or a POST endpoint as a wrapper) would, as of now, however only be needed inside your PressbooksEDU code?
Regards,
Tobias
from tablepress.
Hi,
sorry for the long delay: TablePress 2.0 will be out soon, see https://tablepress.org/8-million-downloads-tablepress-2-0/.
It will be getting more Premium features later this summer and one will be a TablePress REST API that can then be used here.
Best wishes,
Tobias
from tablepress.
Hi @SteelWagstaff,
thanks for reaching out about the integration of REST API features into TablePress!
I do in fact have ideas for adding support for that to a future major version of TablePress (think TablePress 2.0, maybe), but haven't chased that dream with a high priority, as the plugin's features won't benefit too much from it. So ressources and funding definitely plays a role here.
That said, I could very well imagine that such a REST API integration could first be developed as a TablePress Extension, for more flexibility and without impacting "standard" installations just yet. I do already have some wireframe code for that.
You mention a need for "cloning" tables. Could you maybe elaborate on that, i.e. what exactly would a TablePress REST API have to deliver and how would you process the response? Is that needed e.g. for conversion into other formats (PDF, ePub, ...)? Would that "just" encompass retrieving ("GET") the table data in its raw internal JSON format? Or would you want to retrieve the rendered table HTML (probably not, as that's already part of the current book pages, I assume)? Or are we even talking about full CRUD features, including adding, updating, deleting TablePress tables via a REST API?
Regards,
Tobias
from tablepress.
Hi @TobiasBg thanks for the encouraging response. Our users want to move openly licensed Pressbooks content from one server to another. In Pressbooks we call this "cloning". Cloning happens using the REST API. That said this could also be done using WXR (The WordPress eXtended Rss XML document), a generic WordPress feature you may also wish consider if you are coding this.
We do not use the API for conversion into other formats. All our desired use case needs is the ability to make exact copies of existing table data in a source book (site) when we clone that book (site) to a target location. Ideally, we would like your REST API endpoint(s) to provide us with a reliable GET method to fetch the table data in raw internal JSON format. At present, all we get in the data now is a shortcode like [table id=1 /]. Importing that shortcode into a target system doesn't help much because there is no table whose id=1 on the target system, and we can't infer anything from the id=1 outside of the source system (we don't have access to the source database).
If we're able to look up the underlying table data via a GET call to the source book, we would be able to save/store it and adjust the shortcode ID reference as needed in the target book (perhaps supporting a POST action would also be helpful, or at least some way to access your existing import table function?). Here's how we build a list of 'known' elements via available API endpoints in our current cloning routine for both media and H5P activities, both of which are currently stored in the database and referenced in WordPress shortcodes: https://github.com/pressbooks/pressbooks/blob/37c29e586dbb8ef88994a7625c91d8d03edb75ae/inc/cloner/class-cloner.php#L704-L762. We'd want to do something very similar for TablePress tables.
The comments from this H5P issue includes a other relevant technical/implementation details, mainly related to some of the ways that we depart from vanilla WordPress in our use of custom post types, etc: h5p/h5p-wordpress-plugin#63 (comment) (you can skim from here down to see conversation between connerbw, a former Pressbooks developer, and the developers at H5P who built their REST API endpoints).
from tablepress.
TablePress does integrate into the WordPress export/import system to some degree: If it's activated while a WordPress WXR export is triggered, it will add the table ID to the post's meta data. Then, likely on a different/new site, if TablePress is activated before a WordPress WXR import is performed (which needs the WordPress Importer plugin), it will retrieve the table ID from that added meta field and use it to reconstruct the table ID to post ID relationship. See the referenced hook functions. I don't think that all this helps in your workflow, but I wanted to mention it just in case.)
Excellent -- I didn't know this! The key for us would be simply making sure that TablePress is activated on the target book/site before the import runs then.
According to https://guide.pressbooks.com/chapter/book-cloning/, one can currently clone into PressbooksEDU networks only, but one can clone from any (openly licensed) Pressbooks site (included e.g. self-hosted)? If so, the GET endpoint should eventually be part of TablePress itself (so that Pressbooks sites don't have to separately have to install the TablePress REST API Extension)?
Actually, you can clone into and from all normal Pressbooks networks (whether EDU or self-hosted [i.e. open source]. The only cloning restriction we have is in relation to pressbooks.com, which is a huge WordPress multisite that we run for self-publishing authors (kind of like how wordpress.com functions in relation to wordpress.org). You cannot clone into pressbooks.com. Because the guide is for general pressbooks users, we note that limitation so as not to confuse the entry-level self-publishing users.
As for the API questions, let me bring them up in our product meeting tomorrow and get back to you.
from tablepress.
Hi @SteelWagstaff,
I hope everything is well! Do you maybe have updates from your meetings regarding this feature idea?
Best wishes,
Tobias
from tablepress.
Hi @SteelWagstaff,
is there still interest for this from Pressbooks' side at the moment? Otherwise, I'd close this as "maybe later", pending feedback. We could then of course always reopen the issue.
Best wishes,
Tobias
from tablepress.
Hi @TobiasBg so sorry for dropping the ball on this. Yes, there is still interest from Pressbooks side in moving this forward. I believe that the GET endpoint you proposed would be sufficient for our needs. Your proposal to do this as an extension/plugin for TablePress also makes sense to me. How can we help move this forward?
from tablepress.
Hi @SteelWagstaff,
thanks for your reply! I didn't mean to pressure, just trying to clean up a bit, in order to be able to plan time and resources better (big changes in family life coming up shortly 👶).
As a start, I would suggest that we look into creating a TablePress Extension that offers a /wp-json/tablepress/v1/tables/<table-id>
GET endpoint, available via authenticated REST requests. I already have an early version of this, but some effort is still needed in regards to proper integrating and testing everything. If you still think that Pressbooks could support this with some funding, I would be glad to discuss that, maybe in a direct email conversation (you can find my email on https://tablepress.org/impressum/).
from tablepress.
Related Issues (20)
- Responsive Table extension is triggering datatables HOT 2
- column_default missing in TablePress_Editor_Button_Thickbox_List_Table HOT 4
- Editor page hangs browser when table has many rows (~1000) HOT 1
- Cross site scripting HOT 2
- Table cross the maximum size of template HOT 1
- Uncaught TypeError: can't access property "disabled", o(...) is null HOT 8
- Lesbarkeit von Beiträgen (Yoast SEO) wird durch einfügen der Tabelle von Gut auf OK runtergestuft HOT 2
- Question: posibility to get table information from a json REST api, instead of importing? HOT 4
- Can't save Auto Import Tables config HOT 1
- Function WP_Block_Type_Registry::register was called incorrectly HOT 2
- tablepress_rest_api:missing_capability:tablepress_edit_table HOT 7
- Help with translation HOT 3
- Freemius integration is doing heavy damage to wp_sitemeta meta_key fs_accounts HOT 5
- aria-role="link" in previous/next-buttons is redundant HOT 4
- check if file exists before attempting to unlink HOT 2
- Freemius Performance issue after upgrading to 2.1.5 HOT 3
- Error: Function is_search was called incorrectly... HOT 4
- Change Default Table Features for Site Visitors HOT 1
- No obvious way to disable/revert inline CSS loading HOT 1
- Fatal error: Compatibility issue with FS Edd Migration plugin HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tablepress.