<div dir="rtl" lang="he" class="mw-content-rtl">
{{languages/he|Quick Views}}
[[File:QuickViewReport-EditPerson-context-menu-popup-50default-60.png|thumb|left|450px|תפריט הקשר מצג מהיר בעורך אדם]]
מצגים מהירים (בעבר נקראו ''דוחות מהירים'' אך עדין מופיעים ב"עדכוני תוספים זמינים" כ''דוח מהיר'') הם דוחות אליהם ניתן להגיע מתפריטי ההקשר של: אנשים, משפחות וכדומה'. קיימתקבוצה קיימת קבוצה של [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_8/he#מצגים_מהירים|מצגים מהירים מובנים]] אותה ניתן להרחיב באמצעות תוספים מסוג QuickView.
ההנחה היא שגם משתמשים בעלי ידע מוגבל בקידוד יהיו מסוגלים ליצור אותם.
נלווה לכלי זה, נבנתה גם [[Simple Access API/he|גישה פשוטה למסד נתונים (API)]] וממשק מסמכים פשוט, כדי להסיר מורכבויות עד כמה שניתן.
==היכן לאחסן אחסון מצגים מהירים שיצרתישנוצרו באופן אישי==
מצגים מהירים מורכבים בדרך כלל משני קבצים בתת מחיצה יעודית עבורם, שממוקמים במחיצת התוספים של ה''[[Gramps_{{man version}}_Wiki_Manual_-_User_Directory/he|משתמש]]''. הנתיב למחיצה זו במערכות הפעלה דמויי לינוקס הוא '''/home/[user_name]/.gramps'''. במחיצה זו תמצא מחיצת משנה בשם '''plugins'''. על מנת שתוסף המצג המהיר המותאם אישית יופיע בגרמפס, יש לשמור את הקבצים במחיצה זו.
אל המחיצה ניתן להגיע ממסוף באופן הבא
(כאשר XX מציין את הגרסה המותקנת במחשב):<br>
<div dir="ltr">
cd ~/.gramps/grampsxx/plugins
</div>
* לקריאה נוספת [[Gramps_{{man version}}_Wiki_Manual_-_User_Directory/he| במערכות ההפעלה השונותנספח ד' במדריך הויקי – מחיצת משתמש]]
אל המחיצה ניתן להגיע ממסוף באופן הבא==דוגמה=====קוד===[[File:‎ cd ~/QuickViewReport-people-context-menu-popup-50.gramps/grampsxx/pluginspng|thumb|left|450px|תפריט הקשר מצג מהיר בסוג־אב במצג אדם]]
* לקריאה נוספת [[Gramps_{{man version}}_Wiki_Manual_-_User_Directory/he|נספח ד' של מדריך ויקי - מחיצת משתמש]] ==Example 1=====Code===[[File:QuickViewReport-people-context-menu-popup-50דוגמה ממשית היא דרך מצוינת ללמוד כיצד לבצע דבר מה.png|thumb|right|450px|Quick View context menu on Person View]][[File:Siblings-quick-report-result-34הדוגמה הבאה תראה כיצד לכתוב (קוד) דוח שיציג את כל האחאים של 'אדם'.png|thumb|right|450px|Quick View Report example result output]] How better than to learn something than using an example? Here it goes. We want a report to show all siblings of a person. That isכלומר, brothers and sisters from אחים ואחיות מ'''allכל''' families the person is part ofאותן משפחות שה'אדם' הוא חלק מהן. The quick report is then the following:
פלט דוח מהיר יראה כך:
[[File:QuickViewReport-Siblings-example-60.png|thumb|left|450px|פלט תוצאת מצג מהיר לדוגמה]]
{{-}}
<span id="siblings.gpr.py"></span>
==== siblings2.gpr.py ====
You first need a Gramps registration תחילה נדרש לייצור קובץ רישום בגרמפס (<code>*.gpr.py</code>) file so create a python file named , הרישום לגרמפס נדרש כדי שגרמפס יזהה את הדוח. הרישום מתבצע על ידי יצירת קובץ פיתון בשם <code>Siblings.gpr.py</code> and add the following contentולהוסיף לתוכו את התוכן הבא:<div dir="ltr">
<pre>
#------------------------------------------------------------------------
status = STABLE,
fname = 'siblings2.py',
authors = ["Your Name Hereשם היוצר כאן"], authors_email = ["Your כתובת @ Email address hereדו"ל היוצר כאן"],
category = CATEGORY_QR_PERSON,
runfunc = 'run'
)
</pre>
</div>
<span id="siblings.py"></span>
את הקובץ יש לשמור במחיצה כפי שתואר במקטע שלעיל שמתאר [[#היכן לאחסן מצגים מהירים שיצרתי|היכן לשמור את הקבצים]].
<span id="siblings.py"></span>
==== siblings2.py ====
Now create a python file named לאחר רישום המצג המהיר בגרפס, אפשר לייצור את הקובץ שמכיל את הקוד שנכתב בשפת פיתון. לשם כך יש לייצר קובץ פיתון נוסף בשם <code>siblings.py</code> and add the following contentולהוסיף לתוכו את התוכן הבא ולשמור את הקובץ באותה מחיצה בה נשמר קובץ הרישום בגרמפס:<div dir="ltr">
<pre>
#------------------------------------------------------------------------
stab.write(sdoc)
</pre>
</div>
===ניתוח הקוד: רישום הדוח===
כעת ננתח את קטעי הקוד השונים שנכללו בשני הקבצים שנשמרו קודם לכן.<br>1. קובץ הרישום [[Quick_Views/he#siblings2.gpr.py|siblings2.gpr.py]] . גרמפס יחפש בקובץ הרישום את הפונקציה '''register''' שמופיעה בתחתית הקובץ. להלן פירוט והסבר על שאר שורות קוד קובץ הרישום:* {{man label|name}} =שם ייחודי: שם שבו יזהה גרמפס את המתקע (במקרה זה זהו דוח המצג המהיר), אין להשתמש ברווחים או בסמלים מוזרים. בדוגמה שלעיל נוספה לשם הסיפרה '2' כדי למנוע התנגשויות עם [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_8/he#צאצאים|מצג צאצאים מהיר]].* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L159-L171 {{man label|סוג־אב}}] =קבוע מיוחד שמציין היכן יוצג הדוח. ניתן להשתמש ב־'''CATEGORY_QR_PERSON''' כדי לצפות בדוח בעורך מצג אדם, או '''CATEGORY_QR_FAMILY''' כדי לצפות בדוח בעורך מצג משפחה. (CATEGORY_QR_DATE מיועד לדוחות שניתן להטמיע בתוך דוחות אחרים מכיוון שלא קיים סוג־אב "תאריך").* {{man label|run_func}} =Analysisהיא הפונקציה אותה מייצרים בתוסף זה ואותה יבצע גרמפס כאשר משתמש יבחר את הדוח המהיר הזה מתפריט ההקשר.* [https: registering the report//github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L58-L69 {{man label|מצב}}] =מצב הדוח שנוצר ''', '''לא יציב''', ''יציב''', '''ניסוי''' או '''בטא'''* {{man label|translated_name}} = שם הדוח כפי שיופיע בתפריט* {{man label|description}} =תיאור קצר על התוסף ומטרתו. יופיע כרמז צץ מעל התפריט* {{man label|author_name}} =שם יוצר המתקע* {{man label|author_email}}=דוא"ל יוצר המתקע, כדי שמשתמשים יוכלו לשלוח את ברכתם, או לבקש תיקוני תקלים והצעות לשינויים...
Let's analyse the החל בגירסת גרמפס 5.2 נוספו מספר מאפייני [[Quick_Views#siblings2https://github.gpr.py|siblings2.gpr.py]com/gramps-project/gramps/pull/1451 רישום] file above. We start at the bottom where the report is registered with '''register'''. This is the function Gramps will look for in your file. You need to giveחדשים:*{{man label|namehelp_url}} = a unique name: a name Gramps identifies the plugin with, don't use spaces or strange symbols. In this case, we add a '2' to the name to avoid conflicts with the builtin [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_8#Siblings|siblings quickview]].עמוד המרשתת שייפתח בעת השימוש בעזרה* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L159L71-L171 L76 {{man label|categoryaudience}}] = a special constant indicating where the report will be shown. You can use 'קהל יעד, אפשרויות סינון: 'כולם'CATEGORY_QR_PERSON''' to see the report on person editor and view, or 'מפתחים'ו'CATEGORY_QR_FAMILY''' to see the report on family editor or viewמומחים. (CATEGORY_QR_DATE is for reports that can be embedded in other reports since there is no "Date" category.)*{{man label|run_funcmaintainers}} = the function you create in this plugin and that Gramps will execute when the user selects your quick report in the menuשם האדם שמתחזק כעת את התוסף, במידה ששונה מ־author_name* {{man label|translated_namemaintainers_email}} = the name of the report as it will appear in the menuדוא"ל של האדם שמתחזק כעת את התוסף, במידה ששונה מכתובת author_email* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L58L297-L69 L299 {{man label|statusrequires_mod}}] = is your report '''Stable''', '''Unstable''', '''Experimental''' and '''Beta'''* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L300-L303 {{man label|descriptionrequires_gi}} = a description of what your plugin does], [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg. This appears in a tooltip over the menu* py#L304-L306 {{man label|author_name}} = your name* {{man label|author_emailrequires_exe}}] = your email, so people can congratulate you with your work, or ask for bug fixes..האם קיימות דרישות קדם לתוסף.
And beginning with Gramps 5.2 version, there are [https://github.com/gramps-project/gramps/pull/1451 additional registration properties]: * {{man label|help_url}} = a webpage that will be opened when using the Help* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L71-L76 {{man label|audience}}] = filtering options=ניתוח הקוד: ‘All’, ‘Developer’ and ‘Expert’.* {{man label|maintainers}} פונקציית הריצה= name of person currently maintaining the addon, if different from the author_name* {{man label|maintainers_email}} = email of person currently maintaining the addon, if different from the author_email* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L297-L299 {{man label|requires_mod}}], [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L300-L303 {{man label|requires_gi}}], [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L304-L306 {{man label|requires_exe}}] = if the addon has prerequisites.
===Analysis: the run function=== Now lets analyse the 2. קובץ הריצה [[Quick_Views/he#siblings.py|siblings.py]] file. If the user clicks in the quick view report menu on your report, the run function is executed with the following three parameters:
כאשר משתמש מקיש על דוח מצג מהיר בתפריט ההקשר, פונקציית הריצה תתבצע עם שלושת המשתנים הבאים:
<div dir="ltr">
<code>run(database, document, person)</code>
</div>
כלומר, הדוח מקבל מגרמפס את המשתנים: שם מסד הנתונים שפתוח כעת ונמצע בעבודה, את המסמך עליו יש לכתוב, ואת ה'אדם' של שמקושר לעצם שבמוקד המשתמש (עליו מונח מצביע העכבר). לדוח מצג מהיר 'אדם', זהו אדם, ובהתאמה לדוח מצג מהיר 'משפחה', זוהי משפחה.
Soבדוגמה זו, your report receives from Gramps the currently opened database name on which to work, the document on which to write, and the person of the object the user is on. For a person quick view report, this is a person, for family, a family. In this example, the function called is הפונקציה שתקרא היא:<div dir="ltr">
<code>def run(database, document, person):</code>
</div>
===Analysisניתוח קטע קוד: accessing the dataגישה לנתונים===Now that your plugin runsלאחר השלמת פונקציית הקיצה של המצג המהיר, you need to open the databaseניתן לטפל בפתיחת מסד הנתונים, start the documentהפעלת המסמך, access data, and write it outגישה לנתונים וכתיבתם על המסמך. We do this using the פעולות אלו מתבצעות באמצעות [[Simple Access API/he|Simple Database מנשק APIגישה פשוטה למסד הנתונים]]. So, the following code:
קטע הקוד הבא מכין את כל שנדרש לפעולת הנמנשק:
<div dir="ltr">
<pre>
# setup the simple access functions
sdoc = SimpleDoc(document)
</pre>
</div>prepares everything. Then we write a title on the document, an empty line under itכעת ניתן לטפל בכותרת שתופיע על המסמך: שורת כותרת , and a headerשורה ריקה מתחת לשורת הכותרת וכותרת עליונה, with the titleבאמצעות פונקציית הכותרת, paragraph and header functionהפסקה וראש העמוד:<div dir="ltr">
<pre>
# display the title
sdoc.paragraph("")
</pre>
</div>Note that we use an underscore לתשומת לב! קו תחתון (<code>_</code>) to indicate every string that requires translationמציין מחרוזת שמצריכות תרגום, which comes from the lineמחרוזות אלו ניתנות לשליפה לתוך קובץ ‎.pot וזה מגיע מהשורה:<div dir="ltr">
<pre>
from gramps.gen.ggettext import gettext as _
</pre>
</div>
לאחר שכל ההדגרות הסתיימו, ניתן לגשת לקטע הקוד שיכתוב את השורות עם כל האחאים, את האדם הפעיל עצמו לא כוללים, שכן הוא מופיע בשדה הכותרת!
<div dir="ltr">
<pre>
Everything is set up, now we write out the lines with all the siblings, leaving out the active person himself, as he is in the title field!
<pre>
# grab our current id, so we can filter the active person out
# of the data
stab.write(sdoc)
</pre>
</div>
כאן נעשה שימוש במחלקות הגישה הקלה מ־[[Simple Access API/he|מנשק API גישה פשוטה למסד הנתונים]] כדי להשיג במהירות את המטרה ללא הצורך לכתוב שורות קוד רבות נוספות.
Here, the easy access classes from the [[Simple Access API]] have been used to quickly achieve what we want. ==Example 2דוגמה שניה==
A second example can be found in the Gramps codeדוגמה שנייה ניתן למצוא בקוד גרמפס עצמו. See לקריאה נוספת [https://github.com/gramps-project/gramps/blob/master/gramps/plugins/quickview/all_events.py all_events.py]. In this report, all events for a person are printed, and all events for a familyבדוח זה מודפסים כל האירועים לאדם וכל האירועים למשפחה. Two quick reports are hence registered, one for personלפיכך נרשמים שני דוחות מהירים, and one for familyאחד לאדם ואחד למשפחה.
==Notesהערות==
The possibilities are enormousאפשרויות העברת ושיתוף מידע ממסד הנתונים לפטים שונים הן רבות ומגוונות. If you are an experienced programmerמתכנת מנוסה, there is no need to limit yourself to the simple database APIלא חייב להגביל את עצמו ל־API מסד הנתונים פשוט זה. Alsoכמו כן, if you make a real reportכאשר יוצרים (בכתיבת קוד) דוח 'אמיתי', you can at the same time register a quick report with default settingsניתן במקביל גם לרשום אותו כדוח מהיר עם הגדרות ברירת מחדל.
Seeלקריאה נוספת: [https://github.com/gramps-project/gramps/tree/master/gramps/plugins/quickview https://github.com/gramps-project/gramps/tree/master/gramps/plugins/quickviewמצג מהיר]
=See alsoלקריאה נוספת=* [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_8/he#Quick_Viewsמצגים_מהירים|מצגים מהירים]]
[[Category:Developers/GeneralHe:פתוח]][[Category:Developers/TutorialsHe:תיעוד]][[Category: PluginsHe:תוספים]][[Category:ReportsHe:דוחות]][[Category:ViewsHe:מצגים]]