Skip to content
This repository was archived by the owner on Dec 21, 2023. It is now read-only.

Commit 3d7bafd

Browse files
committed
Add Wiki and migrate some wiki pages
1 parent 88b1a4d commit 3d7bafd

19 files changed

Lines changed: 983 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATagHelperContent_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003Fhome_003Finfinity_003F_002Econfig_003FJetBrains_003FRider2021_002E1_003Fresharper_002Dhost_003FSourcesCache_003FF627DDE6_002D49E5_002D42E1_002DB30B_002D43D5CEB7ED8F_003FE_003FTagHelperContent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>

OpenTabletDriver.Web/Controllers/PluginsController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public PluginsController(IPluginMetadataService pluginMetadataService)
1313

1414
private IPluginMetadataService pluginMetadataService;
1515

16+
[ResponseCache(Duration = 300)]
1617
public async Task<IActionResult> Index()
1718
{
1819
var metadata = await pluginMetadataService.GetPlugins();
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace OpenTabletDriver.Web.Controllers
4+
{
5+
public class WikiController : Controller
6+
{
7+
[ResponseCache(Duration = 300)]
8+
public IActionResult Index()
9+
{
10+
return View();
11+
}
12+
13+
[ResponseCache(Duration = 300)]
14+
[Route("Wiki/{category}/{page}")]
15+
public IActionResult Wiki(string category, string page)
16+
{
17+
return View($"{category}/{page}");
18+
}
19+
}
20+
}

OpenTabletDriver.Web/OpenTabletDriver.Web.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@
1111

1212
<ItemGroup Label="NuGet Packages">
1313
<PackageReference Include="Markdig" Version="0.25.0" />
14+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="5.0.8" />
1415
</ItemGroup>
1516

1617
<ItemGroup>
1718
<_ContentIncludedByDefault Remove="Views\Wiki\Index.cshtml" />
19+
<_ContentIncludedByDefault Remove="Views\Wiki\Configurations\Guide.cshtml" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<Folder Include="wwwroot\images\OS" />
1824
</ItemGroup>
1925

2026
</Project>
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Immutable;
4+
using System.IO.Pipes;
5+
using System.Linq;
6+
using System.Text.RegularExpressions;
7+
using System.Threading.Tasks;
8+
using Microsoft.AspNetCore.Html;
9+
using Microsoft.AspNetCore.Razor.TagHelpers;
10+
using Microsoft.CodeAnalysis;
11+
12+
namespace OpenTabletDriver.Web.TagHelpers
13+
{
14+
[HtmlTargetElement("codeblock")]
15+
public class CodeBlockTagHelper : TagHelper
16+
{
17+
public string Language { set; get; }
18+
19+
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
20+
{
21+
output.TagName = "pre";
22+
23+
if (output.Attributes.TryGetAttribute("class", out var classAttr))
24+
output.Attributes.SetAttribute("class", $"{classAttr.Value} card card-body");
25+
else
26+
output.Attributes.Add("class", $"card card-body");
27+
28+
29+
var content = await output.GetChildContentAsync();
30+
var innerHtml = content.GetContent().Trim('\n');
31+
32+
var body = TrimPreceding(innerHtml, ' ');
33+
output.Content.SetHtmlContent(body);
34+
}
35+
36+
private string TrimPreceding(string value, char character)
37+
{
38+
var lines = value.Split(Environment.NewLine);
39+
int preceding = CountPreceding(lines, character);
40+
var trimmedLines = from line in lines
41+
select TrimPrecedingLine(line, character, preceding);
42+
43+
var formattedLines = LanguageFormat(trimmedLines.ToArray(), Language);
44+
45+
return string.Join(Environment.NewLine, formattedLines);
46+
}
47+
48+
private IEnumerable<string> LanguageFormat(IList<string> lines, string language)
49+
{
50+
switch (language)
51+
{
52+
case "sh":
53+
case "bash":
54+
case "nix":
55+
{
56+
for (int i = 0; i < lines.Count; i++)
57+
{
58+
var line = lines[i];
59+
if (line.TrimStart().StartsWith("#"))
60+
{
61+
var nextLine = lines[i + 1];
62+
const string tag = "span";
63+
yield return $"<{tag} class=\"text-muted\">{line}</{tag}>{nextLine}";
64+
i++;
65+
}
66+
else
67+
{
68+
yield return line;
69+
}
70+
}
71+
72+
break;
73+
}
74+
case "ini":
75+
{
76+
for (int i = 0; i < lines.Count; i++)
77+
{
78+
var line = lines[i];
79+
if (Regex.IsMatch(line, @"^\[.+?\]$"))
80+
{
81+
var nextLine = lines[i + 1];
82+
const string tag = "span";
83+
yield return $"<{tag} class=\"text-info\">{line}</{tag}>{nextLine}";
84+
i++;
85+
}
86+
else
87+
{
88+
yield return line;
89+
}
90+
}
91+
92+
break;
93+
}
94+
default:
95+
{
96+
foreach (var line in lines)
97+
yield return line;
98+
break;
99+
}
100+
}
101+
}
102+
103+
private int CountPreceding(IEnumerable<string> lines, char leadingCharacter)
104+
{
105+
foreach (var line in lines)
106+
{
107+
// Make sure that the line actually starts with the leading character
108+
if (line.StartsWith(leadingCharacter) == false)
109+
continue;
110+
111+
// Determine last index of leading character, return if something else is found
112+
for (var i = 0; i < line.Length; i++)
113+
{
114+
var character = line[i];
115+
if (character != leadingCharacter)
116+
return i;
117+
}
118+
119+
// Assume that this line is the template for trimming
120+
return line.Length;
121+
}
122+
123+
throw new ArgumentException("No lines match the target leading character.", nameof(lines));
124+
}
125+
126+
private string TrimPrecedingLine(string line, char character, int amount)
127+
{
128+
return line.StartsWith(character) ? new string(line.Skip(amount).ToArray()) : line;
129+
}
130+
}
131+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<section class="py-3">
2+
<h2>@ViewBag.Title</h2>
3+
<hr/>
4+
</section>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<div class="ms-4 w-15" style="width: 15%">
2+
<div class="card">
3+
<div class="card-header text-center">
4+
<h6 class="mt-2">Navigation</h6>
5+
</div>
6+
<ul class="list-group list-group-flush text-muted text-center" id="wiki-navigation"></ul>
7+
</div>
8+
</div>
9+
10+
<script type="text/javascript">
11+
document.onreadystatechange = function () {
12+
if (document.readyState == 'complete') {
13+
let navList = document.getElementById('wiki-navigation');
14+
let navItems = document.querySelectorAll('.wiki-nav-item');
15+
navItems.forEach(function (item) {
16+
let itemName = item.textContent;
17+
let id = item.id;
18+
navList.innerHTML +=
19+
'<li class=\'list-group-item\'>' +
20+
'<a class=\' link-light\' href=\'#' + id + '\'>' + itemName + '</a>' +
21+
'</li>';
22+
});
23+
}
24+
}
25+
</script>

OpenTabletDriver.Web/Views/Shared/_Layout.cshtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<title>@pageTitle</title>
1414
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@5.0.2/dist/darkly/bootstrap.min.css" integrity="sha256-IzD7YgcFC7mrH3sadY/G75Gc49OgfS5IVOgFlxtdoUI=" crossorigin="anonymous"></link>
1515
<link rel="stylesheet" href="~/css/site.css"></link>
16+
@await RenderSectionAsync("Styles", required: false)
1617
</head>
1718
<body>
1819
<header>
@@ -35,6 +36,9 @@
3536
<li class="nav-item">
3637
<a class="nav-link text-light" asp-area="" asp-controller="Plugins" asp-action="Index">Plugins</a>
3738
</li>
39+
<li class="nav-item">
40+
<a class="nav-link text-light" asp-area="" asp-controller="Wiki" asp-action="Index">Wiki</a>
41+
</li>
3842
<li class="nav-item">
3943
<a class="nav-link text-light" asp-area="" asp-controller="Changelog" asp-action="Index">Changelog</a>
4044
</li>
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
@{
2+
ViewBag.Title = "Linux FAQ";
3+
}
4+
5+
<partial name="Wiki/_Header"/>
6+
7+
<div class="d-flex px-4">
8+
<div class="flex-fill">
9+
<h3 class="wiki-nav-item pb-2" id="ghost-cursor">
10+
Teleporting Cursor Position
11+
</h3>
12+
<div class="ms-3">
13+
<p>
14+
This occurs because another program is reading the tablet at the same time as OpenTabletDriver.
15+
<small>
16+
<a class="link-light" href="https://github.com/InfinityGhost/OpenTabletDriver/issues/68">#68</a>
17+
</small>
18+
<ol>
19+
<li>
20+
Perform the following commands in a terminal
21+
<codeblock class="mt-2">
22+
echo "blacklist wacom" | sudo tee -a /etc/modprobe.d/blacklist.conf
23+
sudo rmmod wacom
24+
</codeblock>
25+
</li>
26+
</ol>
27+
</p>
28+
</div>
29+
30+
<hr/>
31+
32+
<h3 class="wiki-nav-item pb-2" id="fail-device-streams">
33+
Failed to open device streams
34+
</h3>
35+
<div class="ms-3">
36+
<p>
37+
This occurs due to a lack of permissions to open a device stream.
38+
It is resolved by creating udev rules that give these permissions.
39+
<br/>
40+
If you installed OpenTabletDriver via your package manager,
41+
you may need to run the following command then replug your tablet.
42+
<codeblock class="mt-2">
43+
sudo udevadm control --reload-rules
44+
</codeblock>
45+
</p>
46+
<p>
47+
Otherwise, perform the following
48+
</p>
49+
<ol>
50+
<li>
51+
Download the latest udev rules from the GitHub CI<br/>
52+
<small class="ms-3 text-muted">
53+
Note: You must be logged into GitHub to see these builds, otherwise you will get a 404.
54+
</small>
55+
</li>
56+
<li>
57+
Run the following commands, replacing <code class="bg-">&lt;file&gt;</code> with the extracted file
58+
<codeblock class="mt-2">
59+
sudo mv &lt;file&gt; /etc/udev/rules.d/99-opentabletdriver.rules
60+
</codeblock>
61+
</li>
62+
</ol>
63+
</div>
64+
65+
<hr/>
66+
67+
<h3>Failed to initialize virtual device</h3>
68+
<div class="ms-3">
69+
<h4>EACCESS</h4>
70+
<codeblock class="mt-2">
71+
sudo chmod 0666 /dev/uinput
72+
</codeblock>
73+
74+
<h4>ENODEV</h4>
75+
<p>
76+
Rebooting is the only option here. Your kernel was very likely updated, or some component of
77+
uinput was modified which requires a reboot to resolve.
78+
</p>
79+
</div>
80+
81+
<hr/>
82+
83+
<h3 class="wiki-nav-item pb-2" id="performance-nvidia">
84+
Poor performance with NVIDIA
85+
</h3>
86+
<div class="ms-3">
87+
<ol>
88+
<li>Disable <code>Force full composition pipeline</code> in the NVIDIA settings panel.</li>
89+
</ol>
90+
</div>
91+
92+
<hr/>
93+
94+
<h3 class="wiki-nav-item pb-2" id="display-session-not-detected">
95+
X11/Wayland Session not detected
96+
</h3>
97+
<div class="ms-3">
98+
<h4>X11 <small class="text-muted">(systemd)</small></h4>
99+
<div class="mx-3">
100+
<p>
101+
Your <code>.xinitrc</code> is likely configured improperly and the <code>DISPLAY</code> environment
102+
variable isn't set for systemd.<br/>
103+
Proper configuration for the <code>.xinitrc</code> file can be found
104+
<a href="https://wiki.archlinux.org/index.php/Xinit#Configuration">here</a>.<br/>
105+
<small class="ms-3 text-muted">
106+
Note: The fix below is just a quick and dirty fix to get OpenTabletDriver running and should
107+
instead be resolved as above.
108+
</small>
109+
</p>
110+
<ol>
111+
<li>
112+
Create an override file
113+
<codeblock class="mt-2" language="sh">
114+
# Opens with whatever program is set to $EDITOR
115+
systemctl --user edit opentabletdriver.service
116+
</codeblock>
117+
</li>
118+
<li>
119+
Add this block below the first 2 lines of the file, then save and exit
120+
<codeblock class="mt-2" language="ini">
121+
[Service]
122+
Environment=DISPLAY=:0
123+
</codeblock>
124+
</li>
125+
<li>
126+
Finally, run the following commands
127+
<codeblock class="mt-2" language="sh">
128+
# Reload the systemd user daemon
129+
systemctl --user daemon-reload
130+
# Start the OpenTabletDriver daemon service (restarts if already running)
131+
systemctl --user restart opentabletdriver.service
132+
</codeblock>
133+
</li>
134+
</ol>
135+
</div>
136+
137+
<h4>Wayland <small class="text-muted">(systemd)</small></h4>
138+
<div class="mx-3">
139+
<ol>
140+
<li>Create an override file</li>
141+
<codeblock class="mt-2" language="sh">
142+
# Opens with whatever program is set to $EDITOR
143+
systemctl --user edit opentabletdriver.service
144+
</codeblock>
145+
<li>Add this block below the first 2 lines of the file, then save and exit</li>
146+
<codeblock class="mt-2">
147+
[Service]
148+
Environment=WAYLAND_DISPLAY=:0
149+
</codeblock>
150+
<li>Finally, run the following commands</li>
151+
<codeblock class="mt-2">
152+
systemctl --user daemon-reload
153+
systemctl --user restart opentabletdriver.service
154+
</codeblock>
155+
</ol>
156+
</div>
157+
</div>
158+
</div>
159+
<partial name="Wiki/_Navigation"/>
160+
</div>

0 commit comments

Comments
 (0)