restful解决什么问题_当您陷入RESTful,WordPress和一个困难的地方时,如何解决CMS问题...

那正初
2023-12-01

restful解决什么问题

by Jessica Duffin Wolfe

杰西卡·达芬·沃尔夫(Jessica Duffin Wolfe)

当您陷入RESTful,WordPress和一个困难的地方时,如何解决CMS问题 (How to solve a CMS problem when you’re caught between RESTful, WordPress, and a hard place)

Last fall I was trying to decide on how to host and manage a small storytelling project built by around 40 users — my students. I wanted them to have a clean and easy experience uploading their content (images and audio files, along with some text). I also wanted it to be stored long-term in a format my little Vue.js app could easily pull in to display without a lot of set up and overhead on my part.

去年秋天,我试图决定如何托管和管理一个由大约40个用户(我的学生)构建的小型故事项目 。 我希望他们在上载内容(图像和音频文件以及一些文本)时拥有干净整洁的体验。 我还希望将其以我的小Vue.js应用程序可以轻松插入显示的格式长期存储,而无需进行很多设置和开销。

I’ve relied very happily on WordPress as a primary Content Management System (CMS) for years, but it’s been feeling a bit old lately, and it’s not quite designed for such a heavily AV-based, multi-user project, so I decided to look around for good fresh options.

多年来,我一直非常愉快地将WordPress用作主要的内容管理系统(CMS),但是最近感觉有点陈旧,并且它并不是为基于AV的多用户项目而设计的,因此我决定到处寻找新鲜的好选择。

选项1:Google表格 (Option 1: Google Sheets)

The simplest path seemed to be setting up a Google Sheet the students could populate with links to their own self-hosted media. I’ve had good experiences building small sites like this before pulling in the data through JSON.

最简单的方法似乎是设置一个Google表格,学生可以在其中添加指向自己的自托管媒体的链接。 在通过JSON提取数据之前,我在构建像这样的小型网站方面有很好的经验。

For this case, though, with around fifteen different content pieces going into each user’s contribution, if I used a spreadsheet it would be a beast, and populating it would not be a good user experience for the students.

但是,对于这种情况,每个用户的贡献中有大约15个不同的内容,如果我使用电子表格,那将是野兽,而填充它对于学生而言将不是良好的用户体验。

The links to the students’ self-hosted media also risked going bad over time, as accounts lapse, and services dry up. I didn’t want the project to get patchy, and I didn’t want to have to do too much maintenance on it each year to keep it solid.

随着时间的流逝,由于帐户失效和服务枯竭,与学生的自托管媒体的链接也可能会变坏。 我不希望该项目变得零散,也不想每年对其进行过多维护以保持其坚固性。

So, no to Google Sheets.

因此,对Google表格不适用。

选项2:内容充实 (Option 2: Contentful)

Contentful is a headless CMS, which means it provides infrastructure for storing, editing, and serving content without providing any sort of front-end display. Traditional WordPress, in contrast, is set up to do both — store your content, and offer up all the code that retrieves and displays it. This big stack of abilities makes it pretty bulky, and increasingly it doesn’t feel as nimble as a web tool should.

Contentful是无头CMS,这意味着它提供了用于存储,编辑和提供内容的基础结构,而无需提供任何类型的前端显示。 相比之下,传统的WordPress可以同时执行这两种操作-存储您的内容,并提供检索和显示它的所有代码。 如此众多的功能使其变得非常庞大,并且越来越感觉不到Web工具应该具有的敏捷性。

I was really excited about Contentful. It’s so pretty and slick! And so smart — it permits direct geotagging of content! Ahhh. And I could set up a custom content model that exactly matched the project at hand, and it was fun! Yay.

我对Contentful感到非常兴奋。 它是如此的漂亮和光滑! 如此智能-它允许直接对内容进行地理标记! 啊 而且我可以建立一个与手头项目完全匹配的自定义内容模型,这很有趣! 好极了。

After spending some time configuring Contentful, I desperately wanted to use it, but I began to lose interest the more I thought through how the students would upload their work.

在花了一些时间配置Contentful之后,我非常想使用它,但是我对学生如何上传他们的作品的想法越多,我就开始失去兴趣。

The free tier maxes out at five users. While I could have had the students upload their content through one generic user account, this would not have been a good experience, as they would have had to wade through the back end and other people’s files to submit their work.

免费套餐最多可容纳五个用户。 尽管我本可以让学生通过一个通用用户帐户上传内容,但这并不是一个很好的体验,因为他们必须经过后端和其他人的文件才能提交工作。

I also wasn’t convinced that the free tier would have covered the hosting needs of this project. It probably would have been fine — but I would have found myself keeping an eye on bandwidth and API requests and the longterm status of the content.

我也不相信免费套餐能够满足该项目的托管需求。 可能会很好-但我会发现自己一直在关注带宽和API请求以及内容的长期状态。

With the first paid tier starting at $249 per month, levelling up was too expensive to consider. That pricing deterred me from even wanting to use a free account, because I knew I would never upgrade at that price. So there was a chance I’d need to migrate everything if I started building the project on the service.

