GithubHelp home page GithubHelp logo

skybrud / skybrud.umbraco.redirects.import Goto Github PK

View Code? Open in Web Editor NEW
6.0 6.0 11.0 1003 KB

Import and export addon for Skybrud.Umbraco.Redirects.

License: MIT License

Batchfile 0.18% JavaScript 7.02% CSS 1.86% Less 1.74% HTML 6.88% C# 82.32%
dotnet export import limbo package redirects skybrud umbraco-backoffice umbraco-cms umbraco-package

skybrud.umbraco.redirects.import's Introduction

Skybrud Redirects Import

GitHub license NuGet NuGet Umbraco Marketplace

Import and export addon for Skybrud.Umbraco.Redirects. The package features an extensible set of importers and exporters, and by default it supports importing from and exporting to CSV, XLSX and JSON files.

License: MIT License
Umbraco: Umbraco 13
Target Framework: .NET 8



Installation

Umbraco 13

The package is only available via NuGet. To install the package, you can use either .NET CLI:

dotnet add package Skybrud.Umbraco.Redirects.Import --version 4.0.2

or the NuGet Package Manager:

Install-Package Skybrud.Umbraco.Redirects.Import -Version 4.0.2

Other versions of Umbraco



Screenshots

image The package adds an Import option as well as an Export option to the existing Add redirect button.

image Package includes default importers and exporters for CSV, JSON and XLSX.

image Each import may have different options - here is the options for the CSV importer.

image When uploading the CSV file, a status is shown for each redirect. If not set to override existing redirects, the importer will fail for any existing redirects.

skybrud.umbraco.redirects.import's People

Contributors

abjerner avatar bjarnef avatar garpunkal avatar hfloyd avatar jawood1 avatar pedro-mpontes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

skybrud.umbraco.redirects.import's Issues

CsvRedirectsProvider: Import not separating columns at commas

While trying to sort out the BOM issue, I realized next that the CSV file hadn't been split properly. It was only listing 1 column, even though there are two in the CSV.

This is what the debugger is showing:
image

It is reading the comma as part of the first column name.

Import results always shows an error

The overlay showing the import results always shows an error, even though no error occurred:

image

Found this issue using the package on Umbraco version 11.2.1.

ParseRootNode using a domain returns an error "Root node with ID 'XXX' not found."

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

4.0.1

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.17

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10.7.0

Bug description

This is a small bug when parsing the redirects on the method ParseRootNode the logic correctly retrieves the correct ID however it's not getting passed in to the TryGetContent method as it's calling the earlier declared variable rootNodeId rather than domain.RootContentId.Value so the value of 0 is always getting passed in.

Happy to raise a PR to resolve this

The `#` part of the fragment is incorrectly stripped when importing redirects

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

4.0.1

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.18

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10.8.0

Bug description

Can't remember whether I've fixed this in newer releases, but doesn't seem like it when reading the changelog 🤷‍♂️

Use checkbox component in selection of columns to export

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.8)

4.0.17

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.1

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.2.0

Question

In selection of columns to export, it would be nice to use <umb-checkbox> component instead the make the UI a bit more consistent with Umbraco core.

image

Refresh/reloads redirects after import

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

4.0.1

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.18

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.3.3

Bug description

I exported redirects locally from a migrated project on Umbraco 8 -> 10 -> 12 on Umbraco Cloud development environment.

In imported most redirects, but it seemed a bit odd I couldn't click Continue and nothing further happened.

image

however closing overlay and refreshing did show the imported redirects.

It can eventually trigger an event e.g. "Skybrud.Redirects.Import.Something" which the dashboard react on and reload/refresh the redirects table.

CsvRedirectsProvider: BOM () at beginning of CSV file

I've come across an issue with the CsvRedirectsProvider, when reading a locally-stored CSV file...

"MapCsvColumns()" was failing because it was reading the first column name with "" in front when using the "Encoding.Auto" option.

