not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
3.4 KiB

  1. [Go back to tutorial home](tutorial.md)
  2. # Step 1: create the activity from the template
  3. *(Estimated time: 15mn)*
  4. Sugarizer comes with an empty template that you could use as base of your new activity. So first, copy all content of the Sugarizer [activities/ActivityTemplate](activities/ActivityTemplate) directory in a new directory called `activities/Pawn.activity`. **Pawn** will be the name for our new activity.
  5. ### File structure
  6. In your new directory, you will find the following file structure:
  7. ![](images/tutorial_step1_1.png)
  8. * `activity/` contains information about your activity, including the name, ID, and the icon.
  9. * `index.html` is where the elements that compose your activity are defined. The template comes with a toolbar and a canvas where you can place your content.
  10. * `js/activity.js` is where the logic of your activity lives.
  11. * `css/activity.css` is where you add the styling of your activity.
  12. Those are the files you'll modify in most cases. The others are:
  13. * `js/loader.js` configures the libraries paths and loads your `js/activity.js`
  14. * `lib/` contains the libraries
  15. * `package.json` contains information about the libraries the activity depends on
  16. * `setup.py` is used if you want to run your activity in Sugar.
  17. ### Customize the activity
  18. Then customize the activity using your text editor. Change the name for your activity. Write `Pawn` in the activity **name** and `org.sugarlabs.Pawn` in **bundle_id** properties in `activity/activity.info` of the new directory.
  19. [Activity]
  20. name = Pawn
  21. activity_version = 1
  22. bundle_id = org.sugarlabs.Pawn
  23. exec = sugar-activity-web
  24. icon = activity-icon
  25. Use also your text editor to change the **title** tag of `index.html` to `Pawn Activity`.
  26. <!DOCTYPE html>
  27. <html>
  28. <head>
  29. <meta charset="utf-8" />
  30. <title>Pawn Activity</title>
  31. <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width"/>
  32. <link rel="stylesheet" media="not screen and (device-width: 1200px) and (device-height: 900px)"
  33. href="lib/sugar-web/graphics/css/sugar-96dpi.css">
  34. <link rel="stylesheet" media="screen and (device-width: 1200px) and (device-height: 900px)"
  35. href="lib/sugar-web/graphics/css/sugar-200dpi.css">
  36. <link rel="stylesheet" href="css/activity.css">
  37. <script data-main="js/loader" src="lib/require.js"></script>
  38. </head>
  39. ...
  40. Finally, update the file `activities.json` at the root of the Sugarizer directory: add a new line for your activity. Update **id**, **name** and **directory** values on this new line to `org.sugarlabs.Pawn`, `Pawn` and `activities/Pawn.activity`.
  41. [
  42. {"id": "org.sugarlabs.Pawn", "name": "Pawn", "version": 1, "directory": "activities/Pawn.activity", "icon": "activity/activity-icon.svg", "favorite": true, "activityId": null},
  43. {"id": "org.sugarlabs.GearsActivity", "name": "Gears", "version": 6, "directory": "activities/Gears.activity", "icon": "activity/activity-icon.svg", "favorite": true, "activityId": null},
  44. {"id": "org.sugarlabs.MazeWebActivity", "name": "Maze Web", "version": 2, "directory": "activities/MazeWeb.activity", "icon": "activity/activity-icon.svg", "favorite": true, "activityId": null},
  45. Now run Sugarizer, you should see the icon of a new activity like this:
  46. ![](images/tutorial_step1_2.png)
  47. Let's run the activity by clicking on it. You will see the first step of your activity.
  48. ![](images/tutorial_step1_3.png)
  49. Now you are ready to go ahead and customize your activity.
  50. [Go to next step](tutorial_step2.md)