Advice for editing multiple HTML/Markdown pages together. Any tools for editing multiple pages as a table?

huangapple go评论67阅读模式
英文:

Advice for editing multiple HTML/Markdown pages together. Any tools for editing multiple pages as a table?

问题

背景:我需要构建一堆类似的页面,50个或更多。它们共享许多设计和内容,因此我将尽量封装/重用尽可能多的样式和内容。但是,每个页面都有独特的元素,可能具有任意的设计元素,因此这些页面不能仅仅从数据库或资源文件中程序化地制造出来。

可能有所帮助:由于要跟踪这么多页面,我希望在一个大表格中编辑它们,而不是在一个长长的滚动文本文件中或在单独的文件中编辑。这将使得比较和对比每个页面的代码变得容易。这个表格可能如下所示:

| 分组 | 页面名称 | 描述 | 格式 | 头部 | 正文 | 页脚 |
|-------|-----------|-------------|------------|--------|------|--------|
| 1     | 页面1     |文本         |代码        |代码    | 代码 | 代码   |
| 1     | 页面2     |文本         |代码        |代码    | 代码 | 代码   |
| 2     | 页面3     |文本         |代码        |代码    | 代码 | 代码   |

这个示例中的前三个字段是供我自己使用的,或者可能作为元数据放入页面中,而剩下的字段显示了“真正”的代码应该放在哪里。

问题

  • 用表格形式编辑页面代码的想法是否正确?是否有更好的方法来一起设置一组类似的页面?

  • 如果表格编辑是有道理的,我应该使用什么工具?

我考虑过的工具

  • 文本/代码编辑器:好吧,毫不意外,但我没有找到任何允许你按行和列显示和编辑文件的代码编辑器,也许可以使用特殊标签来定义。是否有类似的工具存在?

  • 电子表格和结构化数据库:非常适合基本的行和列,但对于文本编辑来说不太好,多行行的显示效果不佳。

  • 专门的“结构化文本”数据库:也许存在这样的数据库,但我的搜索结果一无所获。大多数“文本数据库”都用于非结构化/自由格式文本。

  • “表格编辑器”:错误的想法,对吧?它们用于生成表结构的代码,然后在页面上显示,或者在数据库表单或报表中使用。

  • 文字处理软件。目前,我正在使用Microsoft Word中的表格,将HTML视为普通文本处理。将页面宽度设置为Word的最大值(22英寸),字体非常小,可以容纳我需要的列。我失去了代码编辑器提供的所有帮助,这是一个很大的损失,但至少我可以看到我在做什么。Word有一个键盘命令,可以将一个或多个行作为块上下移动,以帮助比较页面。但另一个主要缺点是我仍然必须使用Word VBA的“宏”将表格导出为CSV文件,然后编写一个小脚本来循环遍历CSV文件以创建实际页面。我还没有编写这些转换程序,所以如果您有其他建议,请告诉我。

这个项目的“页面”实际上是Anki卡片类型。

英文:

Background: I'm having to build a bunch of similar pages*, 50 or more. They share a lot of design and content so I will be encapsulating/reusing as much of the styling and content as possible. Still, each page has unique elements and may have arbitrary design elements, so the pages can't just be manufactured programatically from a database or resource file.

What might help: Because there are so many pages to keep track of I would like to edit them in a big table rather than in a long scrolling text file or in separate files. That would make it easy to compare and contrast the code for each page. The table would look something like this:

| Group | Page name | Description | Formatting | Header | Body | Footer |
|-------|-----------|-------------|------------|--------|------|--------|
| 1     | Page1     |text         |code        |code    | code | code   |
| 1     | Page2     |text         |code        |code    | code | code   |
| 2     | Page3     |text         |code        |code    | code | code   |

The first three fields in this example are for my own use or maybe would go into the pages as metadata, while the remaining fields show where the 'real' code would go.

Questions:

  • Am I on the right track with the idea of editing the page code in tabular form? Are there established better ways to set up a whole group of similar pages together?

  • If tabular editing does make sense, what tool should I use?

