These are chat archives for locomotivecms/v3

5th
Apr 2017
Nikolay Bonev
@DonKoko
Apr 05 09:23
Hey @did
Didier Lafforgue
@did
Apr 05 09:24
hi @DonKoko!
Ahmed Helil
@aaeabdo
Apr 05 10:27

Hey Guys,

I was upgrading locomotive to 3.3.0.rc1 but I encountered 2 errors.
the first one was a validation error on content_type templates saving, That was because the db didn't contain the title for the unused locale. I managed to fix it going to the affected page through the backoffice and switching to this locale then saving them. In this way the concerned template title will be saved. then we won't have this validation error anymore.

The other issue was a validation problem while deploying ThemeAssets Resource invalid: source New file does not have the original extension. So here is my findings, Locomotive rely on carrierwave to get the ContentType for the assets this causes an issue. carrierwave relies on MIME Magic to get the content type. unfortunately, MiMe Magic does very bad job identifying the content type for the files. E.X. Any file starts with if gets identified as audio/x-mod. In our case our file starts with if. https://github.com/minad/mimemagic/blob/master/lib/mimemagic/tables.rb#L1767
this is clearly not the way that we should identify files content types upon. I believe that the solution can be done through carrierwave by prioritizing mime_types_content_type over mime_magic_content_type
https://github.com/carrierwaveuploader/carrierwave/blame/v0.11.2/lib/carrierwave/sanitized_file.rb#L250

what's your thoughts on this?

Ahmed Helil
@aaeabdo
Apr 05 10:47
I tried to downgrade Carrierwave to v0.11.0 and it fixes the issue, the latest Carrierwave version is 1.0.0I think the issue is already fixed there but we can't upgrade to it as locomotive use carrierwave-mongoidwhich locks Carrierwave to < v0.12.0
Nikolay Bonev
@DonKoko
Apr 05 10:52
@aaeabdo hmm thats what i was looking for
spend the last 2 days struggling with why my css files are suddenly getting the wrong mime-type
Ahmed Helil
@aaeabdo
Apr 05 10:57
yea, it took me time as well. it's a nasty bug in MIME MAGIC.
Nikolay Bonev
@DonKoko
Apr 05 10:59
Good job man! Lets see what Did says. Maybe he knows about it already.
Ahmed Helil
@aaeabdo
Apr 05 11:00
Thanks :) yea, I'd like to hear his input.
Didier Lafforgue
@did
Apr 05 11:29
hi @aaeabdo & @DonKoko, well, it was (supposed to be?) fixed in the rc2.
@aaeabdo you’re totally right it was caused by the new version of the mime-types gem.
the fix here: locomotivecms/engine@0866e9f
Ahmed Helil
@aaeabdo
Apr 05 11:38
@did this only fixes it for the CSS files only. I suppose the proper fix for this is in CarrierWave itself.
Didier Lafforgue
@did
Apr 05 11:38
interesting. why are you saying that?
if you’ve got an example regarding a JS file, that’d be great to add it in our spec suite
Ahmed Helil
@aaeabdo
Apr 05 11:39
well, our minified js file starts with if gets identified as audio/x-mod
Didier Lafforgue
@did
Apr 05 11:40
pfff
wtf mime-types? really?
:-(
Ahmed Helil
@aaeabdo
Apr 05 11:41
As I said I think they fixed it in the latest release. so what we can do for now is to downgrade CarrierWave.
Didier Lafforgue
@did
Apr 05 11:42
let me see the dependencies
Ahmed Helil
@aaeabdo
Apr 05 11:42
until CarrierWave-mongoid supports the latest CarrierWave
Didier Lafforgue
@did
Apr 05 11:48
hmmm, I’d prefer to monkey patch carrierwave inside Engine (and so rely on the last version of carrierwave)
Ahmed Helil
@aaeabdo
Apr 05 11:51
yes, monkey patch can be a solution as long as it's temporary.
Didier Lafforgue
@did
Apr 05 11:51
exactly
thanks @aaeabdo, @DonKoko and @manuchap for your patience
I’ll come up soon with a patch
Ahmed Helil
@aaeabdo
Apr 05 11:53
you're welcome, Happy to deal with those issues :)
Manu
@manuchap
Apr 05 17:29
@did Can we have a clue on the secretly launched new product? :shipit: (I filled the survey & discovered typform which is awesome)
Nikolay Bonev
@DonKoko
Apr 05 17:30
:)
soon you will know
I think I know what the product is as we talked about it together with Did like 5 months ago
if its the same thign
Manu
@manuchap
Apr 05 17:30
hashtag impatient
Nikolay Bonev
@DonKoko
Apr 05 17:30
haha
@manuchap do you have any idea how I can iterate over select_options in a content_type field
I need it for a form, but I dont know how to get the options
Manu
@manuchap
Apr 05 17:34
You mean this?:
<select class="form-control" name="content[thing]">
    <option></option>
    {% for thing in contents.things %}
    <option value="{{ thing._id }}">{{ thing.whathaveyou }}</option>
    {% endfor %}
