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解決什么問題