Hot-Honeys



.

Author Topic: POST NEW SOLUTIONS HERE, 1 POST/SOLUTION, TITLE = HOST LABEL  (Read 708 times)

0 Members and 1 Guest are viewing this topic.

Offline Greg

  • Retired Member
  • *
  • Joined: Apr 2016
  • Location: On the Ethernet
  • Posts: 69
  • Images: 1,159
  • Reputation: 11
  • Gender: Male
In order to make it easier to maintain and update IHG's offical hostf.xml file you are requested to post all new host solutions in this topic. It is hoped that this will result in more frequent updates of the official hostf.xml file, thus allowing non-technical users to automatically receive new host solutions without having to search the forum and add new solutions manually.

By having just one topic, the person maintaining the official hostf.xml file will not have to read every topic searching for new solutions, and no new solutions will go overlooked. IHG users who wish to receive all new solutions may subscribe to this topic and will receive notifications only when a new solution has been added.

Coders, when you have solved a new host solution request, by all means post the solution in the request topic so that the original requester will receive a subscribed topic notification that his request has been updated. Then please post just the solution in this topic to ensure that it will be added to the official hostf.xml file.

IMPORTANT RULE FOR THIS TOPIC: Only solutions are to be posted in this topic. This is not a discussion topic. Posts containing anything other than host solutions will be merged with an appropriate topic, moved to create a new topic, or deleted.




Example of desired solution format:

Host Label:   example

URL Pattern:
Code: [Select]
^http:\/\/example\.com\/[a-z\d]+$
Search Pattern:
Code: [Select]
function(pageData, pageUrl) {
var iUrl = pageData.match(/img src=("|')(.+)\1 class=("|')pic\3 alt=("|')(.+)\4 onLoad=["|']/);
return iUrl ? {imgUrl: iUrl[2], fileName: iUrl[5], status: "OK"} : {imgUrl: null, status: "ABORT"};
}




Final notes:

1. If it becomes necessary to modify a solution you have already posted in this topic, post the updated solution as a new post and then go back and edit the previous solution by adding a note that it has been updated later in the topic, possibly deleting the obsolete solution, and possibly adding a link to the new solution if you wish.

2. By all means if you feel that additional comments may add important information to your solution then go ahead and include them.

3. The example is not intended to be rigid requirements. They are simply guidelines illustrating one effective means of presenting the information. If you have your own preferred style then by all means use it as long as it includes all the necessary information.

4. IMPORTANT: Put all functions in BBCode CODE tags. The appropriate editor button to create a code and end-code tag appears in the middle row of the post editor just to the left of the quote button and is labeled # -- or you may simply type the tags manually as [CODE] and [/CODE] with your function or XML between them.

5. Please DO NOT post XML code. That was useful back when the hostf.xml file was manually edited, but with the new system XML code has to be disassembled before inputting into the MySQL database, which introduces another source of errors in translation.

6. And finally, just a reminder: this is NOT a discussion topic. If you want to discuss one of the solutions appearing in this topic, create a new topic and quote the solution you wish to discuss, then have your discussion there.



The old topic got too long so we are starting over. A few suggestions come to mind...

It would be very helpful if you can indicate if you are ADDING or UPDATING a host solution. If I add a solution where one already exists it will crash the host file. It would save me extra work if you can tell me if it's an add or an update.

As stated above please use CODE tags to surround your URL Pattern and Search Pattern. And PLEASE, DO NOT have a linefeed before the end CODE tag. That breaks the host file too and I sometimes forget to check for it.

A few more requests:

1. Please do not leave a dangling closing broken bracket: } ... This tag properly appears as the last character in a Seach Pattern.


And folks, it is highly obsolete to add the following line to your code:

Code: [Select]
var retVal = {};
or even worse:

Code: [Select]
var retVal = {imgUrl: null, status: "ABORT"};
I'd like to see our solutions take a more sophisticated approach where unnecessary variables, declarations and initializations are left out. Particularly leave out intermediate variables when they are not needed. Look to the other solutions for examples on how to do this.

Particularly this type of code is highly desirable:

Code: [Select]
return iUrl ? {imgUrl: iUrl[2], status: "OK"} : {imgUrl: null, status: "ABORT"}
You notice the retVal is just not used. Trust me, you don't need it.

If you do nothing else, PLEASE, make sure your ending CODE tag is on the same line as the last line of your code, and PLEASE make sure your function ending bracket } is hard left to the margin.

And thank you very much for those who provide solutions. Remember, this is a closed loop where some solutions may break previous solutions. This is an imperfect world. We are a feedback system where sometimes solutions break, and new solutions follow that correct previous bad solutions.