</select>
Nikolay Bonev
@DonKoko
Apr 05 17:35
not rly
- event: # The lowercase, underscored name of the field
    label: Evenement # Human readable name of the field
    type: select
    required: false
    hint: Which event is this registration for? (This is temporary. In the future the functionality might slightly change).
    localized: false    # if localized, use
    select_options: ['Introductieavond 24 mei', 'Introductieavond 13 juni']
Look at this field within a content type
i need to iterate over the select_options
      %select
        {% for option in contents.event_registrations.event_options %}
        %option{ value: "{{ option }}" } {{ option }}
        {% endfor %}
This is what I mean
just figured it out
Manu
@manuchap
Apr 05 17:39
Sry wrong example
Nikolay Bonev
@DonKoko
Apr 05 17:39
no probs
I just found it in the documentation
Manu
@manuchap
Apr 05 17:42
yep like:
%select.form-control{:name => "content[select]", :value => "{{ model.select }}"}
  %option{:value => ""}
  {% for select in contents.models.select_options %}
  %option{:value => "{{ select._id }}"} {{ select }}
  {% endfor %}
Manu
@manuchap
Apr 05 17:48
I've had problems with those sometimes when posting a public_submission_enabled model. I'm using js to fetch the selected value and insert it into a hidden input. I plan to create an action for that.
Nikolay Bonev
@DonKoko
Apr 05 17:50
i remember I also struggled with it once but that was a long time ago
will test it now and let you know
Manu
@manuchap
Apr 05 17:55
I see you fixed the css issue? I can't get off my head It might be related to the /preview in the url... (same with 404 on images)
Nikolay Bonev
@DonKoko
Apr 05 17:57
didn't really fix it
rolled back my engine to 3.2
Today @aaeabdo found what the real issue is and they discussed it with did.
Also the other problem I had I now know is a real problem, not just something that i did
apparently there is a problem with json serailization
for models with relationships
Manu
@manuchap
Apr 05 18:03
Yep, saw that.
Manu
@manuchap
Apr 05 18:32
@did I just made a suggestion in the docs in order to clone the one click install locally and have images editing work.
Nikolay Bonev
@DonKoko
Apr 05 18:44
@manuchap do you have an idea on how I can capture the errors when using an ajax model_form?
Didier Lafforgue
@did
Apr 05 18:48
quick update. @DonKoko I’m fixing both the serialization issue and the mime type stuff
@manuchap thanks for answering the form :-) soon you’ll know ;-)
Nikolay Bonev
@DonKoko
Apr 05 18:50
@did sounds great. Glad we found those issues
Manu
@manuchap
Apr 05 19:58
@DonKoko You might wanna try lighttable. I just re-downloaded it and haven't use it in a while but it may do the job.