mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 17:45:18 -05:00
Import and Export have a new group, Website: - WordPress (.xml): WordPress eXtended RSS from Tools -> Export, as Squarespace, Wix and others also write it; written as WordPress reads it. - WordPress REST API (.json): /wp-json/wp/v2/posts and /pages. - Ghost: its JSON export, written as Ghost's importer reads it. - Blogger (.xml): its Atom backup. - Hugo, Jekyll, Eleventy, Astro (.zip): Markdown files with YAML or TOML front matter, and their images; written as content/pages and content/posts. - HTML website, Medium (.zip): a site's .html pages and images, read for their main text; written as the published site itself, ready for any web server, with the cards' attachments beside their pages. - Substack (.zip): posts.csv and the posts' HTML. Each page and post becomes a card in the list of its status (Published, Draft, Pending review, Scheduled, Private), pages in the swimlane Pages and posts in Posts, its content as Markdown, a subpage as a subtask, categories and tags as labels, approved comments as comments, a .zip's images as attachments. A site's HTML is read as text, so no script of it reaches a card; a card's text is written into an exported site escaped, never as markup. Board View / Website shows the board as that website: the cards of its Published list (every list when it has none), Pages as the menu with the subpages, the other cards as posts, newest first, and the cards' attachments - built straight from the board. As a public board's default view in Board Settings / Board View, it is what visitors see at the board's address instead of the kanban; a draft is never shown, not even by its id. Admin Panel / Features can turn it off. The Sandstorm WordPress and Hacker CMS grain imports stay under Sandstorm, by the rule that a platform's apps are listed under it. 12 new strings are translated in every language. Lower-confidence translations: ace, ak, ay, bi, bm, bo, dz, ee, chr, bua, cv, ba, csb, an, co, br, ary, bho, as, am, ckb, iu, kl, ff, fj, gn, gv, kw, ig, ha, haw, ks, kok, fur, hsb, fo, ku, lld, nah, rup, sah, se, sc, scn, nap, qu, sm, pap, lg, nd, ss, nso, rn, om, mg, ny, sn, so, ps, sd, mai, or_IN, my, la, tig, wal, tlh, vo, zgh and ve-PP. Thanks to xet7 !
76 lines
4.1 KiB
JavaScript
76 lines
4.1 KiB
JavaScript
// "Export all boards": every board a user can export, in one format, in one
|
|
// download (server/lib/exportAllBoards.js). Plain JavaScript, so
|
|
// tests/exportAllBoards.test.cjs runs it in Node.
|
|
//
|
|
// - Excel: ONE workbook, a sheet per board, the sheet named after the board.
|
|
// - Every other format: a .zip with one file per board, named after it.
|
|
|
|
import { EXTERNAL_EXPORT_FORMATS } from './externalExportFormatters.js';
|
|
|
|
// The extension of one board's file, per format key. The tool formats are
|
|
// those of the board export menu (client/components/boards/exportScope.js);
|
|
// a format not listed here is a JSON document.
|
|
const EXTENSIONS = {
|
|
wekan: 'json', csv: 'csv', scsv: 'csv', tsv: 'tsv',
|
|
markdown: 'md', leo: 'leo', opml: 'opml', orgmode: 'org', todotxt: 'txt', taskwarrior: 'json', focalboard: 'jsonl',
|
|
todoist: 'csv', meistertask: 'csv', obsidian: 'md', linear: 'csv', ticktick: 'csv', clickup: 'csv', nullboard: 'nbx',
|
|
pivotal: 'csv', redmine: 'csv', notion: 'csv', quire: 'csv', superproductivity: 'json', vikunja: 'zip', fizzy: 'zip',
|
|
planner: 'xlsx', monday: 'xlsx', wrike: 'xlsx', teamwork: 'xlsx', businessmap: 'xlsx',
|
|
mbox: 'mbox', enex: 'enex', mattermost: 'jsonl', rocketchat: 'zip',
|
|
wordpress: 'xml', wordpressjson: 'json', ghost: 'json', blogger: 'xml', markdownsite: 'zip', htmlsite: 'zip',
|
|
sandstormprioritize: 'zip', sandstormyatl: 'zip', sandstormmutodo: 'zip', sandstormsandchat: 'zip', sandstormethercalc: 'zip', sandstormradicalecalendar: 'zip', sandstormradicalecontacts: 'zip', sandstormdavros: 'zip', sandstormhackercms: 'zip',
|
|
azuredevops: 'csv', mslists: 'csv', msproject: 'xml', outlook: 'zip', onenote: 'zip', teams: 'json',
|
|
};
|
|
export const extensionOf = format => EXTENSIONS[format] || 'json';
|
|
|
|
// The formats "Export all boards" offers: WeKan's own JSON, CSV/TSV, Excel and
|
|
// every tool format. PDF, HTML, iCalendar and the dependency graph are
|
|
// documents of one board and are not among them.
|
|
// The Trello .zip streams a board's files and is not one of them: "Export all
|
|
// boards" makes each board's file whole (server/lib/renderExternalExport.js).
|
|
export const MASS_EXPORT_FORMATS = ['wekan', 'csv', 'scsv', 'tsv', 'excel', ...EXTERNAL_EXPORT_FORMATS.filter(format => format !== 'trellozip')];
|
|
export const MAX_MASS_EXPORT_BOARDS = 1000;
|
|
|
|
// ?boardIds=a,b,c -> ['a', 'b', 'c'], or null for every board. Ids are
|
|
// Meteor ids; anything else is dropped.
|
|
export function parseBoardIds(value) {
|
|
if (value === undefined || value === null || value === '') return null;
|
|
return [...new Set(String(value).split(',').map(id => id.trim()).filter(id => /^[A-Za-z0-9_-]{1,64}$/.test(id)))]
|
|
.slice(0, MAX_MASS_EXPORT_BOARDS);
|
|
}
|
|
|
|
// Excel sheet names: at most 31 characters, none of \ / ? * [ ] :, not empty,
|
|
// not starting or ending with an apostrophe, and unique regardless of case.
|
|
// A name that is taken gets " (2)", " (3)" ... within the 31 characters.
|
|
export function uniqueSheetNames(titles) {
|
|
const used = new Set();
|
|
return (titles || []).map(title => {
|
|
const base = String(title || '').replace(/[\\/?*[\]:]/g, ' ').replace(/\s+/g, ' ').trim()
|
|
.replace(/^'+|'+$/g, '').trim().slice(0, 31).trim() || 'Board';
|
|
let name = base;
|
|
for (let n = 2; used.has(name.toLowerCase()); n += 1) {
|
|
const suffix = ` (${n})`;
|
|
name = `${base.slice(0, 31 - suffix.length).trim()}${suffix}`;
|
|
}
|
|
used.add(name.toLowerCase());
|
|
return name;
|
|
});
|
|
}
|
|
|
|
// File names in the .zip: the board's title as the single board export names
|
|
// its file (letters, digits, . _ -), unique regardless of case.
|
|
export function uniqueFileNames(titles, extension) {
|
|
const used = new Set();
|
|
return (titles || []).map(title => {
|
|
const base = String(title || '').replace(/[^a-z0-9._-]+/gi, '-').replace(/-+/g, '-').replace(/^[-.]+|[-.]+$/g, '')
|
|
.slice(0, 80) || 'board';
|
|
let name = `${base}.${extension}`;
|
|
for (let n = 2; used.has(name.toLowerCase()); n += 1) name = `${base}-${n}.${extension}`;
|
|
used.add(name.toLowerCase());
|
|
return name;
|
|
});
|
|
}
|
|
|
|
// The download's own name.
|
|
export const massExportFilename = format => (format === 'excel' ? 'wekan-boards.xlsx' : `wekan-boards-${format}.zip`);
|