Coder Social home page Coder Social logo

moc / cookbook Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 3.0 1.63 MB

Important: NOT READY FOR RELEASE YET!! A fully featured Cookbook plugin for e107, for all your recipes. Includes functionalities such as categorization, sharing, and bookmarking.

License: Apache License 2.0

PHP 82.75% CSS 2.71% JavaScript 14.54%
e107 cookbook recipes plugin

cookbook's People

Contributors

ericc-dream avatar gitter-badger avatar moc avatar

Stargazers

 avatar  avatar

Watchers

 avatar

cookbook's Issues

SQL Insert Error when creating the first recipe

Bug Description

When I created the first recipe, just after installing the plugin, I had a "SQL Insert Error"
I retried several time with the same problem, so I activate "Developer mode" and this time it worked
For each try, I delete the database and re-import it, so I'm in the same state each time

How to Reproduce

Steps to reproduce the behavior:

  1. Install the plugin
  2. Go to "Configure" and then "Add a recipe"
  3. Create your recipe, fill all cells
  4. click on "Create button"

Expected Behavior

Just the recipe to be added to the database

I activate the debug mode [debug=sql!] , and this is what I have collected :

System Debug
Event triggers fired (admin_cookbook_recipes_create, admin_ui_create) Toggle data
SQL Error #23000: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'r_instructionsnew' cannot be null
SQL QRY Error 
Debug Log
Message	Function	File	Line
Session Save Method: db 	e_session->setDefaultSystemConfig()() 	/home/ericc/www/ericc/e107_handlers/session_handler.php 	931 
Timezone: Europe/Brussels 	init_session() 	/home/ericc/www/ericc/class2.php 	672 
Broken Icon Path: images/icon_32.png 	e_parse->toIcon()() 	/home/ericc/www/ericc/e107_core/shortcodes/batch/navigation_shortcodes.php 	266 
Using Cached Core Update Data 	admin_shortcodes->sc_admin_update()() 	/home/ericc/www/ericc/e107_handlers/shortcode_handler.php 	1154 
Possible issue: Missing a Unique Tablerender ID. Use $ns->setUniqueId() in the plugin script prior to setContent(). See 'source code' for more information. 	e_render->setContent()() 	/home/ericc/www/ericc/e107_handlers/e_render_class.php 	391 
Possible issue: Missing a Unique Tablerender ID. Use $ns->setUniqueId() in the plugin script prior to setContent(). See 'source code' for more information. 	e_render->setContent()() 	/home/ericc/www/ericc/e107_handlers/e_render_class.php 	391 

Probably an issue with the Admin theme, but at first I haven't see that there was something in the big almost white box