由于第一个付费级别的起价为每月249美元,因此升级成本太高,无法考虑。 这种价格使我什至不想使用免费帐户,因为我知道我永远都不会以这个价格升级。 因此,如果我开始在服务上构建项目,就有可能需要迁移所有内容。

It was clear Contentful didn’t really want the business of small-scale experimental work — fair enough — and anyway it was getting too annoying to be fussing over these details for a little project.

很明显,Contentful并不真正希望进行小规模的实验工作(足够公平),无论如何,它变得太烦人了,以至于无法为一个小项目忙于这些细节。

选项3:RESTful WordPress (Option 3: RESTful WordPress)

While I was trying to make Contentful work, I kept switching back to a WordPress install to play around. Bulky though the old WP can be, faced with Contentful’s nickle-and-dime approach of charging for content “records,” I was starting to feel very nostalgic for the ease and freedom of adding content in WordPress.

当我尝试使Contentful正常工作时,我一直切换回WordPress安装进行操作。 尽管可以使用旧的WP,但是由于面对Contentful的内容“记录”收费的灵活方法,我感到非常怀旧,因为我对在WordPress中添加内容的便捷性感到非常怀旧。

I thought — well, hey — why not use WordPress as a headless CMS with its new REST API feature? This would let me get around the bulk of serving content through PHP, while still allowing me to use WordPress as a CMS, an interface my students know well.

我以为-嘿-为什么不将WordPress与其新的REST API功能一起用作无头CMS? 这将使我能够通过PHP解决大量的内容提供服务,同时仍然允许我将WordPress用作CMS,这是我的学生很熟悉的界面。

To allow the students to add all the images and audio for their projects, I would need to add a custom post type. To do that I would need to add a plugin. To use the plugin I would need to figure out how to configure it, and then create an appropriate custom post type that would provide in an easy-to-use interface inside the WP system. To do that I would need to rewrite WordPress from the ground up, because bless its heart it is not built to do anything other than look and feel like WordPress. It manages blog posts really, really, really well, and can be muddled into doing some other things sort of but not well. The whiff of the blog post never really fades.

为了允许学生为他们的项目添加所有图像和音频,我需要添加一个自定义帖子类型。 为此,我需要添加一个插件。 要使用该插件,我需要弄清楚如何配置它,然后创建一个适当的自定义帖子类型,该类型将在WP系统内部的易于使用的界面中提供。 为此,我需要从头开始重写WordPress,因为请保佑它的内心,它的外观和感觉不像WordPress。 它确实,非常,非常好地管理博客帖子,并且可能被混淆为做一些其他事情,但是做得不好。 博客帖子的味道从未真正消失过。

I gave up on all this before even trying to figure out how I would use the REST API in my project. I’m still excited about it, though. It’s probably an amazing option for serving content from larger sites using JS frameworks.

我什至在试图弄清楚如何在项目中使用REST API之前就放弃了所有这些。 不过,我仍然对此感到兴奋。 对于使用JS框架从较大的站点提供内容,这可能是一个了不起的选择。

选项4:WordPress +表格= CMS Sugar (Option 4: WordPress + Forms = CMS Sugar)

The solution I finally settled on seemed ridiculously simple and a funny amalgam of all my earlier efforts.

我最终选择的解决方案似乎很简单,而且是我以前所有工作的有趣组合。

Using Gravity Forms, a WordPress plugin I know my way around from other projects, I built a basic form through which the students could upload all fifteen of their files, and paste in their text components.

使用Gravity Forms(一个我在其他项目中知道的方法)的WordPress插件,我建立了一个基本表单,学生可以通过该表单上载全部15个文件,并粘贴其文本组件。

I exported the entries as a spreadsheet with links to the uploaded content stored in the WordPress site, and I turned this file into JSON to use just as I would a Google Sheet.

我将条目导出为电子表格,并带有指向WordPress站点中存储的上载内容的链接,然后将该文件转换为JSON以像使用Google表格一样使用。

So my students got a clean, familiar, and accessible experience uploading their content, and I will be able to store it long term without hassle in a format my static web app will play nicely with. Problem solved.

因此,我的学生在上载内容时获得了干净,熟悉且可访问的体验,并且我将能够长期存储它,而不会遇到麻烦,可以使用我的静态Web应用程序可以很好地使用的格式。 问题解决了。

Ta da! Why was this solution not more obvious when I began?

da! 为什么当我开始时这种解决方案不那么明显?

For me, one moral of this story is that even in this era of increasingly fancy decoupled and well-rested deployment options, it still helps to know your way around WordPress — that despite getting a bit long in the tooth, its low-cost, and feature-rich ecosystem continues to lower barriers to digital creativity.

对我来说,这个故事的寓意是,即使在这个如今越来越花哨的去耦合和休息的部署选项的时代,它仍然有助于您了解WordPress的使用方法-尽管花费了很多时间,但它的低成本,而且功能丰富的生态系统继续降低了数字创意的障碍。

翻译自: https://www.freecodecamp.org/news/how-to-solve-a-cms-problem-when-youre-caught-between-restful-wordpress-and-a-hard-place-77bbebe49e1b/

restful解决什么问题

 类似资料: