Giter VIP home page Giter VIP logo

Comments (7)

Kagetsuki avatar Kagetsuki commented on June 19, 2024 1

I hate to bump but we're looking to finish a site in the next 10 days and without this working it's going to be a bit of a mess. If there's some alternate solution I'd love to hear about it - otherwise do you think we can expect a patch at some point?

from movabletype.

yuji avatar yuji commented on June 19, 2024 1

@Kagetsuki
大変ご迷惑をお掛けしております。できる限り、早急の対応を検討します。

from movabletype.

yuji avatar yuji commented on June 19, 2024

@Kagetsuki

Hello,

Do you mean API as Data API? If yes, please tell me Movable Type Version.

from movabletype.

Kagetsuki avatar Kagetsuki commented on June 19, 2024

Yup, the Data API. I'm testing on 6.3.6. I have a feeling the internal code works something like this:

  1. if folder is set, manage file under folder (automatically generate name from title, if no title or title contains no ASCII characters set title to "post-##") ⇒ set file path and name based on folder and title (basename is not used? and automatically generated)
  2. if basename is set, check to make sure the base name does not conflict with folder path (path portion of base name matches folder path) ⇒ if base name conflicts with folder path ignore base name / set it to null
  3. permalink is generated as folder path + base name

The logic here probably made sense, because if you had folder path a/b and base name c/d/e.html, folder sorting wouldn't work correctly. The issue is there's no other attribute but base name to set the file name, and in the case of using the API you'd need to set a base name as "index" to get the apex of a folder or you'd need to set manually to some name to fit with links in other pages you're posting.

Ideally if MT would extract folders automatically from the base name, and create folders if they didn't already exist, it would not only solve this issue but would also eliminate the need to pass folder arguments (which require folder ID, meaning you need to get folders from API first and then extrapolate the ID before you can even post a page!).

Thanks for looking into this - please tell me if you need any more info.

from movabletype.

dphillips avatar dphillips commented on June 19, 2024

I don't work with the Data API, but I did look at the Data API code and see if anything jumped out at me. I think I discovered a bug in the basename uniqueness checking when a new page is created through the Data API.

In theory, you should be able to create multiple pages with the same basename (file name) in the same site/blog as long as each page is in a different folder. In practice, the Data API checks the entire site/blog for unique basenames without looking at any folder assignment.

From lib/MT/DataAPI/Endpoint/v2/Page.pm, lines 89-94 (MT 6.3.6):

if (  !$new_page->basename
    || $app->model('page')
    ->exist( { blog_id => $site->id, basename => $new_page->basename } ) )
{
    $new_page->basename( MT::Util::make_unique_basename($new_page) );
}

Once a page has been created with a basename of 'index' for example, the above code does not allow for any other pages to have the same 'index' basename, even if the page is in a different folder. In this case, the Data API generates a unique basename ("post-##") instead of allowing "index".

When creating new pages in Movable Type, the MT code loads all pages with the same basename as the new page being created, constructs the permalinks to each page, and compares the existing page permalinks to the new page permalink to determine whether a duplicate basename has been used. A similar logic should be implemented in the Data API for uniqueness checking of basenames of new pages.

I don't see any workarounds for this issue in the Data API. The Data API code will need to be updated to address this issue.

@Kagetsuki - Does this seem to explain the behavior you are encountering with the Data API?

from movabletype.

Kagetsuki avatar Kagetsuki commented on June 19, 2024

Once a page has been created with a basename of 'index' for example, the above code does not allow for any other pages to have the same 'index' basename, even if the page is in a different folder. In this case, the Data API generates a unique basename ("post-##") instead of allowing "index"

I'd have to double check but that sounds dead on! Specifically line 4 of the table I made in the first post would seem to confirm this:

folder basename resulting folder resulting permalink expected result
a/b a/b/index a/b a/b/a/b/index.html a/b/index.html

But, as I noted, permalink generation is folder + basename, so the "resulting permalink" above has the path twice, and sending the permalink as a parameter to the API just gets ignored.

Definitely hoping for a quick fix on the API. The site we're doing is a monster and importing all the pages through the admin panel by hand would probably take months... with the API we have it down to about 10 minutes!

from movabletype.

Kagetsuki avatar Kagetsuki commented on June 19, 2024

何度も投稿して大変申し訳ありませんが、ライセンス費を払っているお客様に綺麗に整理されているサイトの納品がしたいのです。 @dphillips 様が述べているようにそこまで複雑な問題ではなさそうなので、早めに対応して貰えれば大変ありがたいです。
よろしくお願い致します。

from movabletype.

Related Issues (20)

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.