Skip to content

Commit

Permalink
Merge pull request #1 from symptum/editor-uno
Browse files Browse the repository at this point in the history
Ported Symptum.Editor to Uno
  • Loading branch information
ShankarBUS authored Dec 3, 2023
2 parents f16e3db + ce89aed commit 6c35dbb
Show file tree
Hide file tree
Showing 124 changed files with 5,077 additions and 1,958 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/web-editor-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Symptum Web Editor Deployment
on:
push:
branches: [ main ]
workflow_dispatch: # Allows workflow to be ran via a button
jobs:
deploy-to-github-pages:
runs-on: windows-latest
name: Deploy to GitHub Pages
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: main
- name: Checkout Symptum.Data
uses: actions/checkout@v4
with:
repository: symptum/Symptum.Data
path: Symptum.Data
- name: Correct Web Manifest Scope
run: |
cd ./main/src/Symptum.Editor/Symptum.Editor.Wasm/
(Get-Content manifest.webmanifest) -Replace '/', '/editor/' | Set-Content manifest.webmanifest
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore Dependencies
run: dotnet restore ./main/src/Symptum.Editor/Symptum.Editor.Wasm/Symptum.Editor.Wasm.csproj
- name: Publish
run: dotnet publish ./main/src/Symptum.Editor/Symptum.Editor.Wasm/Symptum.Editor.Wasm.csproj "-p:WasmShellWebAppBasePath=/editor/" --no-restore -f net8.0 -c Release -o out
- name: Create Editor Folder
run: mkdir editor
- name: Copy Files to Editor Folder
run: copy-item out\\wwwroot\\* editor -force -recurse -verbose
# add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore)
- name: Add .nojekyll file
run: touch editor/.nojekyll
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
repo: symptum/editor
build_dir: ./editor/
author: Shankar <[email protected]>
committer: Shankar <[email protected]>
jekyll: false
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
212 changes: 186 additions & 26 deletions Symptum.sln

Large diffs are not rendered by default.

19 changes: 6 additions & 13 deletions src/Symptum.Core/Subjects/Books/BookStore.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
using CsvHelper;
using Symptum.Core.Subjects.QuestionBank;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Symptum.Core.Subjects.Books
{
Expand All @@ -28,17 +21,17 @@ public static void SaveBooks(string path)
}
}

