Giter VIP home page Giter VIP logo

categoriesforappstudio's Introduction

New version 2015.11.03 (compatible with the last version of Windows App Studio, but only with Windows 10 apps).

What is CategoriesForAppStudio?

CategoriesForAppStudio modify your Windows App Studio Visual Studio solution, in order to:

  • use generic categories for your items collections, show them and navigate through categories
  • easily connect to a Rest Api (Json or Xml)
  • easily connect to a Cms Api. Example provided for Wordpress and Prestashop.

How to use it?

  1. Generate a Windows 10 application with Windows App Studio, that contains one (or more) collection(s)
  2. Download and unzip the Visual Studio source package for Windows 10
  3. Copy Install_CategoriesForAppStudio directory to your root directory VS solution
  4. Launch cmd.exe (the command line utility) and go to the Install_CategoriesForAppStudio directory in your VS solution
  5. Launch CategoriesForAppStudio:
    CategoriesForAppStudio {WAS_APP_NAME} -bc|-c {NAME_COL_CONFIG_1} {NAME_COL_CONFIG_2} ... {NAME_COL_CONFIG_N} [-path {PATH_DEST}] where:
  • WAS_APP_NAME is the name of the application (used to the namespace, without spaces or other special characters)
  • use -bc to generate the base and eventually the collection(s)
  • use -c to only generate the collection(s)
  • NAME_COL_CONFIG is the name of the collection config class (= collection config .cs file)
  • use -path PATH_DEST to specify the root directory of the VS solution (if the Install_CategoriesForAppStudio directory isn't in the root directory of the VS solution)
  1. Configure the files in your WAS_APP_NAME\Sections directory, mainly the [COLLECTION_NAME]Config.cs file.
    See further for more details.
  2. Build and run your Windows 10 app (with Visual Studio 2015), and enjoy!!!!

Where are your data from?

For your app, your collections can use data from:

  • 'static resources' (directly in your app)
  • 'dynamic resources':
    • public read access
    • managed by you, with your personal account in the Windows App Studio site
    • saved in the Microsoft Azure cloud
  • an online backoffice
    In this case, CategoriesForAppStudio can help you!
    A cheap and easy way, is to use a backoffice solution with a REST API web service (and usually with categorized contents).
    For example:
    • a CMS like Wordpress
    • an e-commerce solution like Prestashop

For another REST API, you will just have to create 2 classes (like for Wordpress and Prestashop), in the DataProviders project:

  • [YOUR_API]Schema.cs file
  • [YOUR_API]Parser.cs file

Prestashop backoffice

Configuring Prestashop site

Prestashop is provided with a REST API, disabled by default.
In order to enable it (and to create the "authentication key", go to the Prestashop documentation).

You will have to check, at least:

  • line products, column GET
  • line categories, column GET

Configuring your collection

The files to modify are in the 'WAS_APP_NAME' project, in the 'Sections' directory.
By default, after the CategoriesForAppStudio installation, the Prestashop version of these files are used, but you can exclude them from the project and include the files from another version.

Note that the 'Show all files' option in VS is very useful!).

2 files are used to configure your collection:

  1. [COLLECTION_NAME]Shema - Prestashop.cs. This class must inherit from PrestashopSchema. No need to add something to this new class (unless you want to!).

  2. [COLLECTION_NAME]Config - Prestashop.cs. This is the main config class.
    For a quick configuration, all you need to do is:

  • to replace the url with your own url, in the line:
SiteUrl = "http://PRESTASHOP_SITE_NAME.com",
  • to replace the "API_KEY" with your own "authentication key", in the line:
NetCredential = new NetworkCredential("API_KEY", "", "")
  • to replace the "category_2" with your own root category id (in the example, the root category is "2"), in the line:
new PrestashopParser<NewCol1Schema>("category_2"),

(null is allowed: this is the default value).

Note that you can change the following parameters, in the JsonDataProviderWithCategories constructor:

  • the VisibleItemsType enum parameter: All, CurrentLevel and AllForCurrentCategory, to show the appropriate items
  • the VisibleCategoriesType enum parameter: All, CurrentLevel and NotEmpty, to show the appropriate categories

Wordpress backoffice

Configuring Wordpress site

Wordpress doesn't yet provide a REST API, but will have it soon (in Wordpress v5?). The official plugin is WP REST API.
So you must install it in order to access to your contents through the API.

Notes:

  • a v2 version is coming, with big changes... but do not use it in production!
  • ACF (Advanced Custom Fields) is a great plugin, that I used to:
    • add an image custom field to the categories,
    • add custom fields to a new custom post (like the standard "category" field)

Configuring your collection

The files to modify are in the 'WAS_APP_NAME' project, in the 'Sections' directory.
By default, after the CategoriesForAppStudio installation, the Prestashop version of these files are used, so you must exclude them from the project and include the files from another version.

Note that the 'Show all files' option in VS is very useful!).

3 files are used to configure your collection:

  1. [COLLECTION_NAME]Shema - Wordpress.cs. This class must inherit from WordpressSchema. No need to add something to this new class (unless you want to!).
    For the CustomPost version, you can use the [COLLECTION_NAME]Shema - Wordpress - CustomPost.cs file, if you want...

  2. [COLLECTION_NAME]WordpressParser - CustomField.cs (or [COLLECTION_NAME]WordpressParser - CustomPost.cs in the CustomPost case). This file is use to change the default behavior of the WordpressParser, in the case of custom fields.

  3. [COLLECTION_NAME]Config.cs. This is the main config class.
    For the CustomPost version, use the [COLLECTION_NAME]Config - Wordpress - CustomPost.cs file.
    For a quick configuration, all you need to do is:

  • to replace the url with your own url, in the line:
SiteUrl = "http://WORDPRESS_SITE_NAME.com",
  • for the custom post version, to replace the "POSTTYPE_NAME" with your own custom post name, in the lines:
ApiFunction = "posts?type=POSTTYPE_NAME"
new [COLLECTION_NAME]Parser<[COLLECTION_NAME]Schema>(null, "category", "POSTTYPE_NAME")
  • to add your own root category id parameter (if needed), in the line:
new [COLLECTION_NAME]Parser<[COLLECTION_NAME]Schema>(),

Note that you can add the following parameters, in the JsonDataProviderWithCategories constructor:

  • the VisibleItemsType enum parameter: All, CurrentLevel and AllForCurrentCategory, to show the appropriate items.
  • the VisibleCategoriesType enum parameter: All, CurrentLevel and NotEmpty, to show the appropriate categories.

TODO list (v2015.09.05)

  • with the previous version of Windows App Studio, a config variable was stored in a class (xDataProvider) but is now store in the DataModelBase class. I made a new config variable for the categories, but I didn't move it. It would be great if the 2 config variables were stored in the same class!
  • the XAML for the categories list could be better: I used an existing list layout, but it isn't very good.
  • the "AppStudio.DataProviders" directory's project could be in the WindowsAppStudio.DataProviders dll (https://github.com/wasteam/waslibs/tree/master/src/AppStudio.DataProviders)

Changelog

  • v2015.11.03 : compatible with the official Windows 10 generation of Windows App Studio
  • v2015.09.05 : compatible with the official Windows 10 generation of Windows App Studio (online since late of july 2015)
  • v2015.06.19 : first version, compatible with the beta Windows 10 generation (with Win8/WP8 solutions)

Credits

Hervé PHILIPPE

alchiweb[at]live.fr / http://alchiweb.fr

If you have questions, let me know!

categoriesforappstudio's People

Contributors

alchiweb avatar

Watchers

 avatar

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.