From cbf2b3563b8944a0e0b688d3e9f0d9efbe742104 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 22 Jan 2019 16:48:10 +0100 Subject: [PATCH] Update org-chef. Signed-off-by: Andreas Gerler --- .../org-chef-all-recipes.el | 0 .../org-chef-autoloads.el | 8 + .../org-chef-budget-bytes.el | 0 .../org-chef-chef-koch.el | 0 .../org-chef-cultures-for-health.el | 0 .../org-chef-genius-kitchen.el | 0 .../org-chef-marmiton.el | 0 .../org-chef-martha-stewart.el | 0 .../org-chef-nytimes.el | 0 .../org-chef-pkg.el | 2 +- .../org-chef-reluctant-gourmet.el | 0 .../org-chef-20181202.2221/org-chef-saveur.el | 139 ++++++++++++++++++ .../org-chef-serious-eats.el | 0 .../org-chef-simply-recipes.el | 0 .../org-chef-steamy-kitchen.el | 0 .../org-chef-utils.el | 3 +- .../org-chef-wordpress.el | 0 .../org-chef.el | 2 + elpa/org-chef-readme.txt | 3 - 19 files changed, 152 insertions(+), 5 deletions(-) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-all-recipes.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-autoloads.el (94%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-budget-bytes.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-chef-koch.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-cultures-for-health.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-genius-kitchen.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-marmiton.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-martha-stewart.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-nytimes.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-pkg.el (84%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-reluctant-gourmet.el (100%) create mode 100644 elpa/org-chef-20181202.2221/org-chef-saveur.el rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-serious-eats.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-simply-recipes.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-steamy-kitchen.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-utils.el (94%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef-wordpress.el (100%) rename elpa/{org-chef-20181105.2035 => org-chef-20181202.2221}/org-chef.el (98%) delete mode 100644 elpa/org-chef-readme.txt diff --git a/elpa/org-chef-20181105.2035/org-chef-all-recipes.el b/elpa/org-chef-20181202.2221/org-chef-all-recipes.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-all-recipes.el rename to elpa/org-chef-20181202.2221/org-chef-all-recipes.el diff --git a/elpa/org-chef-20181105.2035/org-chef-autoloads.el b/elpa/org-chef-20181202.2221/org-chef-autoloads.el similarity index 94% rename from elpa/org-chef-20181105.2035/org-chef-autoloads.el rename to elpa/org-chef-20181202.2221/org-chef-autoloads.el index f3a927b2..9cd8eda7 100644 --- a/elpa/org-chef-20181105.2035/org-chef-autoloads.el +++ b/elpa/org-chef-20181202.2221/org-chef-autoloads.el @@ -83,6 +83,14 @@ (if (fboundp 'register-definition-prefixes) (register-definition-prefixes "org-chef-reluctant-gourmet" '("org-chef-reluctant-gourmet-"))) +;;;*** + +;;;### (autoloads nil "org-chef-saveur" "org-chef-saveur.el" (0 0 +;;;;;; 0 0)) +;;; Generated autoloads from org-chef-saveur.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "org-chef-saveur" '("org-chef-saveur-"))) + ;;;*** ;;;### (autoloads nil "org-chef-serious-eats" "org-chef-serious-eats.el" diff --git a/elpa/org-chef-20181105.2035/org-chef-budget-bytes.el b/elpa/org-chef-20181202.2221/org-chef-budget-bytes.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-budget-bytes.el rename to elpa/org-chef-20181202.2221/org-chef-budget-bytes.el diff --git a/elpa/org-chef-20181105.2035/org-chef-chef-koch.el b/elpa/org-chef-20181202.2221/org-chef-chef-koch.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-chef-koch.el rename to elpa/org-chef-20181202.2221/org-chef-chef-koch.el diff --git a/elpa/org-chef-20181105.2035/org-chef-cultures-for-health.el b/elpa/org-chef-20181202.2221/org-chef-cultures-for-health.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-cultures-for-health.el rename to elpa/org-chef-20181202.2221/org-chef-cultures-for-health.el diff --git a/elpa/org-chef-20181105.2035/org-chef-genius-kitchen.el b/elpa/org-chef-20181202.2221/org-chef-genius-kitchen.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-genius-kitchen.el rename to elpa/org-chef-20181202.2221/org-chef-genius-kitchen.el diff --git a/elpa/org-chef-20181105.2035/org-chef-marmiton.el b/elpa/org-chef-20181202.2221/org-chef-marmiton.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-marmiton.el rename to elpa/org-chef-20181202.2221/org-chef-marmiton.el diff --git a/elpa/org-chef-20181105.2035/org-chef-martha-stewart.el b/elpa/org-chef-20181202.2221/org-chef-martha-stewart.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-martha-stewart.el rename to elpa/org-chef-20181202.2221/org-chef-martha-stewart.el diff --git a/elpa/org-chef-20181105.2035/org-chef-nytimes.el b/elpa/org-chef-20181202.2221/org-chef-nytimes.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-nytimes.el rename to elpa/org-chef-20181202.2221/org-chef-nytimes.el diff --git a/elpa/org-chef-20181105.2035/org-chef-pkg.el b/elpa/org-chef-20181202.2221/org-chef-pkg.el similarity index 84% rename from elpa/org-chef-20181105.2035/org-chef-pkg.el rename to elpa/org-chef-20181202.2221/org-chef-pkg.el index 9340d6fa..70f03844 100644 --- a/elpa/org-chef-20181105.2035/org-chef-pkg.el +++ b/elpa/org-chef-20181202.2221/org-chef-pkg.el @@ -1,4 +1,4 @@ -(define-package "org-chef" "20181105.2035" "Cookbook and recipe management with org-mode." +(define-package "org-chef" "20181202.2221" "Cookbook and recipe management with org-mode." '((org "0") (emacs "24")) :keywords diff --git a/elpa/org-chef-20181105.2035/org-chef-reluctant-gourmet.el b/elpa/org-chef-20181202.2221/org-chef-reluctant-gourmet.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-reluctant-gourmet.el rename to elpa/org-chef-20181202.2221/org-chef-reluctant-gourmet.el diff --git a/elpa/org-chef-20181202.2221/org-chef-saveur.el b/elpa/org-chef-20181202.2221/org-chef-saveur.el new file mode 100644 index 00000000..e5dfc0e4 --- /dev/null +++ b/elpa/org-chef-20181202.2221/org-chef-saveur.el @@ -0,0 +1,139 @@ +;;; org-chef-saveur.el --- Functions for fetching recipes from saveur.com. -*- lexical-binding: t; -*- + +;; Copyright (C) 2018 Calvin Beck/Derek Ellis + +;; Author: Calvin Beck /Derek Ellis +;; URL: https://github.com/Chobbes/org-chef +;; Created: 2018 + +;; Copyright 2018 Calvin Beck/Derek Ellis + +;; Permission is hereby granted, free of charge, to any person +;; obtaining a copy of this software and associated documentation +;; files (the "Software"), to deal in the Software without +;; restriction, including without limitation the rights to use, copy, +;; modify, merge, publish, distribute, sublicense, and/or sell copies +;; of the Software, and to permit persons to whom the Software is +;; furnished to do so, subject to the following conditions: + +;; The above copyright notice and this permission notice shall be +;; included in all copies or substantial portions of the Software. + +;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +;; SOFTWARE. + +;;; Commentary: + +;; Functions for fetching information from saveur.com. + +;;; Code: + + +(require 'org-chef-utils) +(require 'dom) + + (defun org-chef-saveur-chomp (str) + "Chomp leading and tailing whitespace from STR." + (replace-regexp-in-string (rx (or (: bos (* (any " \t\n"))) + (: (* (any " \t\n")) eos))) + "" + str)) + + +(defun org-chef-saveur-extract-name (dom) + "Get the name of a recipe from an saveur DOM." + (string-trim (dom-text (car (dom-by-class dom "page-title"))))) + + +(defun org-chef-saveur-extract-ingredients (dom) + "Get the ingredients for a recipe from an saveur DOM." + (remove "" + (mapcar 'org-chef-saveur-chomp + (split-string + (replace-regexp-in-string " ⁄ " "/" + (string-join (mapcar #'dom-texts (dom-by-class dom "^ingredients$")))) "\n" )))) + + +(defun org-chef-saveur-extract-servings (dom) + "Get the number of servings for a recipe from an saveur DOM." + (replace-regexp-in-string "serves " "" + (dom-text (dom-by-tag (dom-by-class dom "yield") 'span)))) + + +(defun org-chef-saveur-extract-prep-time (dom) + "Get the amount of prep-time for a recipe from an saveur DOM." + (org-chef-saveur-chomp + (dom-text (dom-by-class dom "^prep-time$")))) + + +(defun org-chef-saveur-extract-cook-time (dom) + "Get the amount of cook-time for a recipe from an saveur DOM." + (org-chef-saveur-chomp + (dom-text (dom-by-class dom "^cook-time$")))) + + +(defun org-chef-saveur-extract-ready-in (dom) + "Get the total amount of time for a recipe from an saveur DOM." + (string-trim (dom-texts (dom-by-class (cadr (dom-by-tag (dom-by-class dom "recipe-time-yield") 'li)) "recipe-yield-value")))) + + +(defun org-chef-saveur-extract-directions (dom) + "Get the directions for a recipe from an saveur DOM." + (remove "" + (mapcar 'org-chef-saveur-chomp + (split-string + (replace-regexp-in-string " ⁄ " "/" + (dom-texts + (dom-by-class dom "^instructions "))) "\n \n " )))) + +(defun org-chef-saveur-from-dom (dom) + "Given an saveur.com DOM, retrieve the recipe information. + +This returns an alist with the following keys: + +- name +- ingredients +- servings +- prep-time +- cook-time +- ready-in +- directions" + (let* ((prep-time (org-chef-saveur-extract-prep-time dom)) + (cook-time (org-chef-saveur-extract-cook-time dom)) + (total-time (org-chef-saveur-extract-ready-in dom))) + + `((ingredients . ,(org-chef-saveur-extract-ingredients dom)) + (name . ,(org-chef-saveur-extract-name dom)) + (servings . ,(org-chef-saveur-extract-servings dom)) + (prep-time . ,prep-time) + (cook-time . ,cook-time) + (ready-in . ,total-time) + (directions . ,(org-chef-saveur-extract-directions dom))))) + + +(defun org-chef-saveur-fetch (url) + "Given an saveur.com URL, retrieve the recipe information. + +This returns an alist with the following keys: + +- name +- ingredients +- servings +- prep-time +- cook-time +- ready-in +- directions +- source-url" + (with-current-buffer (url-retrieve-synchronously url) + (let ((dom (libxml-parse-html-region (point-min) (point-max)))) + (cons `(source-url . ,url) (org-chef-saveur-from-dom dom))))) + + +(provide 'org-chef-saveur) +;;; org-chef-saveur.el ends here diff --git a/elpa/org-chef-20181105.2035/org-chef-serious-eats.el b/elpa/org-chef-20181202.2221/org-chef-serious-eats.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-serious-eats.el rename to elpa/org-chef-20181202.2221/org-chef-serious-eats.el diff --git a/elpa/org-chef-20181105.2035/org-chef-simply-recipes.el b/elpa/org-chef-20181202.2221/org-chef-simply-recipes.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-simply-recipes.el rename to elpa/org-chef-20181202.2221/org-chef-simply-recipes.el diff --git a/elpa/org-chef-20181105.2035/org-chef-steamy-kitchen.el b/elpa/org-chef-20181202.2221/org-chef-steamy-kitchen.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-steamy-kitchen.el rename to elpa/org-chef-20181202.2221/org-chef-steamy-kitchen.el diff --git a/elpa/org-chef-20181105.2035/org-chef-utils.el b/elpa/org-chef-20181202.2221/org-chef-utils.el similarity index 94% rename from elpa/org-chef-20181105.2035/org-chef-utils.el rename to elpa/org-chef-20181202.2221/org-chef-utils.el index 2239825a..a9aadb24 100644 --- a/elpa/org-chef-20181105.2035/org-chef-utils.el +++ b/elpa/org-chef-20181202.2221/org-chef-utils.el @@ -52,8 +52,9 @@ The optional argument BULLET specifies which type of bullet point should be used." - (mapcar (lambda (x) (progn (insert (format "%s" x)) + (mapcar (lambda (x) (progn (insert (format "%s " (string-trim x))) (org-cycle) + (org-delete-backward-char 1) (org-ctrl-c-minus) (if bullet (org-cycle-list-bullet bullet)) (org-return))) diff --git a/elpa/org-chef-20181105.2035/org-chef-wordpress.el b/elpa/org-chef-20181202.2221/org-chef-wordpress.el similarity index 100% rename from elpa/org-chef-20181105.2035/org-chef-wordpress.el rename to elpa/org-chef-20181202.2221/org-chef-wordpress.el diff --git a/elpa/org-chef-20181105.2035/org-chef.el b/elpa/org-chef-20181202.2221/org-chef.el similarity index 98% rename from elpa/org-chef-20181105.2035/org-chef.el rename to elpa/org-chef-20181202.2221/org-chef.el index 227ebc3b..90c4acee 100644 --- a/elpa/org-chef-20181105.2035/org-chef.el +++ b/elpa/org-chef-20181202.2221/org-chef.el @@ -53,6 +53,7 @@ (require 'org-chef-chef-koch) (require 'org-chef-steamy-kitchen) (require 'org-chef-nytimes) +(require 'org-chef-saveur) (require 'org-chef-wordpress) @@ -107,6 +108,7 @@ ((org-chef-match-url "chefkoch.de" URL) (org-chef-chef-koch-fetch URL)) ((org-chef-match-url "steamykitchen.com" URL) (org-chef-steamy-kitchen-fetch URL)) ((org-chef-match-url "nytimes.com" URL) (org-chef-nytimes-fetch URL)) + ((org-chef-match-url "saveur.com" URL) (org-chef-saveur-fetch URL)) (t nil))) diff --git a/elpa/org-chef-readme.txt b/elpa/org-chef-readme.txt deleted file mode 100644 index b59d21fe..00000000 --- a/elpa/org-chef-readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -org-chef is a package for managing recipes in org-mode. One of the -main features is that it can automatically extract recipes from -websites like allrecipes.com -- 2.47.3