Add the whole blog
This commit is contained in:
		
					parent
					
						
							
								0d2f58ce7a
							
						
					
				
			
			
				commit
				
					
						c4f23c1529
					
				
			
		
					 418 changed files with 15708 additions and 0 deletions
				
			
		
							
								
								
									
										56
									
								
								content/post/2012-02-12-some-more-nepomuk-please.markdown
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								content/post/2012-02-12-some-more-nepomuk-please.markdown
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,56 @@ | |||
| --- | ||||
| author: einar | ||||
| categories: | ||||
| - KDE | ||||
| - Linux | ||||
| comments: true | ||||
| date: "2012-02-12T19:57:06Z" | ||||
| slug: some-more-nepomuk-please | ||||
| tags: | ||||
| - danbooru | ||||
| - KDE | ||||
| - python | ||||
| title: Some more Nepomuk, please | ||||
| disable_share: true | ||||
| wordpress_id: 949 | ||||
| --- | ||||
| 
 | ||||
| Recently we've seen [several](http://joerg-weblog.blogspot.com/2012/02/conquirere-joins-nepomuks-future.html) [blog posts](http://trueg.wordpress.com/2012/02/11/a-fun-release-nepomuk-tv-namer-0-2/) on [Planet KDE](http://planetkde.org) related to Nepomuk. Reading those I thought that I could add some (little) semantic features to [Danbooru Client]({{ site.url }}/projects/danbooru-client). | ||||
| 
 | ||||
| Danbooru Client already makes use of Nepomuk: if enabled, tags extracted from Danbooru items are added as Nepomuk tags. But since at least some Danbooru boards are specialized in certain types of images (e.g., wallpapers only, for examples) I found it would be nice to have Nepomuk show me only the images that come from a specific Danbooru board. | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| After a quick talk on IRC, the task proved to be easier than expected. What I did was to create a new  Nepomuk.Resource using the image board URL. Then I set it type as `NFO::Website` and added it as a related property to the resource pointing to the file. In code, this translates to (excerpt from the main file): | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| {{< highlight python >}} | ||||
|     resource = Nepomuk.File(KUrl(absolute_path)) | ||||
| 
 | ||||
|     for tag in tags: | ||||
| 
 | ||||
|         if blacklist is not None and tag in blacklist: | ||||
|             continue | ||||
| 
 | ||||
|         nepomuk_tag = Nepomuk.Tag(tag) | ||||
|         nepomuk_tag.setLabel(tag) | ||||
|         resource.addTag(nepomuk_tag) | ||||
|          | ||||
|     if board_url is not None: | ||||
|         website_resource = Nepomuk.Resource(board_url) | ||||
|         website_resource.addType(Nepomuk.Vocabulary.NFO.Website()) | ||||
|         website_resource.setLabel(board_url.prettyUrl()) | ||||
|         resource.setDescription( | ||||
|                     i18n("Retrieved from %1").arg(board_url.prettyUrl())) | ||||
|         resource.addIsRelated(website_resource) | ||||
| {{< / highlight >}} | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| Lo and behold, this is what happens after downloading one such image from Danbooru Client, in Dolphin (notice the "is related to"): | ||||
| 
 | ||||
|  | ||||
| 
 | ||||
| Clicking on the link will open in Dolphin all items related to the board in question. Neat, isn't it? Of course, I'm very willing to add other features like that if there's interest. Also, critiques on the approach are most welcome! | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue