Parsing Jekyll's Categories - ruby

I have created a simple blog based on the Jekyll engine but I need one more function to make the thing really complete.
In Jekyll, parent directories of posts are implicitly 'labels' or 'categories'. So, if I were to create a post under the directory structure
/computers/scm/git
it would end up having 3 labels (computers, scm, git)
In my blog, I have created a few pages:
/computers/index.html
/computers/scm/index.html
/computers/scm/git/index.html
and these pages explicitly list posts in their respective categories such that /computers/index.html displays links to every post in /computers, /computers/sc and /computers/scm/git ... and likewise on down the road. Unfortunately, categories are not compound in Jekyll and so, "/computers/scm/index.html" iterates over the same set of posts as "/sandwiches/scm/index.html" …
Now, I'd like to automatically generate a sitemap listing all the categories, providing links to all of the pages I've created. Jekyll includes a construct "site.categories" that I can iterate over which works just great for all the top level categories. The problem is that when "scm" comes up, there is no "/scm/index.html" - it needs to be "/computers/scm/index.html".
I'm not sure I can fix this behavior - what type of extensions can I write to get both hierarchical categories and automatically generate a site map to my listing pages?
In my wildest dreams, I'd like to be able to tag a post as /a/b/c and have it associated with labels /a, /a/b and /a/b/c and then be able to generate pages that iterate over exactly these sets of posts. I need the site's organization to drill down from general to specific.
Do I need to try a different static generation engine?

You need to use Jekyll's plugins. For categories support in my blog I use one of this.
If you are Github Pages user, you must note that GP does not support plugins because of security reasons. To avoid this, you may use ideas from this blog post.
As an alternative, you can use Octopress, which is Jekyll-based.

Related

Kademi - how to set canonicals on a product page

I am trying to set a canonical on a product detail page to prevent duplicate pages of the same URL.
Our client's website has 1375 however search engines are picking up 2890 because the overwhelming majority of pages are being rendered as duplicate such as the below several examples.
Same product example 1:
https://www.waterware.co.nz/store/1-function-hand-shower
https://www.waterware.co.nz/store/FW556
Same product example 2:
https://www.waterware.co.nz/store/1-function-hand-shower-black
https://www.waterware.co.nz/store/FW550BL
Same product example 3:
https://www.waterware.co.nz/store/1-2m-shower-hose-metal-wound
https://www.waterware.co.nz/store/FH112SS
And repeat 1375x.
I have since discovered where the 2nd version of the URL is coming from - its the favourites icon on product detail page - and will begin removing / adjusting these.
However in order to maintain best SEO practices I need to find a way to set a canonical.
I am aware that this could be done MasterTemplate.html. However there does not seem to be a way to discover the correct scope when in the master template file.
Any suggestions?
Thanks
SEO integration was commented out in KCommerce2, but it will be re-enabled in the next release later this week
This uses the webname property in the canonical href.
It also inserts the meta description field using the brief if its available, otherwise the product body.
And it also generates a meta keywords tag, using the product code, categories and brand.
To use this once available, you will just need to update to KCommerce 3.1.3 or later.

How do I get a count of the Shopify products in a collection using the Ruby API

I want to get the count of products in each collection in the shop as part of a Shopify App that I'm building.
I know that for a single collection Product.all(params: {collection_id: 29238895}).count will show me the count in the shopify console, but I'm not certain about how it is implemented.
The API document describes a call that counts all products that belong to a certain collection GET /admin/products/count.json?collection_id=841564295 but I have been unable to get a ruby expression that runs this.
Is there a more complete document on the Ruby API?
If you want to know exactly what is going on with the API, may I suggest the simple command: bundle open shopify_api
That will load the entire API into your text editor, allowing to quickly determine the answer to your question. The /lib/resources directory is especially rich, but do not forget to check the base class as well. In fact, I think the count option is declared right in the base itself. Nothing beats a few minutes of examining the code.

How can I get a list of all CSGO items including skin name, quality and rarity?

I'm not looking for details of a specific player inventory, but a list of all items for CSGO. What I want is details of the weapons in particular, but including skin name information and rarity.
To make it easier to explain this site has the information I need, except rarity.
http://csgo.steamanalyst.com/list.php
By using the following api url I can get weapon model names but not skin names (ie. "Zirka")
http://api.steampowered.com/IEconItems_730/GetSchema/v0002/?key={YOUR_API_KEY}
I haven't found anything regarding skins in Steam Web Api.
Lists of all skins as well as rarity and corresponding weapons are in "paint_kits", "paint_kits_rarity" and "item_sets" sections of /csgo/scripts/items/items_game.txt file.
As for their correct names, those are in /csgo/resource/csgo_YOUR_LANGUAGE.txt. Looking like that
"PaintKit_so_red_Tag" "Candy Apple"
Won't be hard to make php or python script to get all of it and put it in a database for ease of use.
For skins images you could get weapon and skin name from the above, and do a foreach curl loop to get content from div with "market_listing_largeimage" class using for example simple_html_dom.php, from url http://steamcommunity.com/market/listings/730/{ITEM_NAME}%20%7C%20{SKIN_NAME}%20%28{USAGE_THINGY Ex. Well-Worn}%29
Just remember to replace all spaces going to the url with %20 but that depends on what you use to get the page. You could do a foreach on the usage thingy since some weapons don't have some variants on the market, curl could return wrong page. Nothing that a simple if+foreach couldn't fix.
Also do it only after skins update if overused you could get blocked from valve website for spamming. You could also use SteamWebApi and game news to check for new versions and update it automatically then. Just use your imagination and google.

