Push content from remote server into a CSS file asset


(Evan Wills) #1

We are thinking about using a CSS preprocessor (SASS) and a version control system (GIT) to manage our CSS development.

 

Mostly this is to allow us to create tight production css files while keeping verbose documentation for developers.

 

Is it possible to push content like a CSS file into a matrix CSS file asset without human intervention?

 

I've pulled stuff in to matrix using remote content. And I've pulled stuff out of matrix using external systems. But never pushed stuff into matrix.

I've looked briefly at the documentation for SOAP and REST. But I've never done anything like this and the documentation didn't make a huge amount of sense to me.

 

Which would I use?

 

Is there any step by step documentation on how to do this?

 

PS: Matrix doesn't do version control for anything but content (as far as I know) (and arguably shouldn't). Being able to user version control and push from the repository into matrix keeps matrix focused on it's core functionality - being a CMS/CMF - while enabling valuable developer documentation and roleback functionality. CSS files, JS files and martrix parse files are where this would be most useful but extending it to include asset listings and paint layouts would also be cool.


(Nic Hubbard) #2

Yeah, the SOAP features can this this for you, and actually does have quite a bit of documentation. Take a look at the SOAP Upload function: 

 

http://manuals.matrix.squizsuite.net/web-services/chapters/soap-api-file-retrieval-service#upload


(Evan Wills) #3

Hi Nic

 

Thanks very much for that. I'll look into it.


(Evan Jardine) #4

Hi Evan

 

Did you have any success with this?  I've been trying to get my head around exactly the same thing and haven't managed to get very far yet.

 

 


(Nic Hubbard) #5

Hi Evan

 

Did you have any success with this?  I've been trying to get my head around exactly the same thing and haven't managed to get very far yet.

 

 

 

What have you tried to do so far? Did you make sure to encode the data to upload into base64?

 

Basically you just POST something like the following to your SOAP Server:

<SOAP-ENV:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://SYSTEM_ROOT_URL/_web_services/soap-server">
  <SOAP-ENV:Body>
   <ns1:Upload>
      <AssetID>150</AssetID>
      <FileName>file.txt</FileName>
      <FileContentBase64>VGhpcyBpcyBhIHRlc3QgZmlsZQ==</FileContentBase64>
    </ns1:Upload>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

(Evan Wills) #6

 

What have you tried to do so far? Did you make sure to encode the data to upload into base64?

Hi Nic

 

I haven't had a chance to get back to it. But I'll post here as soon as I've got anything to report.


(Ryan Archer) #7

Bump.

I'm about to embark down this road. How did you go Evan or still at it?


(Evan Wills) #8

Hi CoolWebs

 

Nope. I had a brief try ages ago but didn't get very far. I haven't had a chance to get back to it and try, but I'm still keen on it. We're now using SASS and Git to manage our CSS and JS, so I'm really keen to start.

 

If you get anywhere, let me know.


(Nic Hubbard) #9

What issues were you guys having? I have implemented this (not in the same way), and it wasn't too hard to get working. 


(Evan Wills) #10

I can't remember now. I think I just didn't get to the push part from the other server.


(Ryan Archer) #11

Hi Nic,

I don't think I am having any issues yet. I am seeking to do the same as Evan and I'm trying to find out how to get GitHub to make the request via SOAP/REST (actually I read somewhere on GitHub that it supports POST and REST - I think you said POST will suffice @Nic).

 

Yeah so we want to setup some CSS and JS files on GitHub for projects and when we update them, they get pushed into SQUIZ via POST method over HTTP. Just trying to get information on how to make GitHub to POST those requests in the XML format that you earlier specified Nic. 

 

Have you you done this testing with GitHub @Nic?


(Nic Hubbard) #12

Have you you done this testing with GitHub @Nic?

 

No, I have not. I was implementing it into an iOS app.


(Ryan Archer) #13

Ok, I will see if I can get some support from GitHub on this one. It would make great sense if the process was automated every time a particular file was updated.


(Nic Hubbard) #14

I think you are looking for Webhooks: https://developer.github.com/webhooks/


(Ryan Archer) #15

I am currently attempting to set it up with a default "PUSH" webhook within GitHub. It would appear that the content types to choose from are application/JSON or application/x-www-form-urlencoded. I can't see a specific output format that matches the UPLOAD SOAP API File Retrieval Service (XML) that is specified in the Squiz manual (What the SOAP server needs to receive). It all still appears to be in some 'JSON-like' format.

 

I just pinged the payload URL being  http://www.qanzac100.slq.qld.gov.au/__data/assets/css_file/0003/282297/slq-bootstrap-overrides.css with the newly created webhook and its definitely returned what looks like a JSON file (by the way, the ping was successful).

 

Would there be a way to have GitHub format it to what is required by the SOAP server? I have also contacted GitHub support asking the same question.


(Nic Hubbard) #16

Are you trying to update a CSS File? Or a CSS Design File?


(Joel Porgand) #17

Would there be a way to have GitHub format it to what is required by the SOAP server? I have also contacted GitHub support asking the same question.

 

Looks like github just sends JSON. You could probably build something to consume it with the REST javascript asset, but I don't think it'd be a trivial effort. 


(Ryan Archer) #18

@Nic, I am trying to update a CSS File, not a CSS Design File.

Thanks for the consensus @JP - I suspected as much.


(Ryan Archer) #19

I received this email back from Ivan @GitHub regarding the HTTP POST request:  
Hi there,
 
I think there might have been a misunderstanding about what GitHub webhooks do.
 
GitHub webhooks have a predefined payload structure and are always in JSON. You can point the webhook to make an HTTP POST request to any server, but you can't change the payload type or structure. If the type or structure are not what you expect, you should build a small proxy which will receive the webhook delivery, transform it, and then forward the transformed request to the target destination.
 
In other words, it's not possible to configure GitHub webhooks to send the payloads you described -- you need to create them yourself with a small proxy you would need to build.
 
I hope this clarifies things but let me know if you have any questions or if I misunderstood anything.
 
Cheers,
Ivan

 

I hope that this clears up everything for other peeps who are interested in trying to get this feature happening.


#20

Hey guys thanks for this thread - we are heading this way as well!