Some research turned up the following: https://stackoverflow.com/questions/6260911/how-remove-the-bom%C3%AF-characters-from-a-utf-8-encoded-csv

I un-commented the bit of encoding-checking code you had present:
image

And when debugging, I see that it correctly determined the encoding as UTF8 - but then throws a "Stream was not readable." exception using that encoding.

If I pass-in "CsvImportEncoding.Utf8" explicitly as the option, The stream reads without error, but now it reads the first column name as starting with "\ufeff" - another BOM character.

I think "CsvFile.Load()" called here:
image
might need to be checked.

This CSV file was saved from MS Excel, which I recall seems to ALWAYS have encoding issues for some reason... but considering how common it is to save CSVs from Excel, I think the code needs to handle this.

I was able to strip it out using some code i found in https://stackoverflow.com/questions/1317700/strip-byte-order-mark-from-string-in-c-sharp

URL Redirects

Hey I was trying out your imports package and created a test redirect which I exported to another environment in order to test out the functionality of the package.

I received this issue.

/test-page
Destination URL is not a valid URL: https://www.nyan.cat/
Object reference not set to an instance of an object.

This was the line in the csv file:

Id Key RootKey Url QueryString DestinationType DestinationId DestinationKey DestinationUrl DestinationQuery DestinationFragment Type ForwardQueryString CreateDate UpdateDate
1 cc80c591-d034-4307-866c-5bd20d3ee6f6 00000000-0000-0000-0000-000000000000 /test-page Url 0 00000000-0000-0000-0000-000000000000 https://www.nyan.cat/ Permanent False 2023-09-28T19:53:52.783-10:00 2023-09-28T20:12:37.637-10:00

Furthermore I am seeing that redirects to outside URLs should be handled in your file:

} else if (!destinationUrl.StartsWith("http://") && !destinationUrl.StartsWith("https://")) {

Here on line 519:

        } else if (!destinationUrl.StartsWith("http://") && !destinationUrl.StartsWith("https://")) {
            item.Errors.Add($"Destination URL is not a valid URL: {destinationUrl}");
            return;
        }

Any help would be appreciated to why this doesn't work.

Redirects_20230928201700.csv

V10 to v13 updates fails when Skybrud Redirects 13 installed

Which version of Skybrud Redirects are you using? (Please write the exact version, example: 4.0.8)

13.0.0

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.0.3

Bug description

When updating one of projects to v13, I hit issue where skybrud redirects import would try to read from nucache before update is finished ending up with death lock on nucache and broken db :)

In spare tim I will try prepare reproduction example and send it here.

Import format

Hi, I maybe missing something obvious but I can't seem to find any reference to the requirements for formatting data for import. i.e. Does it rely on certain columns / column headings being in place to upload correctly? I'm trying an XLSX file with no headings and two columns (column 1 is the old URL, column 2 is the new URL) but am getting errors. Many thanks!

XLSX files failing to import/export on azure web apps due to the default font.

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

4.0.1

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.17

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10.7.0

Bug description

When running an import or export with an excel file it's throwing an error when running in azure web apps.

image

I believe this is due to the default font Calibri that is trying to be used not being installed on the server, so I can imagine this extends to other servers as well.

https://docs.closedxml.io/en/latest/tips/missing-font.html#missing-font

There are some solutions outlined within the link above primarily being to search for installed fonts on the server to use as a fallback https://docs.closedxml.io/en/latest/tips/missing-font.html#use-already-installed-font or bundling in a font for ClosedXML by default instead.

I can imagine for imports having any fallback font selected isn't an issue as it's just grabbing the information but on export I don't imagine it's as straight forward if the user doesn't have the font on their device?

CSV Imports don't work in certain scenarios due to specific content type requirements

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

4.0.1

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.17

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10.7.0

Bug description

When uploading a csv file there is a conditional check for the content type which checks it is "text/csv" in the CsvImporter file.

However, I noticed that in most cases the validation was failing due to the content type differing from "text/csv".

