Importing Text Flat Files from Blosxom

This is the right place to report general bugs, make suggestions or ask for help.
Post Reply
miksmith
Posts: 19
Joined: Wed Jul 31, 2019 4:32 pm

Importing Text Flat Files from Blosxom

Post by miksmith » Wed Jul 31, 2019 4:38 pm

Hi

Im taking the plunge and moving away from a long-lived blosxom installation which is just insecure now. I have a directory full of text files (one file per blog post) and want to import them into FlatPress.

They are almost entirely straight text, with the odd bit of HTML introduced every now and then, along with hyperlinks and embedded images. In the first instance Id just be happy with getting all the text imported and can do some regex manipulation along the way.

Whats the easiest way to move the existing files to FlatPress?

thanks

mike

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Importing Text Flat Files from Blosxom

Post by Arvid » Fri Aug 02, 2019 12:54 pm

Mike, welcome to FlatPress :)

How does Blosxom store its entries' metadata (such as the date, subject etc.)?

FlatPress has the entries as text files under fp-content/content/[year]/[month]. The file name contains the entry's date formatted as entry[yy][mm][dd]-[hh][ii][ss].txt. Looking into the file, you see some metadata ahead of the content:

Code: Select all

VERSION|fp-1.1|SUBJECT|The entry subject|CONTENT|The content...
VERSION is the FlatPress version the entry was created under, SUBJECT is, well, the subject :D , and CONTENT is the entry content with BBCode (HTML will be parsed as well).

A simple way to see that all in action is just to set up a test blog with FP and fiddle around with the text files.

For migrating, you'd need a script that creates the file structure under fp-content/content/[year]/[month]. (If your entries don't spread over too many years, you could just create this structure manually.) When all entry files are created in their respective year/month subfolder, you'd just copy the whole file structure into your FlatPress directory. To let FP know about its new contents, rebuild the index in die Admin Panel (Maintain > Rebuild index).

Let us know if you need further help and how migration works out for you!
(The greatest outcome for the community would be a converter Blosxom-FlatPress to be used by anyone.)

All the best
Arvid

miksmith
Posts: 19
Joined: Wed Jul 31, 2019 4:32 pm

Re: Importing Text Flat Files from Blosxom

Post by miksmith » Tue Aug 27, 2019 4:54 pm

Thanks for the help! Im working on some import instructions for Blosxom. One query...

-each file is appended with:
|AUTHOR|miksmith|DATE|1566926569|CATEGORIES|1,2|

How is the DATE calculated?

thanks

User avatar
Arvid
FlatPress Coder
Posts: 558
Joined: Sat Jan 26, 2019 7:40 pm
Contact:

Re: Importing Text Flat Files from Blosxom

Post by Arvid » Wed Aug 28, 2019 6:19 am

Hi,
miksmith wrote: ↑Tue Aug 27, 2019 4:54 pm -each file is appended with:
|AUTHOR|miksmith|DATE|1566926569|CATEGORIES|1,2|

How is the DATE calculated?
This is the UNIX time stamp (seconds since 1970-01-01) of the entry's creation date. (check https://www.unixtimestamp.com/).
1566926569 would be 2019-08-27, 17:22:49 (UTC).

Regards
Arvid

miksmith
Posts: 19
Joined: Wed Jul 31, 2019 4:32 pm

Re: Importing Text Flat Files from Blosxom

Post by miksmith » Fri Sep 27, 2019 2:42 pm

We now have a working Blosxom to Flatpress converter :) The process is broadly this:

-download your Blosxom files, including all the sub-directories for categories, but make sure to maintain the date/time filestamp of individual files - this is used to timestamp the entry for Flatpress. WinSCP does this (Filezilla doesnt)
-make sure the categories only ONE DIRECTORY DEEP. Move any sub-sub-directories up to the top level
-rename all the directories to numbers. These are used to tag the entries and can then be recreated within FlatPress
-copy the script.py and template files to the directory the folders are stored in
-edit the template file to have the header/footer you want. The content, date and categories will be changed for the entries
-run the script
-a new fp-content directory will be created with all your entries
-copy this to your flatpress site and rebuild the index

The script does the following
-rename s the file to entry<date>-<time>.txt based upon the date modified date
-copies the file to a new subfolder in FlatPress /content folder based upon year and month
-cuts the first line from the file (and deletes the first line break)
-prefixes the file with:
VERSION|fp-1.1|SUBJECT|<first line from file>|CONTENT|
-suffixes with:
|AUTHOR|miksmith|DATE|<1566926569>|CATEGORIES|<orig_dir_name>|

BIG shout out to James O'Connor for putting the script together after we'd worked out what to do!
Attachments
script.7z
(862 Bytes) Downloaded 253 times

miksmith
Posts: 19
Joined: Wed Jul 31, 2019 4:32 pm

Re: Importing Text Flat Files from Blosxom

Post by miksmith » Fri Sep 27, 2019 4:26 pm

Small bug fixed which concerned the CATEGORY tag and variances between OSs
Attachments
script.7z
(870 Bytes) Downloaded 274 times


Post Reply

Who is online

Users browsing this forum: No registered users and 44 guests