public static void LoadBooks(string path)
public static void LoadBooks(string csv)
{
if (!File.Exists(path) || Path.GetExtension(path).ToLower() != ".csv") return;
if (string.IsNullOrEmpty(csv)) return;

using var reader = new StreamReader(path);
using var csv = new CsvReader(reader, CultureInfo.InvariantCulture);
var books = csv.GetRecords<Book>();
using var reader = new StringReader(csv);
using var csvReader = new CsvReader(reader, CultureInfo.InvariantCulture);
var books = csvReader.GetRecords<Book>();
foreach (var book in books)
{
Books.Add(book);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Diagnostics;
using System.Text.Json;

namespace Symptum.Core.Subjects.QuestionBank
namespace Symptum.Core.Subjects.QuestionBank
{
public class QuestionBankManager
{
Expand Down
17 changes: 9 additions & 8 deletions src/Symptum.Core/Subjects/QuestionBank/QuestionBankTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public QuestionBankTopic(string topicName)
TopicName = topicName;
}

public void SaveAsCSV(string path)
public string ToCSV()
{
using var writer = new StreamWriter(path);
using var writer = new StringWriter();
using var csv = new CsvWriter(writer, CultureInfo.InvariantCulture);
csv.WriteHeader<QuestionEntry>();
csv.NextRecord();
Expand All @@ -48,16 +48,17 @@ public void SaveAsCSV(string path)
csv.WriteRecord(entry);
csv.NextRecord();
}
return writer.ToString();
}

public static QuestionBankTopic ReadTopicFromCSV(string path)
public static QuestionBankTopic CreateTopicFromCSV(string topicName, string csv)
{
if (!File.Exists(path) || Path.GetExtension(path).ToLower() != ".csv") return null;
if (string.IsNullOrEmpty(csv)) return null;

QuestionBankTopic topic = new(Path.GetFileNameWithoutExtension(path));
using var reader = new StreamReader(path);
using var csv = new CsvReader(reader, CultureInfo.InvariantCulture);
topic.QuestionEntries = new(csv.GetRecords<QuestionEntry>().ToList());
QuestionBankTopic topic = new(topicName);
using var reader = new StringReader(csv);
using var csvReader = new CsvReader(reader, CultureInfo.InvariantCulture);
topic.QuestionEntries = new(csvReader.GetRecords<QuestionEntry>().ToList());

return topic;
}
Expand Down
12 changes: 6 additions & 6 deletions src/Symptum.Core/Subjects/QuestionBank/QuestionEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using CsvHelper.TypeConversion;
using Symptum.Core.Subjects.Books;
using Symptum.Core.TypeConversion;
using System.Runtime.CompilerServices;

namespace Symptum.Core.Subjects.QuestionBank
{
Expand All @@ -28,12 +27,13 @@ public string Title
set => SetProperty(ref title, value);
}

private string description = string.Empty;
private List<string> descriptions;

public string Description
[TypeConverter(typeof(StringListConverter))]
public List<string> Descriptions
{
get => description;
set => SetProperty(ref description, value);
get => descriptions;
set => SetProperty(ref descriptions, value);
}

private bool hasPreviouslyBeenAsked;
Expand Down Expand Up @@ -100,7 +100,7 @@ public QuestionEntry Clone()
{
Id = new() { QuestionType = id.QuestionType, SubjectCode = id.SubjectCode, CompetencyNumbers = id.CompetencyNumbers },
Title = Title,
Description = Description,
Descriptions = CloneList(Descriptions),
HasPreviouslyBeenAsked = HasPreviouslyBeenAsked,
Importance = Importance,
YearsAsked = CloneList(YearsAsked),
Expand Down
3 changes: 1 addition & 2 deletions src/Symptum.Core/Symptum.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
167 changes: 167 additions & 0 deletions src/Symptum.Editor/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

# This file is the top-most EditorConfig file
root = true

##########################################
# Common Settings
##########################################

[*]
indent_style = space
end_of_line = crlf
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8

##########################################
# File Extension Settings
##########################################

[*.{yml,yaml}]
indent_size = 2

[.vsconfig]
indent_size = 2
end_of_line = lf

[*.sln]
indent_style = tab
indent_size = 2

[*.{csproj,proj,projitems,shproj}]
indent_size = 2

[*.{json,slnf}]
indent_size = 2
end_of_line = lf

[*.{props,targets}]
indent_size = 2

[*.xaml]
indent_size = 2
charset = utf-8-bom

[*.xml]
indent_size = 2
end_of_line = lf

[*.plist]
indent_size = 2
indent_style = tab
end_of_line = lf

[*.manifest]
indent_size = 2

[*.appxmanifest]
indent_size = 2

[*.{json,css,webmanifest}]
indent_size = 2
end_of_line = lf

[web.config]
indent_size = 2
end_of_line = lf

[*.sh]
indent_size = 2
end_of_line = lf

[*.cs]
# EOL should be normalized by Git. See https://github.com/dotnet/format/issues/1099
end_of_line = unset

# See https://github.com/dotnet/roslyn/issues/20356#issuecomment-310143926
trim_trailing_whitespace = false

tab_width = 4
indent_size = 4

# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true

# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

#### Naming styles ####

# Naming rules

dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.interface.required_modifiers =

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.types.required_modifiers =

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
dotnet_naming_symbols.non_field_members.required_modifiers =

# Naming styles

dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case

dotnet_naming_style.pascal_case.required_prefix =
dotnet_naming_style.pascal_case.required_suffix =
dotnet_naming_style.pascal_case.word_separator =
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion

csharp_indent_labels = one_less_than_current
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_prefer_primary_constructors = true:suggestion
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
Loading

0 comments on commit 6c35dbb

Please sign in to comment.