Further digging further it seems common types that are used for CSVs are:

  • text/csv
  • application/vnd.ms-excel

But this could also extend to:

  • text/plain
  • application/vnd.ms-excel
  • text/x-csv
  • application/csv
  • application/x-csv
  • text/comma-separated-values
  • text/x-comma-separated-values
  • text/tab-separated-values

I'm happy to raise a PR that includes validation for the below content types as these seem to be the most common or I can extend to also include the other types but I haven't tested these:

  • text/csv
  • application/vnd.ms-excel

UI Integration with Redirects Dashboard

Hi @abjerner ,

You mentioned that you have updated the Redirects dashboard to change the "Add Redirect" button into a drop-down button, but I'm not seeing the new Importer code adding the Import option as you mentioned here:
image

This is what I currently see (v2.0.5):
image

So, any idea when this update will be released?
(And in the meantime, how can I view/test the Import UI you started adding?)

Allow URL rediects

Hey :)

When importing and not having absolute path you get the error, i can see you have an TODO here:

else if (destinationUrl.StartsWith("/")) {
                if (destination == null) {
                    if (TryGetContent(destinationUrl, out IPublishedContent? content)) {
                        destination = content;
                        destinationUrl = content.Url();
                        destinationType = RedirectDestinationType.Content;
                    } else {
                        // TODO: Should this trigger an error, or just create an 'URL' redirect?
                        item.Errors.Add($"No destination found with URL '{destinationUrl}.");
                        return;

Do you plan on ever adding the TODO, so that the redirect is just added as a normal URL redirect?

Double import/export labels

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

4.0.1

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.18

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.3.3

Bug description

I have migrated a project from Umbraco 8 > 10 > 12.

Now installed redirects package:

<PackageReference Include="Skybrud.Umbraco.Redirects" Version="4.0.18" />
<PackageReference Include="Skybrud.Umbraco.Redirects.Import" Version="4.0.1" />

But I am seeing double import/export labels here:

image

Redirects import fails for URLs with domains with segments

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

13.0.0

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

13.0.4

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.0.3

Bug description

The import fails for URLs with a hostname which contains a URL culture segment:

An example:

Considering the following input:
Url | DestinationUrl
en/this-is-a-redirect-en | en/about
nl/this-is-a-redirect-nl | nl/over-ons

When the root node is set with hostnames /en and /nl (with corresponding cultures).

The import fails.

Having looked a bit into the issue, it seems to fail to determine the destination node, which is probably related with the fact that the Umbraco method GetByRoute("nl/over-ons") returns null even when that page exists in the tree.

Close overlays using esc key

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.1)

4.0.0

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.16

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.2.0

Bug description

I noticed after installing following packages:

<PackageReference Include="Skybrud.Umbraco.Redirects" Version="4.0.16" />
<PackageReference Include="Skybrud.Umbraco.Redirects.Import" Version="4.0.0" />

that when import and export overlays are open, they can be closed via close link/button, butt not using esc key.
They probably just need the shortcut="esc" command.

Support for Umbraco 13

Which version of Skybrud.Umbraco.Redirects.Import are you using? (Please write the exact version, example: 4.0.8)

4.0.1

Which version of Skybrud.Umbraco.Redirects are you using? (Please write the exact version, example: 4.0.15)

4.0.18

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

12.3.5

Question

I noticed a v13 of Skybrud Redirects package has been published to NuGet: https://www.nuget.org/packages/Skybrud.Umbraco.Redirects ... I guess the bump of version to 13 is to align with Umbraco 13.

The Skybrud.Umbraco.Redirects.Import has not been released for Umbraco 13 and .NET8 yet, but I am sure if will happen soon.

I noticed the docs here mention v3.0.0-alpha005 for Umbraco 9, but there's a stable v3.0.0 release:
https://packages.skybrud.dk/skybrud.umbraco.redirects/

Furthermore it should probably also list Umbraco 10, 11, 12 and now 13 😉😎

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.