Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Nov 25 10:56
    dahogenelst opened #407
  • Nov 25 10:54
    dahogenelst opened #207
  • Oct 12 17:54
    dependabot[bot] labeled #206
  • Oct 12 17:54
    dependabot[bot] opened #206
  • Oct 12 17:54

    dependabot[bot] on bundler

    Bump puma from 5.3.2 to 5.5.1 … (compare)

  • Oct 01 23:03
    greyskin opened #205
  • Sep 28 21:00
    amattson-kv opened #1392
  • Sep 27 20:24
    dependabot[bot] labeled #204
  • Sep 27 20:24
    dependabot[bot] opened #204
  • Sep 27 20:24

    dependabot[bot] on bundler

    Update nokogiri requirement fro… (compare)

  • Sep 24 09:10

    did on v4.1.0.rc1

    (compare)

  • Sep 24 09:07

    did on master

    bump version to 4.1.0.rc1 (compare)

  • Sep 24 08:58

    did on master

    [Feature] content entries impor… (compare)

  • Sep 24 08:58
    did closed #1391
  • Sep 24 08:50
    did synchronize #1391
  • Sep 24 08:50

    did on feature-content-entries-import

    very simple implementation transform all the types of attr… better import + track created/u… and 10 more (compare)

  • Sep 24 08:28
    did opened #1391
  • Sep 24 07:45
    did closed #1382
  • Sep 24 07:45

    did on master

    Add email validity check (#1382… (compare)

  • Sep 24 07:44

    did on master

    Allow picture upload with .tiff… (compare)

Luke Grayson
@greyskin
And the sample code I've been given for the body for this API request is:
"body": {
    "mode": "raw",
    "raw": "{\r\n  \"type\": \"purchase\"\r\n}",
    "options": {
        "raw": {
            "language": "json"
        }
    }
}
Peter Salomon
@patternpoints
You could try to send your request to https://postb.in and check / compare it
And - since you mentioned above the quotes in this: and that:, I guess you tried to fire your request with username and password in quotes?!
Peter Salomon
@patternpoints
Ah, forget my last question… not required for username / password
Luke Grayson
@greyskin

You could try to send your request to https://postb.in and check / compare it

Awesome thanks! I went searching for something like this and didn't find anything. Perfect! :)

Luke Grayson
@greyskin

So... I'm a little confused here.

  • I set up a Locomotive page with the response_type header as application/json (not even sure if that's relevant but in case it is)
  • I used callAPI to send a POST request to postb.in
  • I set no headers in the request
  • the content-type received is application/x-www-form-urlencoded NOT application/json
  • If I set a Content-Type header of application/json in my request, the request fails (in postb.in I get a 500 internal server error, and the actual service I'm trying to connect with returns an "Invalid JSON" response.

What I gather from this - and someone please tell me if I'm wrong - is that Locomotive sends callAPI requests in application/x-www-form-urlencoded format irrespective of the any Content-Type header set in the request headers...

Am I making sense here? Can anyone confirm?

Luke Grayson
@greyskin

Update: Yup, callAPI sends data in application/x-www-form-urlencode format regardless of the Content-Type header you set. :expressionless:

No content type header, data is sent in application/x-www-form-urlencode format.

Set "Content-Type": "application/json", data still sent in application/x-www-form-urlencode.

https://webhook.site/ - even better than postb.in @patternpoints - because it let's you view the data even when the request is invalid!

Manu
@manuchap
That's weird. Maybe remove the response_type header which was a bad advice. It works for me on webhook.
Manu
@manuchap
---
title: Api
listed: true
published: true
---
{% action 'api' %}
var sessionRequest = callAPI("POST", "https://webhook.site/45d4ae25-efd0-49ae-b468-a813a2a6005c", {
    headers: {
        'Content-Type': 'application/json',
        'Authorization': 'Basic ABC123'
    },
    username: 'my_user_name',
    password: 'my_api_key',
    data: {
        'type': 'purchase'
    }
});
setProp('sessionRequest', sessionRequest);
{% endaction %}
Capture d’écran 2021-09-22 à 14.21.54.jpg
Capture d’écran 2021-09-22 à 14.22.03.jpg
Luke Grayson
@greyskin
Nope, that isn't working. You've received type=purchase as content which is not application/json - it's application/x-www-form-urlencoded. https://stackoverflow.com/questions/9870523/what-are-the-differences-between-application-json-and-application-x-www-form-url
Manu
@manuchap
Ok... Gotta go. Maybe try with ajax using this gist
Luke Grayson
@greyskin
If it's application/json it will show up as
{
    "type": "purchase"
}
JSON.stringify() will hack it to work.
Luke Grayson
@greyskin
Anyone know how to delete a content entry via the API?
Luke Grayson
@greyskin
I tried deleteEntry('content_type_slug', content_entry_id); and destroyEntry() with same format, but no dice.
Luke Grayson
@greyskin
Tried removeEntry() also. I see it's possible in Coal. Does that mean there is a way with callAPI?
Luke Grayson
@greyskin
UPDATE: For any looking for a solution for how to delete a specific content_entry (my example using station.locomotive.works)
callAPI('DELETE', 'https://station.locomotive.works/locomotive/api/v3/content_types/content_type_slug/entries/content_entry_slug.json`, {
    headers: {
        'X-Locomotive-Account-Email': 'admin_email',
        'X-Locomotive-Site-Handle': 'site_handle',
        'X-Locomotive-Account-Token': 'account_token'
    }
});
Manu
@manuchap
👍
Peter Salomon
@patternpoints

I am currently working on optimizing my project. Until now, i was just throwing all my js into public/javascripts and my css into public/stylesheets linked each individually.

Now i am converting my project to webpack and post - generated the webpack js files for my sections ( of which i have tons )

Now my question is this: if i use some third party js, e.g. revolution slider to be used in some sections, how do you guys load these js libs without being redundant?

Luke Grayson
@greyskin

Ok here's one for you: {{ page.slug }}, when used on a page generated by a content_type_template page (i.e. on a content_entry page), returns the content_entry slug with any "s" removed from the end.

Example:

  • content_type slug: treats
  • content_entry slug: lollipops
  • At page /treats/lollipops {{ page.slug }} will be rendered "lollipop"

Is this expected behaviour?

(If the content_entry slug doesn't end in an "s" it remains unchanged.)

Luke Grayson
@greyskin

And something completely unrelated to the above:

I'm trying to get my head around custom routes and whether I can use them to achieve the following:

Curently I have:

  • shop page
  • shop/catalogues (contains catalogues content_type_template)
  • shop/catalogues/products (contains products content_type_template)

But I want urls to be like so:

  • shop/some-catalogue/some-product

Is this possible with custom routes? I don't really understand the documentation.

Manu
@manuchap
@greyskin For the first one I think it's expected since content_types need to be plural and content_type_templates refer to one instance of the content_type.
Luke Grayson
@greyskin
Mmm, I think maybe I haven't been clear. I'm not talking about the slug of the type, but about the slug of the entries.Let's say you set up a team members content type. And you set up a template for individual member pages. And one of your team members names is Charles. You go to his page. {{ page.slug }} will render "charle".
Manu
@manuchap
Oh... dig it. It might deserve a GH bug issue. What if you added an action/js that when you record a name that ends with an s it would add another one?
Not very elegant I reckon...
Luke Grayson
@greyskin
Yeah I considered a number of workarounds, but all of them similarly involved adding and/or removing letters or parts of strings. Ultimately thought I'd just be building on top of a broken foundation. Not good. Will find some other way to do what I need to do that doens't involve {{ page.slug }}.
GH issue created: locomotivecms/steam#205
Luke Grayson
@greyskin

Anyone know if there is any way to get a list of all the content_types? (Without resorting to the REST API?) I would have thought something like {% for content in contents %} would work but I get no output.

If I run {{ contents }} I get:

Locomotive::Steam::Liquid::Drops::ContentTypes

so there is something there - just not sure how to access it.

I've also tried:

{% action "get content_types" %}
    getProp('contents');
{% endaction %}

with a view to manipulation through JS but just that little bit of code results in a wagon error:

Action error - stack level too deep

Peter Salomon
@patternpoints
Wow, interesting question. I checked the code. Short answer: you can’t. There is just that one finder method for content types.
Luke Grayson
@greyskin
Gutted. Thanks for your feedback Peter - saves me time fumbling around in the dark. :smile:
Peter Salomon
@patternpoints
If I remember well dealing with shopify, usually the collection drops had a method “all” for fetching all records. It would be easy to implement {% for content_type in contents.all %}.
On the other hand I guess your content_types are pretty limited by amount.
Luke Grayson
@greyskin
Hmm, I might try that. There are several use cases where being able to access a list of content_types would be useful to me. With the shop site I've set up for a client, for instance, at the moment I'm using the REST API to get the content_types and look for any whose slug starts with attribute_ (these are the product attributes). It would also be useful for building a menu that handles content_type template pages.
Peter Salomon
@patternpoints
I am searching for some information how to setup locomotivecms to play nicely with cloudfront. Is there any info available how to configure dragonfly to upload resized images to s3, so that also resized images can be delivered and cached via cloudfront?
Luke Grayson
@greyskin
Hi @patternpoints I can't help with any of that sorry.
Is it possible to set a created_at datetime via wagon and a data .yml file?
Manu
@manuchap

Is it possible to set a created_at datetime via wagon and a data .yml file?

I so wish!!! Actually I'd be willing to pay a programmer for that feature along with the ability to filter content types during sync.

Wagon sets the date you launch it at as the created_at date for everything. It'd be great to have it in the header.
Luke Grayson
@greyskin
Yeah I figured out it wasn't possible. Ended up having to create a "create date" field, which is a bit superfluous. I get that created_at is a property that shouldn't be tampered with, but unfortunately the current setup doesn't account for those situations where you have to trash the database and start again and you want to re-deploy historical records and retain their created_at data.
How does one upload a .txt file? I need to do this to transfer a Google Analytics account which the client has lost access to.
Manu
@manuchap
Tep. Bummer. The only way I know of is to dump the db and import it somewhere else but you need access to both dbs 😭.
For the txt file you can do it from the back-office (media tab) and copy the download link
Luke Grayson
@greyskin

For the txt file you can do it from the back-office (media tab) and copy the download link

Legend thank you! :smile:

Luke Grayson
@greyskin

Separate to Daniel's question above,

filter_fields is declared in your model header in order to have a search bar doc

@manuchap - do you know if there is a way to get a boolean field to work via the filter_fields? I have a client with 500+ entries and they want to be able to hide or show enabled entries. I've tried passing enabled to the filter_fields array and then typing "enabled", "enabled:true", "enabled=true", etc in the search field, but no joy.

Luke Grayson
@greyskin

If I remember well dealing with shopify, usually the collection drops had a method “all” for fetching all records. It would be easy to implement {% for content_type in contents.all %}.

@patternpoints, finally got around to trying your suggestion. FYI {% for content_type in contents.all %} doesn't work. I guess there is no all. :cry:

Manu
@manuchap
Thx @greyskin for the custom routes doc additions. Much appreciated 👍
Luke Grayson
@greyskin
No worries @manuchap - happy to help if/when I can. :smile:
Luke Grayson
@greyskin

You know what would be awesome? If only_if in sections could also apply to the selected option of a dropdown list.

In my case, I've created a Page Intro Section with a banner_enabled checkbox. Thereafter I have a number of settings that use only_if: banner_enabled.

This works great, BUT, one of the settings is banner_type, a select type field with options color or image. It would be really nice if I could then use only_if: banner_type_color or only_if: background_type_image to only display settings that are relevant to the banner type selected.

Is there a feature suggestion set up somewhere?