Tools I've considered:

  • Text/code editors: Ok, no surprise, but I haven't found any code editors that let you display and edit a file as rows and columns defined by, maybe, special tags. Does anything like that exist?

  • Spreadsheets and structured databases: great for basic rows and columns, but terrible for text editing, and display of multiline rows is lousy.

  • A specialized "structured text" database: Maybe one exists, but my searches came up empty. Most 'text databases' are for unstructured/freeform text.

  • "Table editors": wrong idea, correct? They're for generating code for table structures that you then display on pages, or use in database forms or reports.

  • Word processors. For now I'm going with a table in Microsoft Word, treating the HTML as ordinary text. With the page width set to Word's max (22") and the font really small, there's plenty of room for the columns I need. I lose all the help a code editor provides and that's a big loss, but at least I can see what I'm doing. Word has a keyboard command that lets you move one or more rows as a block up and down in a table, so that helps for comparing pages. But another major downside is that I will still have to export the table to a CSV using a Word VBA 'macro,' then write a little script to loop through the CSV to create the actual pages. I haven't coded those conversion routines yet, so if you have any alternatives to suggest, please do.

*The 'pages' for this project are actually Anki card types.

答案1

得分: 1

嵌套文件

我以前做的是将每个页面或页面元素构建为一个独立的文件,然后从另一个页面引用该文件。这导致了嵌套文件,但它使在普通文本编辑器中编辑页面变得更容易。

________________________________________________________________________________
| 头文件                                                                      |
|   脚本文件(或引用)                                                         |
| 主体文件                                                                     |
|   导航文件    | 内容文件                                                  |
|                      |   更多内容文件(从内容文件引用)           |
| 页脚文件                                                                     |
________________________________________________________________________________

如果需要的话,这可以嵌套得很深,但不一定要这样。而且,您可以从数据库中提取这些引用,而不是像通常情况下在您的网站逻辑中硬编码它们,但我不确定这样在Anki卡片中是否真的有效。

内容管理系统

如果您真的需要/希望将页面存储为代码/文本在数据库中,我建议为自己构建一个内容管理系统(CMS)。这需要大量的前期工作,但它将允许您做所有您想做的工作并将其存储在数据库中。

我曾为自己和我的网站客户编写过几个CMS,大部分时间都是一个漫长而困难的过程。您必须考虑到您想做的每一件事情。本质上,您正在重新创建FrontPage或DreamWeaver,而且您可能会像它们一样做得很糟糕,不幸的是。也许更糟糕。至少我是这样认为的。

如果在这个CMS中没有做任何图形工作,那么开发将会更容易,但您仍然必须手动管理您的链接,有点像StackExchange/StackOverflow的工作方式:一个用于代码的文本框,上面有一行基本的“高级”功能按钮,具有一半HTML和一半MarkDown语法,很容易混淆或因不经常使用而丢失功能。

网站构建工具

如果您不使用像Anki卡片那样特定的东西,我建议使用类似WordPress或Drupal的东西。基本上,它们是将页面存储为数据库中的行。当然,许多页面是使用GUI构建的,但有些人会以编程方式构建页面。

如果您像我一样,您可能更愿意手动编写所有内容。WordPress存在安全问题,我相当确定Drupal和其他所有工具也存在问题。人们为它们制作的插件似乎很少关心安全性,因此使用这些工具构建的网站通常是脆弱的,除非您将您的网站托管在它们的服务器上,这通常也不是首选。此外,您最终会在更新插件时花更多时间管理插件,而不是进行开发,或者这是我听到的一些专业人士的说法。您可能可以在那里编写页面,然后深入数据库将结果复制出来,但这似乎不是一种理想的做事方式。

结论

因此,似乎构建自己的解决方案似乎是您目前所拥有的有限选择中最好的选择。通过构建CMS,您可以像SE/SO一样立即呈现代码,还可以在同一个窗口中进行并排比较,如果需要的话。而且,您可以根据需要使其简单或复杂,并在需要时添加或删除功能。

再次强调,这可能不会容易,但更有可能是您想要/需要的,而不是其他人想象的可能对一般人有所帮助。如果您使这个CMS足够有用,甚至可能将其推广给其他使用Anki卡片的人。只是一个想法而已。

英文:

Nested files

What I've done before is to build each page or page element as a distinct file, then reference that file from another page. This ends up in nested files, but it makes editing pages in a normal text editor much easier.

<pre>


| Header file |
| Scripts file (or reference) |
| Body file |
| Navigation file | Content file |
| | More Content file (reference from Content file) |
| Footer file |


</pre>

This can get nested pretty deep, if you need, but it doesn't have to. And you can get these references pulled from a DB instead of having them hard coded in logic on your site, like normal, but I'm not sure how this would really work with Anki cards.

Content management sysyem

If you really need/want to store your pages as code/text in a database, I'd recommend building a content management system (CMS) for yourself. This involves a lot of work up front, but it'll allow you to do all the work you want to do and store it in a DB.

I've written a couple for myself and my website customers, and it's a long and difficult process most of the time. You have to think of literally everything you want to do. Essentially, you're recreating FrontPage or DreamWeaver and you'll probably do just as bad a job as they did, unfortunately. Maybe worse. At least I did.

If you don't do anything graphically in this CMS, it'll be easier to develop, but you'll still have to manage your links manually, sort of how StackExchange/StackOverflow works: a text box for code with a line of basic "advanced" features buttons above, with a half HTML and half MarkDown syntax that can easily get confusing or features lost due to not using them very often.

Website builders

If you weren't using something as specific as Anki cards already, I'd suggest using something like WordPress or Drupal. That's basically what they do: store pages as rows in a DB. Of course, many of the pages are built using a GUI, but some people build pages programmatically.

If you're like me, you'd rather stick to hand coding everything. WordPress has security issues and I'm pretty sure Drupal and all the others do too. The plug-ins people make for them seem to rarely care about security, so a site built with these tools are usually vulnerable, unless you have your site hosted on their servers, which is often also not a preference. Also, you end up managing plug-ins when they update more than actually doing development, or so I hear from people who do this professionally. You might be able to write your pages there, then dive into the DB to copy the results out, but that seems like a less than desirable way to do things, too.

Conclusion

So it seems as if building your own solution seems like the best of the lack of options you have. With building the CMS, though, you can have the code instantly rendered, like SE/SO, as well as do side-by-side comparisons in the same window, if you want. And you have the capability of making it as simple or complex as you want, along with adding or removing features when you want.

Again, this isn't likely to be easy, but it's more likely to be what you want/need than what someone else imagines might be helpful to people in general. And if you make this CMS useful enough, you might even be able to market it to others who use Anki cards. Just a thought, though.

huangapple
  • 本文由 发表于 2020年1月4日 01:02:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/59582472.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定