diff --git a/.github/workflows/dist.sh b/.github/workflows/dist.sh index 8827e4bd8..af24fe0c6 100644 --- a/.github/workflows/dist.sh +++ b/.github/workflows/dist.sh @@ -67,7 +67,7 @@ git switch $branch || git switch -c $branch echo "Syncing changes ..." rsync \ - -a \ + -rcvh \ --delete \ --stats \ --exclude=.git \ diff --git a/CHANGELOG.md b/CHANGELOG.md index 98d92348d..4f4bae0cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,20 @@ # Changelog -## [v2.0.0-alpha.2](https://github.com/marcantondahmen/automad/commit/6f0ee3a96542fb26de6816430938ba2c5283f1df) +## [v2.0.0-alpha.3](https://github.com/marcantondahmen/automad/commit/7403a58c8ede73b18b960191f408926901a2f7ad) -Sat, 24 Feb 2024 22:36:24 +0100 +Thu, 29 Feb 2024 21:01:04 +0100 + +### New Features + +- **console**: add migrate command for the migration of version 1 sites ([7403a58c8](https://github.com/marcantondahmen/automad/commit/7403a58c8ede73b18b960191f408926901a2f7ad)) + +### Bugfixes + +- fix syntax highlighting colors ([d40291c37](https://github.com/marcantondahmen/automad/commit/d40291c376fdfd36fcec8961927d28148d3475ea)) + +## [v2.0.0-alpha.2](https://github.com/marcantondahmen/automad/commit/0b38cec48ca28bd6e6c78f9686e612923fcaefe0) + +Sat, 24 Feb 2024 22:43:44 +0100 ### New Features @@ -327,16 +339,3 @@ Sat, 7 Aug 2021 19:45:51 +0200 - **ui**: fix disabled save button after deleting unused variable field ([fe375915e](https://github.com/marcantondahmen/automad/commit/fe375915e5afaa9fb9ec4798df3c466fd0e283a5)) - **ui**: fix position of block editor toolbar on large devices ([e19b4b983](https://github.com/marcantondahmen/automad/commit/e19b4b98356d22ed475a8f27489c1d65a26e83e2)) - **ui**: fix switcher tab update on hashchanges ([2a6725d37](https://github.com/marcantondahmen/automad/commit/2a6725d374ffd0b575b8ce98f7a0eb14707d222e)) - -## [v1.7.5](https://github.com/marcantondahmen/automad/commit/fe9027615d9a63051fa4e0cca80d7000a2830bae) - -Wed, 23 Jun 2021 20:24:36 +0200 - -### New Features - -- **blocks**: add option to exclude or include hidden pages ([64625ddbb](https://github.com/marcantondahmen/automad/commit/64625ddbb25bf224096b94085af98fa178d3f1f9)) - -### Bugfixes - -- **sitemap**: exclude private pages from sitemap.xml ([e4b6169c4](https://github.com/marcantondahmen/automad/commit/e4b6169c4c74be7a0d5cdf2bf09106e05a38b70a)) -- **ui**: remove resize option in image selection dialog ([3af5973c3](https://github.com/marcantondahmen/automad/commit/3af5973c3b406a2ff74545c3a8e2b716de2ed1b1)) diff --git a/README.md b/README.md index d793ed832..e66cbd045 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ A flat-file content management system and template engine. ![Tag](https://img.shields.io/github/v/tag/marcantondahmen/automad?include_prereleases&sort=semver&color=222222) -![PHP](https://img.shields.io/packagist/dependency-v/automad/automad/php?color=222222) +![PHP](https://img.shields.io/packagist/dependency-v/automad/automad/php?version=dev-master&color=222222) ![Language](https://img.shields.io/github/languages/top/marcantondahmen/automad?color=222222) ![Size](https://img.shields.io/github/languages/code-size/marcantondahmen/automad?color=222222) ![License](https://img.shields.io/github/license/marcantondahmen/automad?color=222222) @@ -21,6 +21,8 @@ A flat-file content management system and template engine. Note that this repository only contains source code. Please follow the instructions below in order to install a fully bundled version of Automad using [Docker](https://docker.com) or [Composer](https://getcomposer.org). +It is also possible to manually [download](https://github.com/automadcms/automad-dist/archive/refs/heads/master.zip) +and [install](#manual-installation) Automad. ### Composer @@ -50,6 +52,15 @@ docker logs mysite Your can now navigate to [localhost](http://localhost) to view your new site. +### Manual Installation + +In case you are not able to use Docker or Composer, you can also deploy Automad manually. + +1. Download a [distribution bundle](https://github.com/automadcms/automad-dist/archive/refs/heads/master.zip) and move the + unpacked content to the document root of your webserver. +2. Make sure the PHP process has the permissions to write to the document root and its subdirectories including all installed files. +3. Visit the `/dashboard` route of your site and create the first user. + ## Documentation Take a look at the [documentation](https://automad.org) to get started with Automad. diff --git a/automad/src/client/admin/core/factory.ts b/automad/src/client/admin/core/factory.ts index e93986b07..9f9571e48 100644 --- a/automad/src/client/admin/core/factory.ts +++ b/automad/src/client/admin/core/factory.ts @@ -242,6 +242,16 @@ export const createImagePickerModal = ( }, }); + const pageImagePicker = pageUrl + ? html` + + ` + : ''; + create( 'am-modal-dialog', [CSS.modalDialogLarge], @@ -289,14 +299,7 @@ export const createImagePickerModal = ( - ${pageUrl && - html` - - `} + ${pageImagePicker} code[class*='language-'] { @@ -65,7 +65,7 @@ pre[class*='language-'] { .token.constant, .token.symbol, .token.deleted { - color: var(--am-prism-2); + color: hsl(var(--am-prism-2)); } .token.selector, @@ -74,7 +74,7 @@ pre[class*='language-'] { .token.char, .token.builtin, .token.inserted { - color: var(--am-prism-4); + color: hsl(var(--am-prism-4)); } .token.operator, @@ -82,25 +82,25 @@ pre[class*='language-'] { .token.url, .language-css .token.string, .style .token.string { - color: var(--am-prism-2); + color: hsl(var(--am-prism-2)); } .token.atrule, .token.attr-value, .token.keyword { - color: var(--am-prism-4); + color: hsl(var(--am-prism-4)); } .token.function, .token.class-name { - color: var(--am-prism-3); + color: hsl(var(--am-prism-3)); font-weight: bold; } .token.regex, .token.important, .token.variable { - color: var(--am-prism-1); + color: hsl(var(--am-prism-1)); } .token.important, diff --git a/automad/src/server/App.php b/automad/src/server/App.php index d84b72a2a..bdf12944b 100644 --- a/automad/src/server/App.php +++ b/automad/src/server/App.php @@ -56,7 +56,7 @@ * @license MIT license - https://automad.org/license */ class App { - const VERSION = '2.0.0-alpha.2'; + const VERSION = '2.0.0-alpha.3'; /** * Required PHP version. diff --git a/automad/src/server/Console/Commands/Migrate.php b/automad/src/server/Console/Commands/Migrate.php new file mode 100644 index 000000000..95aad84c6 --- /dev/null +++ b/automad/src/server/Console/Commands/Migrate.php @@ -0,0 +1,234 @@ +setState(PublicationState::DRAFT, self::dataFile("$source/shared/data.txt"))->publish(); + + self::copyFiles("$source/shared", AM_BASE_DIR . AM_DIR_SHARED); + + $files = self::getFiles("$source/pages", '*.txt'); + + foreach($files as $file) { + $data = self::dataFile($file); + $path = dirname(Str::stripStart($file, "$source/pages")); + + echo " $path" . PHP_EOL; + + $DataStore = new DataStore($path); + $DataStore->setState(PublicationState::DRAFT, $data)->publish(); + + self::copyPageFiles("$source/pages", $path); + } + + echo 'Removing prefixes ...'; + self::removePrefixRecursively(AM_BASE_DIR . AM_DIR_PAGES); + + $count = count($files); + + echo PHP_EOL . "Migrated $count pages"; + } + + /** + * Copy files. + * + * @param string $src + * @param string $dest + */ + private static function copyFiles(string $src, string $dest): void { + $directoryItems = FileSystem::glob("$src/*"); + $files = array_filter($directoryItems, 'is_file'); + $files = array_filter($files, function ($path) { + return !str_ends_with($path, '.txt'); + }); + + foreach ($files as $file) { + echo ' copy ' . basename($file) . PHP_EOL; + copy($file, $dest . '/' . basename($file)); + } + } + + /** + * Copy media files of pages. + * + * @param string $sourcePages + * @param string $pagePath + */ + private static function copyPageFiles(string $sourcePages, string $pagePath): void { + $src = "$sourcePages/$pagePath"; + $dest = AM_BASE_DIR . AM_DIR_PAGES . $pagePath; + + self::copyFiles($src, $dest); + } + + /** + * Loads and parses a v1 text file. + * + * First it separates the different blocks into simple key/value pairs. + * Then it creates an array of vars by splitting the pairs. + * + * @psalm-suppress PossiblyUndefinedArrayOffset + * @param string $file + * @return array + */ + private static function dataFile(string $file) { + $vars = array(); + + if (!file_exists($file)) { + return $vars; + } + + $content = preg_replace('/\r\n?/', "\n", file_get_contents($file)); + + $pairs = preg_split( + '/\n\-+\s*\n(?=[\+\w\.\-]+:)/s', + $content, + -1, + PREG_SPLIT_NO_EMPTY + ); + + foreach ($pairs as $pair) { + list($key, $value) = explode(':', $pair, 2); + $vars[trim($key)] = trim($value); + } + + $vars = array_filter($vars, 'strlen'); + + foreach($vars as $key => $value) { + if (str_starts_with($key, '+')) { + $vars[$key] = json_decode($value); + } + } + + return $vars; + } + + /** + * Get list of files in v1 installation. + * + * @param string $dir + * @param string $pattern + * @return array + */ + private static function getFiles(string $dir, string $pattern): array { + $files = FileSystem::glob("$dir/$pattern"); + + foreach(FileSystem::glob("$dir/*", GLOB_ONLYDIR) as $d) { + $files = array_merge($files, self::getFiles($d, $pattern)); + } + + return $files; + } + + /** + * Remove prefixes from page directories. + * + * @param string $dir + */ + private static function removePrefixRecursively(string $dir): void { + $dataFiles = FileSystem::glob(rtrim($dir, '/') . '/*/' . DataStore::FILENAME); + + sort($dataFiles); + + foreach($dataFiles as $file) { + $path = Str::stripStart(dirname($file), AM_BASE_DIR . AM_DIR_PAGES); + $slug = basename(preg_replace('/^[^\.]+\./', '', $path)); + $newPath = $path; + + if (basename($path) !== $slug) { + $newPath = FileSystem::movePageDir($path, dirname($path), $slug); + } + + PageIndex::append(dirname($path), $newPath); + + self::removePrefixRecursively(AM_BASE_DIR . AM_DIR_PAGES . $newPath); + } + } +} diff --git a/package-lock.json b/package-lock.json index 48c95b7d6..6804cc1ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "automad", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 2cf3aab56..7958c10d5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "automad", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "description": "Automad", "author": "Marc Anton Dahmen", "license": "MIT",