Sitecore global url to specific url

Currently I am facing the following problem:
A website, which I have to make for a company, has different locations. But the content of a few pages is for all locations the same. Now I have created a global folder with the items for all the locations. But now I am facing the following problem: when accessing the global items from the website of a specific location I get the global url. But what I want is that the specific location url remains the same structure, for example:
Now it is www.url.com/global/subfolder/itemname
And what I want is www.url.com/location1/subfolder/itemname
Does anybody have any solution(s)/suggestion(s) for this problem?
Does anybody also have a solution for creating a menu to insert these global items but also to insert the location specific items?
Some more information about my Sitecore content structure
Global: contains the global items for alle locations
Corporate: the corporate website of the company
Location1: the website of location1
Location2: the website of location2
Adam Weber was right, cloning is your best solution:
Create your Global section, with all the child items you need
For each of your local sections, clone the global section and place it where you'd like it to appear within your local menu
If I understand you correctly, this is what I'd do. It might not be the prettiest solution. But it'll work.
You have your "data" items in /global/subfolder/itemname
then just create some templates, which are "dummy" pages, that only contain a link to the global item (and perhaps the few fields that could differ (perhaps contact email for the specifik location).
Then you make a sublayout that bascially jsut gets the referenced item and uses that instead of Sitecore.Context.Item.
Then create an instance of the "dummy" template in /location1/subfolder/itemname and reference it to /global/subfolder/itemname
That way you URLs will be correct and the data will be the same.
Another and probably smarter solution (if you have enabled proxies) is to create a proxy that takes
/global/subfolder/itemname as source and points to /location1/subfolder/ as target (or you could take /global/subfolder and check "include children".
Here is a Guide on how to use proxies in 5.3:
http://sdn.sitecore.net/Articles/Administration/Using%20Proxy%20Items%20in%205,-d-,3.aspx

Partial caching dependencies in Kentico

How do I use the partial dependency caching in Kentico CMS?
Here's a very common example need I have but can't figure how to set up partial caching with dependencies correctly (in Portal mode, though I think this should apply to the other development modes too):
/Home (with a Repeater)
/News
Item 1 (so path = /News/Item-1)
Item 2 (so path = /News/Item-2)
The Home page has a Repeater web part that lists the most recent news items. It has a Path of "/%" and Document Types filter set to "CMS.News"; obviously also a "Partial cache minutes" value > 0. There is no custom code; just Portal web parts and standard document types.
What is the exact "Partial cache dependencies" string I should use so that when a third news item it is immediately reflected on the Home page, but otherwise uses the cache?
Kentico did release several blog posts including Deep dive: Cache dependencies, but I'm having difficulty applying the theory discussed there to a site. I even asked in comments there some questions, but the answers by the Kentico support there weren't really helpful.
From what I could tell in that post, they said to use node|%CurrentSite.SiteName%}|/News|childnodes which seems to have some magic keywords like node and some macro elements like {%CurrentSite.SiteName%}. (I know that all items need to be lowercase, so already I know their advice isn't real consistent. It should at least be node|%CurrentSite.SiteName%}|/news|childnodes instead. And do I need to force lowercase on the macros?) First of all, that string didn't work for me--it was still caching the Home page Top News repeater (yes, full page caching was turned off); second, how do I build a string like that and debug what it should be? The linked post does have a grid of examples, but it is confusing (to me) and not exhaustive.
Can anyone provide a good example or better blog post reference anywhere that explains this in another way?
EDIT: I realized I asked this question fairly broadly. How about if we narrow it to just answer the question: How do I determine what settings to use to cache a repeater with a dependency to changes in another folder?
The magic words you mentioned in your post are basically the keywords for particular objects. You can see them listed in the caching options description - the "node", "nodes", "nodeid" are listed there as most common for working with nodes. But below then is described the syntax for any object, where you will use that object class name.
Regarding the blog post from the Kentico's CTO and his answers in the comments, it looks like he overlooked or misunderstood your question. you are talking about partial caching and he was giving you examples on the "normal" caching settings. Macros in the touch keys are resolved (lower case or upper case does not matter) in all other caching settings but not in the partial caching. This feature will be available in the upcoming version 6.0.
So, right now you have to hard-code the site name in the touch key cache setting.
I turned on the cache debugging and looked at what cache names were being generated. I saw mine being set to...
node|{%CurrentSite.SiteName%}|/test-section/|childnodes
...which was obviously incorrect and would never work!
It looks like macros do not get resolved within the Partial Cache Dependencies property. So you can't use "{%CurrentSite.SiteName%}" in place of the site name. Here is an example of a partial cache dependency that worked for me...
node|mytestsite|/test-section/|childnodes
Using the above partial cache dependecy, the cache was refreshed as soon as I deleted a sub-item.

Resources