Array
(
    [_FIELD_TYPES] => Array
        (
            [r_id] => int
            [r_thumbnail] => str
            [r_name] => str
            [r_name_sef] => str
            [r_category] => int
            [r_datestamp] => int
            [r_author] => int
            [r_keywords] => str
            [r_persons] => int
            [r_time] => int
            [r_authorrating] => int
            [r_difficulty] => int
            [r_summary] => str
            [r_ingredients] => str
            [r_instructions] => str
            [r_instructionsnew] => json
        )

    [data] => Array
        (
            [r_id] => 
            [r_thumbnail] => {e_MEDIA_IMAGE}2024-07/i71869_toasts_au_chevre_avocat_et_tomates_sechees.webp
            [r_name] => Toast Avocat
            [r_name_sef] => toast-avocat
            [r_category] => 3
            [r_datestamp] => 1720035549
            [r_author] => 1
            [r_keywords] => Avocat,Poulet
            [r_persons] => 2
            [r_time] => 30
            [r_authorrating] => 1
            [r_difficulty] => 1
            [r_summary] => Voici une recette simple, rapide et excellente ... surtout en été
Mais vous devez absolument avoir un toaster, à plat ou de type "clam"
            [r_ingredients] => Pour 3 ou 4 toasts, pour 2 ou 3 personnes, selon la taille du pain, vous aurez besoin de :

[list][*]Pain de mie ou de campagne, avec des céréales c'est meilleur. J'utilise un pain noir avec de grandes tranches
  [*]Un avocat mur mais pas trop (pas qu'il tombe en purée)
  [*]  de la Mozzarella, environ 250gr ou plus, pour 2 ou 3 personnes. Pas besoin de prendre de la "di Bufala" sauf si vous avez de l'argent à perdre rolleyes
  [*]  des poivrons en bocal, grillés et à l'huile d'olive
  [*]  du beurre, du vrai que l'on peux chauffer, pour faire blondir le pain
[/list]


Optionnellement :

[list][*]des aiguillettes de poulet. Normalement ce sont des toasts végétariens, et c'est déjà bon comme cela, mais je suis un horrible carnassier blush2 ceci dit, je n'en met pas à chaque fois
    [*]des tomates séchées dans l'huile d'olive. Totalement accessoire ! La dernière fois que j'ai fait ces toasts, il restait un demi bocal de tomates séchés, c'est pas mal, mais c'est loin d'être obligatoire
[/list]
            [r_instructions] => Environ 1h avant:

    sortir les poivrons de l'huile d'olive et les étaler sur une assiette avec du papier absorbant (même chose avec les tomates si vous avez décidé d'en mettre)
    couper la mozzarella en relativement fines tranches (c'est moins simple que cela en à l'air) et les mettre sur une assiette pour quelle dégorge


Le but de tout ceci est de limiter la quantité de "liquide" par la suite qui pourrais venir imbiber le pain et/ou couler dans le toaster

Faire dorer le poulet, si vous avez choisi d'en mettre et ensuite le laisser refroidir dans une assiette sur du papier absorbant

Préparation des toasts :

    Couper l'avocat en deux, l'éplucher et le couper en fine tranche. Faire cela au dernier moment pour éviter qu'il ne devienne noir.
    Mettre du beurre sur toutes les faces des tranches de pain
    Puis sur le pain, mettre une couche de poivrons, de toutes les couleurs, c'est plus beau
    2 aiguillettes de poulet éventuellement
    une couche de Mozzarella
    une couche d'Avocat
    la tranche de pain



Quand vous avez préparez tout les toasts, deux par deux dans le toaster, jusqu'à ce que le pain soit bien grillé et la mozzarella fondue

Servez chaud, et régalez vous !
            [r_instructionsnew] => 
        )

)

Note that when the "Developer mode" is not active, there are no cell "instructionsnew"
And when it's active, I see some cells with label "New instructions" but I never fill them

I tried to desactivate the "Developer mode" and create a new recipe and I encounter the same problem again

Server Information (optional)

Apache 2.0 running on Linux Ubuntu server in a VM

PHP Version

PHP8.2.20

Client Information

Firefox 127.0.2 , on Linux Kubuntu (Ubuntu and KDE)

Tell me if you need more info

Allow users to bookmark a specific recipe

Motivation

Users may want to save a recipe to check back later

Proposed Solution

  1. Users can add a specific recipe to their bookmarks
  2. Users can access an overview of all their bookmarks

Additional information

Feature 1: add recipe to bookmark

  • Use a bookmark icon
  • AJAX integration?

Feature 2: overview of all bookmarks

  • Sort by date
  • Sort by category?

Allow users to rate the recipe

Motivation

Users may want to vote on recipes when they find them valuable. This way other users can see which recipes are most liked by other people.

Proposed Solution

  • Functionality that allows users to rate specific recipes (stars?)
  • Admin can choose which userclass can rate recipes
  • Show average rating (# of stars?) and amount of people who have votes
  • Order by rating

Additional Context

Just a note; currently the 'rating' was designed for the recipe author to submit their own rating to a recipe. In the future, this will be changed to difficulty level (see #5) and the rating will be re-designed to be a 'user rating' as explained above.

Date format - hardcoded values

Bug Description

Nothing important but the values in the droplist to choose the date format are hardcoded making impossible to translate them.
I see that you have added some "// TODO LAN" in the code, So I assume that you are aware
May be also, in the help, you may explain what you mean by "long", "short" and "relative" !
I have an idea for the 2 first, but "relative" puzzle me :-)

How to Reproduce

Admin -> Cookbook -> Preferences -> Date format ; droplist
You have to select another language than English, obviously

Expected Behavior

the choice translated in other languages

PHP Version

PHP Version 8.2.19

Client Information

Firefox 126.0.2 on Linux Kubuntu 23.10

Contact form per recipe....

Motivation

Would be nice so people can in an easy way contact the owner of a recipe privatly

Proposed Solution

It would be great if you also have a kind of contact form for each recipe so that a member can send an email instead of commenting publicly, stating the recipe in question. ..

printing issue

Do you have idea why real printing looks different:

image

Thanks

Allow variable image size - support SETIMAGE in template

Motivation

Now is always image 180px, there is no possible to change it

Reason:
$thumbUrl = e107::getParser()->thumbUrl($thumbImage, 'aw=180');

Proposed Solution

Support f.e.
{SETIMAGE: w=900&h=600}

Fix

$thumbUrl = e107::getParser()->thumbUrl($thumbImage);
and
{SETIMAGE: w=180&h=180}
in template

Allowing external images

Motivation

When I create a category or a recipe, I can upload an image which is a nice feature
However, some people have a hosting plan with a rather limited disk space (or number of inodes ...) . Actually on one of my site, I have only 125Mb (free webhostmost)

Proposed Solution

It could be useful to allow to link images from another server, like imgbox by example, and not being obliged to uploaded them.

Checkbox for ingredients

Motivation

Just from curiosity :)

Proposed Solution

This is really nice feature - to check if you have them or not

image

Adjust services is too much (they don't support this on WP version either)

Allow users to submit new recipes

Motivation

Users may want to submit new recipes to the cookbook.

Proposed Solution

  • A functionality that allows users to submit new recipes
  • Admin can decide on which userclass is able to submit new recipes
  • Approval functionality by admin to verify the submitted recipes?

front page "Recipe information"

Bug Description

Don't know if it's due to the theme that I'm using or it's the same every where , see screenshot
Screenshot_20240710_202148
The icons aren't vertically aligned with the text ...
Also there are no icon for the "difficulty" , and if you can add a "info bubble" to define what the icon represent ?
I had to check the html code to understand that the "cup" was in fact the author rating (well I guess, as it say only "rating")

And while I'm at it, at the bottom of the recipe, when a user give a rating
Screenshot_20240710_203138
the stars should be on the same line
And from where this "Thanks for voting!" is coming ?
I searched in the plugin, and I couldn't found it.
In the language folder, I found the same text for "RATELAN_3" , but again, I couldn't found it in the plugin
And as I said, my site is in French and "RATELAN_3" is translated

little mistype in label

Bug Description

        $label = (!empty($parm['label'])) ? $parm['label'] : LAN_CB_RATE_RECIPE;

        $options = array(); 
        $options['label'] = $labeL;

latest labeL - there is big L

It is visible better from here:
image

Rating scale

Motivation

Actually when we activate Author and User rating. The Author can rate his recipe between 1 and 3 , while a user rate between 1 and 5 stars

Proposed Solution

It will be nice to be able to choose the scale for the author, on 3 or on 5 or on 10 by example. Even "on 5" to be aligned with the user, if you don't want to allow to change in the parameters

New needed fields

Motivation

*** just discussion ***

  • recipe author as text
  • poster - if community site, and author is user, then user ID - who posted recipe
  • preparation time - now is there total time, but interesting fact is active time too

add class parameter to sc_cookbook_recipe_thumb()

Motivation

Your output is
'<img class="img-responsive" src="'.$thumbUrl.'" alt="'.$this->sc_cookbook_recipe_name('no_url').'" />';

Image class should be parameter as in other part of core

Thanks

Add summary -

Motivation

Missing short description after title. It could be used for meta description too

Proposed Solution

Summary like with news (only textarea)

  • block level,

Status

Hi Moc

I see that you said " NOT READY FOR RELEASE YET!! "
Can you describe what is missing ?
I'm using e107, and I love to publish some recipe.
Actually, I'm doing it in a dedicated section of the forum but having a plugin for that can be interesting

Is it "usable" ? even a little bit ?

Best regards

Report after testing categories

I tested categories on really advanced stuff

I don't ask for adding new fields to the category table because this can be easily done with a little change of category name shortcode.

Default
image

After hover
image

This is code from the theme template (working code after that change in shortcode):

$COOKBOOK_CATEGORIESMENU_TEMPLATE = array();
          
$COOKBOOK_CATEGORIESMENU_TEMPLATE['default']['caption'] = '{COOKBOOK_CATEGORIESMENU_CAPTION}';
$COOKBOOK_CATEGORIESMENU_TEMPLATE['default']['start']   = '<div class="recipe-categories justify-content-center">';
$COOKBOOK_CATEGORIESMENU_TEMPLATE['default']['item']    = '
	<a href="{COOKBOOK_CATEGORY_NAME=link}" data-animate="fadeInUp" data-delay="{THEME_DELAY}" class="recipe-category" style="background-image: url(\'{THEME_PATH}/recipes/demo/images/categories/{COOKBOOK_CATEGORY_NAME=sef}.jpg\');">
		<div class="recipe-category-inner">
			<div class="recipe-category-icon"><img src="{THEME_PATH}/recipes/demo/images/icons/{COOKBOOK_CATEGORY_NAME=sef}.svg" alt="{COOKBOOK_CATEGORY_NAME=title}"></div>
			<div class="recipe-category-info">{COOKBOOK_CATEGORY_NAME=title}</div>
		</div>
	</a> ';
$COOKBOOK_CATEGORIESMENU_TEMPLATE['default']['end']     = '</div>';

Some question/suggestion:

1. I couldn't use theme shortcode in this template**
{THEME_PATH} - it is the path in the theme folder. I was used to using it (it is a global shortcode) in any template with hardcoded images. It didn't work in your template/plugin. No idea why. This is an indication that something is wrong.

Solved. The second parameter has to be true. Could you change it, please? Code above changed,

  // Return render item from template
  $text .= e107::getParser()->parseTemplate($this->template['item'], true, $sc);

2. your parameters naming
This type of stuff (return different values) is common and the rule should be:

  • if the shortcode name is NAME (or title) then return the clean name without the parameter
  • if you want to return something different, use the parameter

3. you should use the new way of parameters - array
f.e. you add class as next parameter in the future and you will need to rewrite everything

4. use common name for parameter, f.e. like in news
"link" - it is for name shortcode that returns title as link
"anchor/sef" - it is for sef url field
"title" - it is for title/name field

"no-url' is not common at all, you will never guess it without looking in the code

This is the shortcode I used:


    function sc_cookbook_category_name($parm = array())
    {
        $category = e107::getDb()->retrieve('cookbook_categories', 'c_id, c_name, c_name_sef', 'c_id = '.$this->var['r_category']);

        if($parm == 'no_url')
        {
            return $category['c_name'];
        }

		if ($parm == 'title')
		{
			return $category['c_name'];
		}


		if ($parm == 'sef')
		{
			return $category['c_name_sef'];
		}

        $urlparms = array(
            'c_id'	      => $category['c_id'],
            'c_name_sef'  => $category['c_name_sef'],
        );

		$url = e107::url('cookbook', 'category', $urlparms);

		if ($parm == 'link')
		{
			return $url;
		}

        return '<a href="'.$url.'">'.$category['c_name'].'</a>';
    }

Do you know what I mean?

If you want the same result, your shortcode should be named (COOKBOOK_CATEGORY) and using the parameters to return different values.

Sometimes is full code enough, sometimes you need to split it into the name, URL, unique field etc...

If you want to split this into more shortcodes, CATEGORY_ANCHOR is the name for the shortcode that returns sef field.

This was the original HTML code for the category:

									<a href="demos/recipes/recipes.html" data-animate="fadeInUp" data-delay="500" class="recipe-category" style="background-image: url('demos/recipes/images/categories/seafood.jpg');">
										<div class="recipe-category-inner">
											<div class="recipe-category-icon"><img src="demos/recipes/images/icons/seafood.svg" alt="Seafood"></div>
											<div class="recipe-category-info">Seafood</div>
										</div>
									</a>

edit button and bookmark, print

Motivation

    /* {COOKBOOK_EDIT} */
	function sc_cookbook_edit($parm='')
	{
		if(check_class(e107::getPlugPref('cookbook', 'submission_userclass')))
		{
			$link = e_PLUGIN_ABS.'cookbook/admin_config.php?action=edit&id='.$this->var["r_id"].'';
			return '<li><i class="fa-li fa fa-pencil"></i> <a href="'.$link.'">'.LAN_EDIT.'</a></li>';
		}
		return;
	}

Proposed Solution

Could you add parameter or move<li></li>to template? When you want to use edit button separately withou <ul></ul>

image

correct icon

Could you use core solution for glyphs? Your fa-pencil is not displayed in bootstrap 5 theme

Quick fix: fa-edit is working

Image format webp not allowed to upload

Bug Description

I tried to create a new recipe and to upload a picture to illustrate it.
Image was in webp format and I had an error saying

Unapproved file-type detected. ../../../e107_system/18c158d14e/import/i71869_toasts_au_chevre_avocat_et_tomates_sechees.webp

How to Reproduce

Admin -> Cookbook -> Add a recipe -> Image : click on the square saying

Drop files here to upload

Select a .webp image

Expected Behavior

The image to be uploaded.
The same image in webp is 47Kb , while in png 512Kb
And in ~/e107_plugins/cookbook/images/ there are some webp images , don't know where they are used however !

PHP Version

PHP Version 8.2.19

Client Information

Firefox 126.0.2 on Linux Kubuntu 23.10

Duplicated use of category menu causes fatal erroru

Bug Description

Fatal error: Cannot declare class cookbook_categoriesmenu, because the name is already in use in ***\cookbook\cookbook_categories_menu.php on line 21

How to Reproduce

Steps to reproduce the behavior:

  1. Add the category menu 2x on the same layout

Could you add a check if class already exists?

Thanks

Tables creation error

Bug Description

Update Unsuccessful [CREATE TABLE e107_cookbook_recipes () ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;].

How to Reproduce

Try to install github version

Screenshots

This was issue"´:
image

Server Information (optional)

PHP Version

PHP 7.4

Allow user to use Grid overview rather than Datatables

Motivation

Currently, all recipes are listed only in a table view (using Datatables). Community websites normally use grid views (like blog posts).

Proposed Solution

Also allow a grid view, which can be modified through a separate template

Allow users to add a 'difficulty level' to their recipes

Motivation

Recipes may vary in complexity. People may want to filter recipes according to their complexity.

Proposed Solution

  • Have a complexity categorization (e.g. easy, moderate, complex || low, medium, high?) that recipe authors can define

adding share options

Motivation

image

Proposed Solution

Not sure if this can be done directly with core.

COOKBOOK_BOOKMARK - templating

Motivation

to solve this look

image

hardcoded fa-li class is causing neither FA icon is displayed (I know it needs ul class too)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.