Just to make it clear, I do not test the solutions. When you have a discussion topic where there is common agreement that it's a good solution please add it to this thread. This is the only topic I guarantee to read, the only topic that will get your solution into the master host file. If you don't post it here then it ain't going in.

And please, offload my very dedicated supermod Artfulbodger by not making him post your solutions for you. When you have a good solution, post it. It's not his job to post your solutions for you, although he has taken on that extra duty because of his dedication to IHG. Please have a little consideration and post your own solutions instead if making him cut and paste them for you.

And thanks again for your solutions to keep IHG going.



I want to add some comments on what breaks the host file. It has to do with CDATA.

Please read this Wikipedia article: https://en.wikipedia.org/wiki/CDATA

Quote
Because of this, using a CDATA section programmatically to quote data that could potentially contain '&' or '<' characters can cause problems when the data happens to contain characters that cannot be represented in the encoding.

Got that? DO NOT USE the characgters & or < in your solutions. Find a work around. Every solution that has either of those characters between the CODE tags breaks the host file.

Find another way to use your regex. In some cases use character entities like &amp; or &lt; but that will not work inn all situations. Depends on what you are doing and where it appears.


Please note that the solutions from the previous topic for coppermine_gallery, xxooru and myimg.club broke the host file and were not added, probably because of the above.


And again I want to emphasize that this topic IS NOT a discussion topic. If you have anything to discuss about this topic, quote the post and start a new topic.



Please ensure that the ending CODE tag does not have a carriage return (newline) before it. It should be hard up against the last character.

All label names should be lower case.

Don't get more creative than necessary with host labels. If the site is example.net don't use example.net for a label, just use example. If it's a two stage solution (yucky, messy, clever coding can make those into one entry) don't call one example and the other example.lala_hoohah. Just use example and example2.

Please do not include the TLD in the label unless required. In other words don't end your label in .net or .com unless there is another identical name with a different TLD.

In code please use tabs, not spaces, to indent your code. If at all possible please do not have empty lines that have only a tab in them. Please delete the spurious tabs on blank lines.

Please make your code readable, do not use unnecessary intermediate values, don't write a 20 line solution when 10 lines will do the same thing.



To sum it up:

POST A NEW TOPIC FOR EACH NEW SOLUTION, USE THE HOST LABEL AS THE TOPIC NAME!

When I add the solution to the host file I move your post to SOLUTIONS ALREADY ADDED.

Thank you for your help! :)

Offline Greg

  • Retired Member
  • *
  • Joined: Apr 2016
  • Location: On the Ethernet
  • Posts: 69
  • Images: 1,159
  • Reputation: 11
  • Gender: Male
Re: POST NEW SOLUTIONS HERE, 1 POST/SOLUTION, TITLE = HOST LABEL
« Reply #1 on: May 02, 2016, 03:33 pm »
Updated Mon, 02 May 2016 15:27:00 GMT and database backed up.

Thanks gang! :)

Offline Greg

  • Retired Member
  • *
  • Joined: Apr 2016
  • Location: On the Ethernet
  • Posts: 69
  • Images: 1,159
  • Reputation: 11
  • Gender: Male
Re: POST NEW SOLUTIONS HERE, 1 POST/SOLUTION, TITLE = HOST LABEL
« Reply #2 on: May 02, 2016, 07:26 pm »
Updated again: Mon, 02 May 2016 19:00:00 GMT

There was a mistake in the database which I have now fixed.

Offline Greg

  • Retired Member
  • *
  • Joined: Apr 2016
  • Location: On the Ethernet
  • Posts: 69
  • Images: 1,159
  • Reputation: 11
  • Gender: Male
Re: POST NEW SOLUTIONS HERE, 1 POST/SOLUTION, TITLE = HOST LABEL
« Reply #3 on: May 06, 2016, 08:34 pm »
Updated: Fri, 06 May 2016 20:30:00 GMT

Offline Greg

  • Retired Member
  • *
  • Joined: Apr 2016
  • Location: On the Ethernet
  • Posts: 69
  • Images: 1,159
  • Reputation: 11
  • Gender: Male
Re: POST NEW SOLUTIONS HERE, 1 POST/SOLUTION, TITLE = HOST LABEL
« Reply #4 on: May 29, 2016, 01:13 am »
Updated: Sun, 29 May 2016 01:15:00 GMT

Offline Greg

  • Retired Member
  • *
  • Joined: Apr 2016
  • Location: On the Ethernet
  • Posts: 69
  • Images: 1,159
  • Reputation: 11
  • Gender: Male
Re: POST NEW SOLUTIONS HERE, 1 POST/SOLUTION, TITLE = HOST LABEL
« Reply #5 on: July 18, 2016, 04:11 pm »
Updated Mon, 18 Jul 2016 16:16:16 GMT